Sidebar

How do you handle NTE's that are in multiple OBR groups?

0 votes
257 views
asked Mar 18, 2020 by saisharan-m-4614 (180 points)
edited Mar 18, 2020 by brandon-w-8204
I need to move the NTE-3 values to the respective OBR-4.2 values.

Example segments:
OBR|1|||L|||1||||||l|||||||||||
NTE|1||||||||||||||||||||||||||||||
NTE|2|||||||||||||||||||||||||||||||
NTE|3||||||||||||||||||||||||||||||||||
OBR |1||||||||||||||||||||||||||||||||||||||||||||||
NTE|2|||||||||||||||||||||||||||||||
NTE|3||||||||||||||||||||||||||||||||||

1 Answer

0 votes

Here is the code with comments on how to handle this:

//get OBR count
var obrCount = message.getCount('OBR');

//loop through each obr group
for (var obrGroup = 1; obrGroup <= obrCount; obrGroup++) {
   //get NTE count for the OBR group
   var nteCount = message.getCount('OBR[' + obrGroup + ']/NTE');
   //Variable to store the NTE-3 values
   var nteValues = '';
   for (var nte = 1; nte <= nteCount; nte++) {
      //Combine the NTE-3 values
      nteValues += message.getNode('OBR[' + obrGroup + ']/NTE[' + nte + ']-3') + ',';
   }
   //remove last , that is not needed
   nteValues = StringUtils.substringBeforeLast(nteValues, ',');
   qie.debug('nteValues: ' + nteValues);
   //set the OBR-4.2 with the combined nte values
   message.setNode('OBR[' + obrGroup + ']-4.2', nteValues);
}

answered Mar 18, 2020 by brandon-w-8204 (33,270 points)
edited Mar 18, 2020 by brandon-w-8204
...