1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
2.0K views
by (290 points)
Some messages have multiple OBR segments with missing OBX children. They have an NTE, but no OBX. I need to search the message for all OBR that don't have an OBX and add it. I also need to take any NTE segments in the OBR and put NTE-3 in OBX-5. The OBX segment can go at the end of the OBR after the NTE if it exists.
by (290 points)
Thanks for the answer. The key important thing I missed was to parse the obrGroup as an HL7.

1 Answer

+1 vote
 
Best answer

Here is a script to add OBX segments if they do not exist in the OBR group:

//Get all OBR groups
var obrGroups = message.getAllNodes('OBR[group=!OBR]');
 
//Loop through each group
for (var i = 0; i < obrGroups.length; i++) {
   //Parse the string as hl7 to allow lookup.
   var obrGroup = qie.parseHL7String(obrGroups[i]);
   
   //Check if an OBX segment exists.
   if (!obrGroup.checkNodeExists('OBX')) {
      //Get the NTE-3 node to use in the OBX-3
      var obx5 = obrGroup.getNode('NTE-3');
      //Add the OBX segment after the NTE segement.
      message.addChildAfter('NTE[@3=' + obx5 + ']', 'OBX', 'OBX|1||||' + obx5);
   }
}
by brandon-w-8204 (34.1k points)
by (290 points)
Thanks for the answer. The key important thing I missed was to parse the obrGroup as an HL7.
...