Thank you to everyone for your quick assistance.  Here is the code
snippet I did that worked:
 
     Segment pidSegment = terser.getSegment("PID-5");

     Type[] pid5Type = pidSegment.getField(5);

     for (int indx = 0; indx < pid5Type.length; indx++) {

        String subIndex = "(" + indx + ")";

        terser.get("PID-5" + subIndx + "-1");  // gets familyName

        terser.get("PID-5" + subIndx + "-2");  // gets givenName

     }

A little ugly but it keeps things generic so you do not have to pick an
HL7 version number in the domain model.

________________________________

From: Kamp, Daniel (GE Healthcare) 
Sent: Thursday, July 23, 2009 1:36 PM
To: [email protected]
Subject: How to access repeating fields using the generic Message type


Good afternoon,
I am trying to write a transformer which converts an HL7 message to a
local object graph.  In doing so, I need to account for repeating
fields. 
 
For example, PID-5 can have multiple names and we need to parse it out
into a List of PatientName objects (each PatientName object contains
family name, given name, and name type code).
 
Since we need to support many versions of HL7 we can not use a specific
v 2.x model data types.  Instead we are relying on the generic:
    ca.uhn.hl7v2.model.Message
    ca.uhn.hl7v2.util.Terser
to parse the message.
 
I have had a difficult time finding simple examples of parsing repeating
fields using these generic classes. 
 
I realize if we used 
     ca.uhn.hl7v2.model.v25.message 
it would be easier to do this, but we need to remain version agnostic.
 
Can anyone assist me in a simple way to extract a repeating field as
mentioned above?
 
Thank you in advance,
Dan
 
Dan Kamp
GE Healthcare
Information Technologies - Global Engineering
Shared Asset Solutions
T (847) 277- 4327
D *567-4327
E [email protected] <blocked::mailto:[email protected]> 
www.gehealthcare.com <blocked::http://www.gehealthcare.com/>
<http://www.gehealthcare.com/> 
 
------------------------------------------------------------------------------
_______________________________________________
Hl7api-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to