James – Thanks so much for a quick response. I followed your suggestion and 
added the code by calling getNames() as described below. I found that HAPI is 
creating a phantom DG1 segment even when the Hl7 message does not have any DG1, 
for that reason I’m doing an extra logic in the highlighted text below. Is it 
intended behavior? If yes, what is the best way of handling it?

                String Names[] = Msg.getNames();
                List<DG1> LDGs = new ArrayList<DG1>();
                for(String Name: Names){
                   if(Name == null || Name.startsWith("DG1") == false)
                     continue;
                   DG1 DG = (DG1)Msg.get(Name);
                   if(DG !=null && 
dg.getDiagnosisCodeDG1().getIdentifier().getValue()) !=null )
                     LDGs.add(DG);
                }

Regards,
Brijesh

From: James Agnew [mailto:jamesag...@gmail.com]
Sent: Tuesday, November 11, 2014 6:15 PM
To: Singh, Brijesh
Cc: hl7api-devel@lists.sourceforge.net
Subject: Re: [HAPI-devel] DG1 segments repetition.

Hi Brijesh,
You're right, the custom segments are causing an issue since the parser csn't 
see subsequent DG1 repetitions as actual repetitions.
The easiest way to do this would be to call
MessageInstance.getAll("DG1")
followed by
MessageInstance.getAll("DG12")
followed by
MessageInstance.getAll("DG13")
etc.. Basically HAPI creates nonstandard segments for each of the following 
DG1s by adding a sequential number to the end.
If you wanted to be more fancy, you could create a custom structure that has a 
group containing the custom segment as well, or you could override the parser 
and use string maniulation to remove the Z-segments before parsing.. But the 
method above is definitely the least work.
Incidentally MessageInstance.getNames() will give you the names of all the 
segments (including the "DG1[number]" ones) so you will know how many there are.
Cheers,
James

On Tue, Nov 11, 2014 at 2:06 PM, Singh, Brijesh 
<sin...@advisory.com<mailto:sin...@advisory.com>> wrote:
Hi – I’m using HAPI library(2.2) to parse the below message and calling the 
method getAll(“DG1”) ( Structure[] Structs = MessageInstance.getAll(“DG1”) ) to 
retrieve the DG1 segments. I’m having issues getting all DG1 segments. From the 
below message, able to retrieve only one DG1 segment. Looks like the custom 
segment (ZDG) is in the middle of repeating DG1 segments and breaking the 
repetition.

Can you please suggest if I can use other API methods to retrieve all DG1 ( 3 
in the below case) ignoring ZDG segments?

Thanks for your help.


MSH|^~\&|SCM|SCM|HL7ADT||20130114001147||ADT^A08|8456356603013|P|2.3
PID||5012223067<tel:5012223067>^^^Corporate Num|50730137^^^EAST 
MRN|300000003^^^EID|Moose^Bullwinkle^J||19091011|F||1|1 Roanoke St^^New 
York^NY^11111^USA^Home||(888)111-1111^^^^^888^111-1111^^Home|^^^^^^^^Cellular|ENG|W|CA|3000000039^^^EAST
 MRN|111165812|11119791||Hispanic Origin
NK1|1|Bugs^Bee|19||(888)111-1111^^^^^888^111-1111^^Home||Emergency
PV1||E|ERM^^^EAST 
MRN|Emergency|||N20714^Chris^Bob^Bruce~1907828742^^^^^^^^^^^^NPI|||REH||||Non-Health
 Care||0||Emergency|3000000039^^^EAST 
MRN|||||||||||||||||||||Clean||||20130115001000
PV2||^N|ABDOMINAL PAIN NAUSEA COLD SYM  OBX|1|ST|Intolerances||None 
Entered||||||X
DG1|1||^CHEST PAIN  DEHYDRATION  NAUSE|CHEST PAIN  DEHYDRATION  NAUSE||Visit 
Reason
ZDG|1||^CHEST PAIN  DEHYDRATION  NAUSE|CHEST PAIN  DEHYDRATION  NAUSE||Visit 
Reason
DG1|2||^CHEST PAIN  DEHYDRATION  NAUSE|CHEST PAIN  DEHYDRATION  NAUSE||Visit 
Reason
ZDG|2||^CHEST PAIN  DEHYDRATION  NAUSE|CHEST PAIN  DEHYDRATION  NAUSE||Visit 
Reason
DG1|3||^CHEST PAIN  DEHYDRATION  NAUSE|CHEST PAIN  DEHYDRATION  NAUSE||Visit 
Reason
ZDG|3||^CHEST PAIN  DEHYDRATION  NAUSE|CHEST PAIN  DEHYDRATION  NAUSE||Visit 
Reason
OBX|2|ST|Allergies||See Allergy Icon/Pt Info Tab||||||X
AL1|1|Drug|quinolone antibiotics^^^^23^Multum|Swelling|facial swelling 
ZAL||||AL|Swelling
AL1|2|Drug|quinolone topicals^^^^70^Multum|Swelling|facial swelling 
ZAL||||AL|Swelling
IN1|1||BLUE|BLUE CROSS^MEDICARE|PO BOX 
880031^^Boston^MA^02201||(888)111-1111^^^^^888^111-1111||||||||Medicare|Bugs^Bunny^M|18|19000928|1
 Roanoke St^^New York^NY^11111^USA||||||||||||||||||||||||Male||||||1112223067
IN2||475846521|DISABLED||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||(888)111-1111^^Phone^^^888^111-1111|||||||DISABLED

Regards,
Brijesh Singh

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to