/*
* The OBR segment is contained within a group called ORDER_OBSERVATION,
* which is itself in a group called PATIENT_RESULT. These groups are
* reached using named accessors.
*/
ORU_R01_ORDER_OBSERVATION orderObservation = message.getPATIENT_RESULT().getORDER_OBSERVATION();
// Populate the OBR
OBR obr = orderObservation.getOBR();
obr.getSetIDOBR().setValue("1");
obr.getFillerOrderNumber().getEntityIdentifier().setValue("1234");
obr.getFillerOrderNumber().getNamespaceID().setValue("LAB");
obr.getUniversalServiceIdentifier().getIdentifier().setValue("88304");
/*
* The OBX segment is in a repeating group called OBSERVATION. You can
* use a named accessor which takes an index to access a specific
* repetition. You can ask for an index which is equal to the
* current number of repetitions,and a new repetition will be created.
*/
ORU_R01_OBSERVATION observation = orderObservation.getOBSERVATION(0);
// Populate the first OBX
OBX obx = observation.getOBX();
obx.getSetIDOBX().setValue("1");
obx.getObservationIdentifier().getIdentifier().setValue("88304");
obx.getObservationSubID().setValue("1");
// The first OBX has a value type of CE. So first, we populate OBX-2 with "CE"...
obx.getValueType().setValue("CE");
// ... then we create a CE instance to put in OBX-5.
CE ce = new CE(message);
ce.getIdentifier().setValue("T57000");
ce.getText().setValue("GALLBLADDER");
ce.getNameOfCodingSystem().setValue("SNM");
Varies value = obx.getObservationValue(0);
value.setData(ce);
// Now we populate the second OBX
obx = orderObservation.getOBSERVATION(1).getOBX();
obx.getSetIDOBX().setValue("2");
obx.getObservationSubID().setValue("1");
// The second OBX in the sample message has an extra subcomponent at
// OBX-3-1. This component is actually an ST, but the HL7 specification allows