Unable to Parse Multiple IN1 Segment in HL7 using HAPI TERSER

狂风中的少年 提交于 2019-12-14 02:03:29

问题


I am receiving HL7 messages version 2.5.1.

MSH|..
PID|..
PV1|..
ORC|..
IN1|1|...
IN1|2|....

So in the above example IN1 is repeating, however when i try to Parse the second IN1 segment with TERSER it throws an exception "Can't create repetition #1 of Structure IN1 - this Structure is non-repeating".

This is what i have tried so far

    string insurance = terser.Get("/.INSURANCE/.IN1(0)-1"); // Works fine
    string insurance = terser.Get("/.INSURANCE/.IN1(1)-1"); // Throws exception
string insurance = terser.Get("/.INSURANCE(0)/.IN1(0)-1"); // Works fine
    string insurance = terser.Get("/.INSURANCE(1)/.IN1(0)-1"); // Throws exception

回答1:


I just started learning about HAPI as well. I notice that in your example you did not specify how you parse the message. Most than likey, it was parse into a generic message using the terser. If that is the case, I think it should look something like this

string insurance = terser.Get("/.INSURANCE/.IN12-1"); 

I believe Generic Message has no groups and to access this segment probably need to use IN12 instead of IN1(1)




回答2:


You are close but you are using a repeating group on IN1 which is not a repeating segment. Remember INSURANCE group is repeating the segments within are not:

Try:

/.INSURANCE(0)/.IN1-1"

/.INSURANCE(1)/.IN1-1"




"/.INSURANCE(1)/.IN1(0)-1" 

works because there's only one IN1 segment in the group (rep 0 defaults to the 1st segment in the group):

From the Terser api read up on the section on groups:

...

group_spec: ["."] group_name_pattern

Here, a . indicates that the group should be searched for (using a SegmentFinder) starting at the current location in the message. The wildcards "" and "?" represent any number of arbitrary characters, and a single arbitrary character, respectively. For example, "M" and "?S?" match MSH. The first group with a name that matches the given group_name_pattern will be matched.

The segment_spec is analogous to the group_spec.

As another example, the following subcomponent in an SIU_S12 message:

msg.getSIU_S12_RGSAISNTEAIGNTEAILNTEAIPNTE(1).getSIU_S12_AIGNTE().getAIG().getResourceGroup(1).getIdentifier();

...

is referenced by all of the following location_spec: /SIU_S12_RGSAISNTEAIGNTEAILNTEAIPNTE(1)/SIU_S12_AIGNTE/AIG-5(1)-1 /AIG(1)/SIU_S12_AIGNTE/AIG-5(1)-1 /AIG(1)/.AIG-5(1)

The search function only iterates through rep 0 of each group. Thus if rep 0 of the first group in this example was desired instead of rep 1, the following syntax would also work (since there is only one AIG segment position in SUI_S12):

/.AIG-5(1)



来源:https://stackoverflow.com/questions/36078622/unable-to-parse-multiple-in1-segment-in-hl7-using-hapi-terser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!