Here is some additional info that might help. I found that with the solutions
provided here that I had to have the appropriate message version import
(i.e. ca.uhn.hl7v2.model.v22.segment.OBX) which was a problem since I use
many versions of HL7 messages. So it works best for me to use the terser to
get and set values. To handle multiple OBX segments I used the following.
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
nksharma0624 wrote:
>
> To find the repeating OBX segment..Here is the code snippet:
>
> To get at the OBX:
>
> ORU_R01 ORU_R01Message = (ORU_R01) theMessage;
>
> for (int PATIENT_RESULTRep = 0;
> PATIENT_RESULTRep<ORU_R01Message.getPATIENT_RESULTReps();
> PATIENT_RESULTRep++) {
>
> for (int ORDER_OBSERVATIONRep = 0;
> ORDER_OBSERVATIONRep<ORU_R01Message.getPATIENT_RESULT(PATIENT_RESULTRep)
> .getORDER_OBSERVATIONReps(); ORDER_OBSERVATIONRep++) {
>
> for (int OBSERVATIONRep = 0;
> OBSERVATIONRep<ORU_R01Message.getPATIENT_RESULT(PATIENT_RESULTRep).getOR
> DER_OBSERVATION(ORDER_OBSERVATIONRep).getOBSERVATIONReps();
> OBSERVATIONRep++) {
>
> String[] OBX3Value=
> TerserUtil.getOBX3(localTerser, PATIENT_RESULTRep, ORDER_OBSERVATIONRep,
> OBSERVATIONRep);
>
> }
> }
> }
>
> To get the Values of OBX:
> public static String[] getOBX3(Terser localTerser, int
> PATIENT_RESULTRep, int ORDER_OBSERVATIONRep, int OBSERVATIONRep) throws
> HL7Exception {
>
> String [] OBX3 = new String[6];
> String terserPath = "PATIENT_RESULT(" + PATIENT_RESULTRep +
> ")/ORDER_OBSERVATION(" + ORDER_OBSERVATIONRep + ")/OBSERVATION(" +
> OBSERVATIONRep + ")/OBX-";
> OBX3[0] = localTerser.get(terserPath + "3(0)-1-1");
> OBX3[1] = localTerser.get(terserPath + "3(0)-2-1");
> OBX3[2] = localTerser.get(terserPath + "3(0)-3-1");
> OBX3[3] = localTerser.get(terserPath + "3(0)-4-1");
> OBX3[4] = localTerser.get(terserPath + "3(0)-5-1");
> OBX3[5] = localTerser.get(terserPath + "3(0)-6-1");
> return OBX3;
>
> }
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Hl7api-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/hl7api-devel
>
>
--
View this message in context:
http://old.nabble.com/How-to-find-Repeating-Segments-tp24700999p34049368.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
[email protected]
https://lists.sourceforge.net/lists/listinfo/hl7api-devel