I figured out how to get and set multiple OBX segments using terser. hapiMsg = p.parse(sourceMessage); Terser terser = new Terser(hapiMsg); terser.get("/.OBSERVATION(2)/.OBX-2-1"); terser.set("/.OBSERVATION(2)/.OBX-2-1", "CE");
This is equivelent to: OBX obx = message.getPATIENT_RESULT().getORDER_OBSERVATION().getOBSERVATION(2).getOBX(); obx.getValueType().setValue("CE"); My objective was to take an existing message and update any of the values. With this code I updated the 2nd field in the 3rd OBX segment from "NM" to "CE" as seen in the message below MSH|^~\&|OADD|${FACILITY}|HELIX||201012010910||ORU^R01|20101720000042|T|2.2 PID|||PX65^^^MRENTR||Mayer^Ronny PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840 OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM) OBX|2|NM|K^Potassium^0|1.1|4.5|mmol/L|3.5-5.0||||F|||201012010905|IM^|8035^COX^CATHERINE (IM) OBX|3|CE|CL^Chloride^0|1.1|100|mmol/L|98-109||||F|||201012010905|IM^|8035^COX^CATHERINE(IM) tcervantez I am having the similar problem... I have tried all and nothing works... I have tried the code segment like below: Terser t = new Terser(theMessage); String str= t.get("/PATIENT_RESULT/ORDER_OBSERVATION/OBSERVATION/OBX-3-1"); // ORU_R01 ORU_R01Message = (ORU_R01)theMessage; // for(int i=0 ; i<=ORU_R01Message.getPATIENT_RESULTReps(); i++) { // for(int j=0 ; j<=ORU_R01Message.getPATIENT_RESULT(i).getORDER_OBSERVATIONReps(); j++) { // for(int k=0 ; k<=ORU_R01Message.getPATIENT_RESULT(i).getORDER_OBSERVATION(j).getOBSERVATIONReps(); k++) { // // OBX o = ORU_R01Message.getPATIENT_RESULT(i).getORDER_OBSERVATION(j).getOBSERVATION(k).getOBX(); // logger.debug("k=" + k); // } // } // } All failed to get me access to OBX segments. Thanks. Regards -Niranjan. -- View this message in context: http://old.nabble.com/HELP-OBX-tp23198417p34049222.html Sent from the hl7api-devel mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Hl7api-devel mailing list Hl7api-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/hl7api-devel