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();
}
}