I’m having a problem using a Terser on a GenericMessage with repeating NTE
 segments.



I whipped up a test case to show the issue. Why does the terser getter like
“NTE2-3-1” work while “NTE(1)-3-1” fail? Is there any way to make the latter
format work?



@Test

public void testNTEQuirk() {

                String hl7Message = null;

                try {

                                hl7Message =
resourceUtil.getResourceAsString("nte_quirk.hl7");

                } catch (IOException e) {

                                fail("Could not load resource!");

                }



                GenericMessage message = new
GenericMessage.UnknownVersion(new DefaultModelClassFactory());



                try {

                                message.parse(hl7Message);

                } catch (EncodingNotSupportedException e) {

                                e.printStackTrace();

                                throw new RuntimeException("Could not parse
HL7 message! Encoding not supported.", e);

                } catch (HL7Exception e) {

                                e.printStackTrace();

                                throw new RuntimeException("Could not parse
HL7 message!", e);

                }

                Terser terser = new Terser(message);



                //"/." + segment + "(" + index + ")-" + field + "-" +
component;

                try {

                                //why do the next 3 lines work??

                                assertEquals("OBRnotes",
terser.get("/.NTE2-3-1"));

                                assertEquals("OBX",
terser.get("/.NTE3-3-1"));

                                assertEquals("notes",
terser.get("/.NTE4-3-1"));

                                assertEquals("ORCnotes",
terser.get("/.NTE(0)-3-1"));

                                //why do these lines fail??

                                assertEquals("OBRnotes",
terser.get("/.NTE(1)-3-1"));

                                assertEquals("OBX",
terser.get("/.NTE(2)-3-1"));

                                assertEquals("notes",
terser.get("/.NTE(3)-3-1"));

                } catch (HL7Exception e) {

                                fail();

                }

}





MSH|^~\&|ADM|CLF654321||CLF123456|200612131130||ORU^R01|4323424|P|2.5|||AL|NE

PID|||||

ORC|||||||||||||||||||

NTE|1||ORCnotes|

OBR||||||||||||||

NTE|2||OBRnotes|

OBX|1|||||||||||||||

NTE|3||OBX|

NTE|4||notes|
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to