Open annosresearch opened 6 years ago
I ran into this issue too. I tried the following code per the HAPI documentation:
ADT_A08 message = (ADT_A08) p.parse(rawMessage);
Segment zcnGenericSegment = (Segment) message.get("ZCN");
String zcnField5 = zcnGenericSegment.getField(5, 0).encode();
System.out.println(zcnField5);
This method produces the error `ZCN does not exist in the group ca.uhn.hl7v2.model.v25.message.ADT_A08
My HL7 message is structured like this:
MSH
PID
PD1
PV1
GT1
IN1
IN2
IN1
IN2
IN1
IN2
IN1
IN2
NK1
DG1
DG1
DG1
ZCN
To fix this I added this code System.out.println(message.printStructure());
which outputs:
ADT_A08 (start)
MSH - MSH|^~\&|...
EVN - EVN|A08|...
PID - PID|1|...
[ PD1 ] - PD1|...
[ { NK1 } ] - Not populated
PV1 - PV1|1|...
[ PV2 ] - Not populated
[ { DB1 } ] - Not populated
[ { OBX } ] - Not populated
[ { AL1 } ] - Not populated
[ { DG1 } ] - Not populated
[ DRG ] - Not populated
PROCEDURE (start)
[{
PR1 - Not populated
[ { ROL } ] - Not populated
}]
PROCEDURE (end)
[ { GT1 } ] - GT1|...
[{
IN1 - IN1|...
[ IN2 ] - IN2||...
[ IN3 ] - Not populated
}]
[{
IN1 - IN1|...
[ IN2 ] - IN2||...
[ IN3 ] - Not populated
}]
[{
IN1 - IN1|...
[ IN2 ] - IN2||...
[ IN3 ] - Not populated
}]
[{
IN1 - IN1|||...
[ IN2 ] - IN2||...
[ { NK1 } ] (non-standard) - NK1||...
[ { DG1 } ] (non-standard) - DG1|...
DG1|...
DG1|...
[ { ZCN } ] (non-standard) - ZCN|...
[ IN3 ] - Not populated
}]
INSURANCE (end)
[ ACC ] - Not populated
[ UB1 ] - Not populated
[ UB2 ] - Not populated
ADT_A08 (end)
Then I added System.out.println(Arrays.toString(message.getNames()));
with an output of:
[MSH, EVN, PID, PD1, NK1, PV1, PV2, DB1, OBX, AL1, DG1, DRG, PROCEDURE, GT1, INSURANCE, ACC, UB1, UB2]
This made me realize that the custom segment was added to the INSURANCE
group and could not be called directly using Segment zcnGenericSegment = (Segment) message.get("ZCN");
I had to add ADT_A08_INSURANCE zpiGenericIns = (ADT_A08_INSURANCE) message.get("INSURANCE", 3);
. Then Segment zpiGenericSegment = (Segment) zpiGenericIns.get("ZCN");
.
So the issue is that the custom segment may be nested under INSURANCE
, PROCEDURE
, etc. depending on where the segment is in the HL7 message. I don't know if this is a bug or if there is a standard order to segments.
So if anyone gets the error ca.uhn.hl7v2.HL7Exception: <segement> does not exist in the group ca.uhn.hl7v2.model.v25.message.*
for a custom segment it may be nested under a group depending on the message type.
Using System.out.println(message.printStructure());
will help determine where the segment is grouped.
Thank you good explanation about the scenario. I have non standard NTE for the SIU_12
MSH - MSH|^~\&|E
SCH - SCH||94
[ { TQ1 } ] - Not populated
[ { NTE } ] - NTE|1|| nte after sch|
[{
PID - PID|1||157
[ { ZPD } ] (non-standard) - ZPD||
[ PD1 ] - Not populated
[ PV1 ] - Not populated
[ PV2 ] - Not populated
[ { OBX } ] - Not populated
[ { DG1 } ] - Not populated
}]
PATIENT (end)
RESOURCES (start)
{
RGS - Not populated
SERVICE (start)
[{
AIS - Not populated
[ { NTE } ] - Not populated
}]
SERVICE (end)
GENERAL_RESOURCE (start)
[{
AIG - Not populated
[ { NTE } ] - Not populated
}]
GENERAL_RESOURCE (end)
LOCATION_RESOURCE (start)
[{
AIL - Not populated
[ { NTE } ] - Not populated
}]
LOCATION_RESOURCE (end)
PERSONNEL_RESOURCE (start)
[{
AIP - Not populated
[ { NTE } ] - Not populated
}]
PERSONNEL_RESOURCE (end)
}
RESOURCES (end)
[ { NTE2 } ] (non-standard) - NTE|1||after zpd
[ { LAN } ] (non-standard) - LAN|1
[ { PD1 } ] (non-standard) - PD1||
[ { ROL } ] (non-standard) - ROL|1
ROL|2
ROL|3
[ { PV1 } ] (non-standard) - PV1||
[ { PV2 } ] (non-standard) - PV2
[ { RGS } ] (non-standard) - RGS|1
[ { AIS } ] (non-standard) - AIS|1
[ { AIP } ] (non-standard) - AIP|1
SIU_S12 (end)
I have missing NTE2 between ZPD and LAN that I have to have in the message it was pushed after the RESOURCES. Please help.
Facing the same issue. The "Z" segments are added to the segment above the first "Z" segment. Anyone figured out how to solve this?
I use the hapi-Version 2.3. I try to access a non standard segment over the described steps in https://hapifhir.github.io/hapi-hl7v2/devbyexample.html especially from https://hapifhir.github.io/hapi-hl7v2/xref/ca/uhn/hl7v2/examples/CustomModelClasses.html Segment zpiGenericSegment = (Segment) message.get("ZBE"); // here I got ca.uhn.hl7v2.HL7Exception: ZBE does not exist in the group ca.uhn.hl7v2.model.v25.message.ADT_A01
With a local single java main program it works fine, but in the context of the jboss application server I got this error...
When I add before message.addNonstandardSegment("ZBE"); I got no exception, but the field content is always null. String firstPetName = zpiGenericSegment.getField(1, 0).encode(); [[Varies[]], [], [], [Varies[]], null, null, null, null, null, null]
But, when I use the terser to retrieve the content, String content = terser.get("/.ZBE-1-1"); ... that works. What is wrong here?