Question
· Aug 31, 2023

How to Search If OBX 5 contains a certain value in consecutive OBXs in BPL

I need to search for the following values "SEDATION:  " and "Procedure" In consecutive OBX 5 as seen below. Note that sometimes the OBX 5 containing "Procedure" may be followed by other characters/text hence I am leaning towards using a contains statement. 

OBX|028|TX|OP^Operative Note^D4D^11504-8^Surgical operation note^XXX||SEDATION:  ||||||C|
OBX|029|TX|OP^Operative Note^D4D^11504-8^Surgical operation note^XXX||Procedure:

Only when they appear consecutively do I want to process the message as an ORU using the BPL. Not sure how to go about it and would appreciate any assistance. Thanks 

Product version: IRIS 2021.2
Discussion (8)2
Log in or sign up to continue

No problem @Christine Nyamu ! Take a look to this code:

 Set context.matchFound = 0
 // Get count of OBR segments
 Set tOBXCnt = request.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp(*)")

 // Loop through OBXs and evaluate field contents
 For tIter = 1:1:tOBXCnt
 {
   set nextIter = tIter+1
   if tIter < tOBXCnt
   {  
     If ((request.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp("_tIter_").OBX:ObservationValue")["SEDATION:") &&
       (request.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp("_nextIter_").OBX:ObservationValue")["Procedure"))
     {
       Set context.matchFound = 1
     }
   }
   
 }

This code will check the OBX segments and check a variable to 1 in case that "SEDATION" and "Procedure:" are in consecutive segments.

You can add that code in an Activity of your BPL and check the matchFound variable.

Hi @Luis Angel Pérez Ramos 
Thank you, the code worked perfectly in the BPL. How can I change it to work in the DTL?

I need to search for the following values "SEDATION:  " and "Procedure" In consecutive OBX 5 and if true set OBR 4.1 = "28014-9"

OBX|028|TX|OP^Operative Note^D4D^11504-8^Surgical operation note^XXX||SEDATION:  ||||||C|
OBX|029|TX|OP^Operative Note^D4D^11504-8^Surgical operation note^XXX||Procedure:

That's easy! You only need to add in your DTL an action with the following code:

 Set matchFound = 0
 // Get count of OBR segments
 Set tOBXCnt = source.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp(*)")

 // Loop through OBXs and evaluate field contents
 For tIter = 1:1:tOBXCnt
 {
   set nextIter = tIter+1
   if tIter < tOBXCnt
   {  
     If ((source.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp("_tIter_").OBX:ObservationValue")["SEDATION:") &&
       (source.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp("_nextIter_").OBX:ObservationValue")["Procedure"))
     {
       Set matchFound = 1
     }
   }
   
 }
 if (matchFound = 1)
 {
  do target.SetValueAt("28014-9","PIDgrpgrp(1).ORCgrp(1).OBR:UniversalServiceID.identifier")
 }

As you can see, we keep the seach of the "SEDATION:" and "Procedure" strings and after that, if we find it in our source message, we just update the value of the specific field in the target.