Menu

#253 Hapi Terser issue to retrieve HL7 segments

2.2
closed
nobody
hapi (2) Hl7 (2)
5
2020-01-24
2020-01-24
No

I am having the following Demo HL7 script which I need to retrieve using Terser.

MSH||||||||||||||||||||||||||||||
EVN||||||||||||||||||||||||||||||
PID|||3214^^^^|||||||||||||||||||
PV1||||||||||||||||||||||||||||||
PV2||||||||||||||||||||||||||||||
IN1|1|^Test IN1(1)|||||||||||||||
IN2|||^Test IN2^^^|||||||||||||||
IN1|2|^Test IN1(2)|||||||||||||||
IN2|||^Test IN2^^^|||||||||||||||
ROL|||^Test ROL^^^|||||||||||||||
DG1|||^Test DG1^^^|||||||||||||||
OBX||CWE|||||||||||||||||||||||||
GT1||123456^^^90XXXX^SS^^||||||||
NK1||^Test NK1^^^||||||||||||||||
ACC||^Test ACC^^^||||||||||||||||
ZAR|Test Z1||||||||||||||||||||||
ZSH|Test Z|||||||||||||||||||||||
ZAR|Test Z2||||||||||||||||||||||
ZSH|Test Z|||||||||||||||||||||||

I am having following issues. Please help.

  1. When I am retrieving the following - terser.get("/PID-3-1") - I am getting the expected result i.e. 3214.
    But the following result is giving NULL - terser.get("/ROL-3-2"), terser.get("/DG1-3-1"), terser.get("/OBX-2"), terser.get("/GT1-2-1"), terser.get("/NK1-2-2"), terser.get("/ACC-2-2").
    Please help me to retrieve ROL, DG1, OBX, GT1, NK1 and ACC segments.

  2. Also if I retrieve terser.get("/IN1-2-2"), I am having the expected result. But I am not able to retrieve the repetition of IN1. I have tried ("/IN1(1)-2-2"), ("/.INSURANCE(1)/.IN1-2-2") but didn't help.

  3. When I am retrieving external segment ("/ZAR-1"), it is returning my result. But I am not able to retrieve ("/ZAR(1)-1"), it's giving NULL. However if the 2nd ZAR segment comes after the 1st ZAR without any ZSH segment then I can retrieve the repetition of ZAR using ("/ZAR(1)-1").

I am waiting for your responses.

Discussion

  • Christian Ohr

    Christian Ohr - 2020-01-24

    Please provide details about the MSH segment. The Terser paths depend on the event type and the HL7 version.

     
    • Supratim Paul

      Supratim Paul - 2020-01-24

      Segment - MSH|^~\&|||||||ADT^A01|P|2.8.1||1
      Event Type is A01 and HL7 version is 2.8.1.

       

      Last edit: Supratim Paul 2020-01-24
  • Christian Ohr

    Christian Ohr - 2020-01-24
    1. Use version HAPI version 2.3
    2. You need to specify the segments in the order they are defined in the message definition! - your example is completely mixed up
    3. Custom Z segments appended to a message can never be in a group - how should the parser know that ZAR and ZSH supposed to form a group? If a segment is not immediately repeating, the second occurence gets a custom segment name (with a number appended to the segment name) to make it unique.

    Here is a working example (should also work with 2.8.1):

        @Test
        public void test() {
            String hl7 = "MSH|^~\\&|||||||ADT^A01|4711|P|2.5||1\r" +
                    "EVN||||||||||||||||||||||||||||||\r" +
                    "PID|||3214^^^^|||||||||||||||||||\r" +
                    "ROL|||^Test ROL^^^|||||||||||||||\r" +
                    "NK1||^Test NK1^^^||||||||||||||||\r" +
                    "PV1||||||||||||||||||||||||||||||\r" +
                    "PV2||||||||||||||||||||||||||||||\r" +
                    "OBX||CWE|||||||||||||||||||||||||\r" +
                    "DG1|||^Test DG1^^^|||||||||||||||\r" +
                    "GT1||123456^^^90XXXX^SS^^||||||||\r" +
                    "IN1|1|^Test IN1(1)|||||||||||||||\r" +
                    "IN2|||^Test IN2^^^|||||||||||||||\r" +
                    "IN1|2|^Test IN1(2)|||||||||||||||\r" +
                    "IN2|||^Test IN2^^^|||||||||||||||\r" +
                    "ACC||^Test ACC^^^||||||||||||||||\r" +
                    "ZAR|Test Z1||||||||||||||||||||||\r" +
                    "ZSH|Test Z|||||||||||||||||||||||\r" +
                    "ZAR|Test Z2||||||||||||||||||||||\r" +
                    "ZSH|Test Z|||||||||||||||||||||||"
            HapiContext hapiContext = new DefaultHapiContext()
            def msg = hapiContext.pipeParser.parse(hl7)
    
            Terser terser = new Terser(msg)
            println(terser.get("/PID-3-1"))
            println(terser.get("/ROL-3-2"))
            println(terser.get("/DG1-3-2"))
            println(terser.get("/OBX-2"))
            println(terser.get("/GT1-2-1"))
            println(terser.get("/NK1-2-2"))
            println(terser.get("/ACC-2-2"))
            println(terser.get("/INSURANCE(0)/IN1-2-2"))
            println(terser.get("/INSURANCE(1)/IN1-2-2"))
            println(terser.get("/ZAR-1"))
            println(terser.get("/ZAR2-1"))
        }
    

    And the output is

    3214
    Test ROL
    Test DG1
    CWE
    123456
    Test NK1
    Test ACC
    Test IN1(1)
    Test IN1(2)
    Test Z1
    Test Z2
    
     
    • Supratim Paul

      Supratim Paul - 2020-01-24

      Thanks for your input. Can you specify the exact Hapi JAR name?

       
  • Christian Ohr

    Christian Ohr - 2020-01-24
    • status: open --> closed
     

Log in to post a comment.