Sidebar

Combine OBX.5 into single OBX if OBX-3 value is the same

0 votes
436 views
asked Nov 7, 2016 by ramaswamy-s-6353 (440 points)
I know a way to combine multiple OBX to a single OBX. But is there a way to combine the OBX-5 values into single OBX only if OBX3.2 value is the same?

1 Answer

0 votes

Below is code that will combine the obx-5 based on the obx-3.2 value

var obx5Values = source.getAllNodes('OBX');
message.removeAllNodes('OBX');
var newObx5Value = '';
var obx32Map = qie.newParameterMap();
 
for (var i = 0; i < obx5Values.length; i++) {
   var obxSegment = qie.parseHL7String(obx5Values[i]);
   var obx32value = obxSegment.getNode('OBX-3.2');
   var obx5Value = obxSegment.getNode('OBX-5');
   // Check if in map.
   if (obx32Map.get(obx32value) === null){
      // If not in map then add obx segment back and add to map.
      obx32Map.put(obx32value, obx5Value);
      message.addChild('/', 'OBX', obxSegment.getNode('/'));
   } else {
      // If in map then add obx-5 to current obx segment
      message.setNode('OBX[@3.2=' + obx32value + ']-5', message.getNode('OBX[@3.2=' + obx32value + ']-5') + ' ~ ' + obx5Value);
   }
}
 
answered Nov 7, 2016 by brandon-w-8204 (33,170 points)
...