Search code examples
javaformathl7hapi

How to create a valid OBX segment in java using HAPI?


I want to generate just the OBX segment in a HL7 message in this format.

OBX|6|CE|59783-1^Status in immunization series^LN|**5**|||||||F

where no. 5 is the Series no.

problem is when ever I try to decode this line with a HL7 decoder. it results in something like this.

Vaccine funding program eligibility category
V07 - VFC Eligibility-Local-specific Eligibility
Vaccine purchased with
null -
vaccine type
107 - DTaP
Date vaccine information statement published
-
Date vaccine information statement presented
-
Status in immunization series

Here is my source code:

obx.getSetIDOBX().setValue(String.valueOf(obxSetId));
        obx.getValueType().setValue("CE");
        obx.getObservationIdentifier().getIdentifier().setValue("59783-1");
        obx.getObservationIdentifier().getText().setValue("Status in immunization series");
        obx.getObservationIdentifier().getNameOfCodingSystem().setValue("LN");
        obx.getObservationSubID().setValue(String.valueOf(immunizationData.getSeries().toString()));
        obx.getObservationResultStatus().setValue("F");

where obx is the reference to the OBX jar in hapi structures.


Solution

  • I suspect that the receiver of the message is complaining about the missing observation value (OBX.5). You specified a data type for the observation value (value type, OBX.2), but OBX.5 in your message does not contain a value of data type CE - it is empty.