Sidebar

Syntax for discarding all messages that do not match what is in a table.

0 votes
377 views
asked Jul 22, 2016 by (120 points)
edited Jul 22, 2016 by
I am looking for the Condition syntax needed to discard all messages coming into a channel that have items in a Node (OBX-3.2) that do not match what is assigned in column 1 of the table.

1 Answer

0 votes

This example code, used in a Condition Node will discard the message if the OBX-3.2 value is NOT found in Column1 of myTable. 

//Gather all of the OBX segments.
var obxSegs = source.getAllNodes('OBX');
//Assume that the value is in the table.
var existsInTable = true;
//Loop through all segments and look for the value in the table.
for (var i=0 ; i < obxSegs.length ; i++) {
//If the value isn't in the table, no need to continue. Break out of the loop. 
 if (existsInTable === false){
      break;
   }
   var obxSeg = qie.parseHL7String(obxSegs[i]);
   var obx32 = obxSeg.getNode('OBX-3.2');
   var result = qie.doTableLookup(obx32, 'Discard', 'myTable ', 'Column1', 'Column2');
//If the value is in the table, continue with the next segment.
   if(StringUtils.equalsIgnoreCase(result, 'Discard')){
//If the value isn't in the table,existsInTable = false
      existsInTable = false;
   }
}
return existsInTable;
_________________________________________________________________
 
This code can be used in a Mapping Node to accomplish the same thing.
 
//Gather all of the OBX segments.
var obxSegs = source.getAllNodes('OBX);
//Loop through all segments and look for the value in the table.
for (var i=0 ; i < obxSegs.length ; i++) {
   var obxSeg = qie.parseHL7String(obxSegs[i]);
   var obx32 = obxSeg.getNode('OBX-3.2');
   var result = qie.doTableLookup(obx32, 'Discard', 'myTable', 'Column1', 'Column2');
//If the value is in the table, continue with the next segment.
   if (StringUtils.equalsIgnoreCase(result, 'Discard')) {
//If the value is NOT in the table, discard the message.
      message.discard();
   }
}
answered Jul 23, 2016 by terrie-g-7436 (3,950 points)
commented Jul 25, 2016 by (120 points)
edited Jul 25, 2016 by
That works perfectly! Thank you!
...