obr.getFillerOrderNumber().getEntityIdentifier().setValue("1234");
obr.getFillerOrderNumber().getNamespaceID().setValue("LAB");
obr.getUniversalServiceIdentifier().getIdentifier().setValue("88304");
// Populate the first OBX
OBX obx = orderObservation.getOBSERVATION(0).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
// extra subcomponents to be tacked on to the end of a component. This is
// uncommon, but HAPI nontheless allows it.
ST observationIdentifier = obx.getObservationIdentifier().getIdentifier();
observationIdentifier.setValue("88304");
ST extraSubcomponent = new ST(message);
extraSubcomponent.setValue("MDT");
observationIdentifier.getExtraComponents().getComponent(0).setData(extraSubcomponent );
// The first OBX has a value type of TX. So first, we populate OBX-2 with "TX"...
obx.getValueType().setValue("TX");
// ... then we create a CE instance to put in OBX-5.
TX tx = new TX(message);
tx.setValue("MICROSCOPIC EXAM SHOWS HISTOLOGICALLY NORMAL GALLBLADDER TISSUE");
value = obx.getObservationValue(0);
value.setData(tx);
// Print the message (remember, the MSH segment was not fully or correctly populated)
System.out.append(new PipeParser().encode(message));