Sidebar

Multiple NTE segments

0 votes
319 views
asked Jan 25, 2023 by maria-j-3133 (220 points)
retagged Jan 25, 2023 by amanda-w-3695
I'm having some issues writing this code. How can I get each segment of an existing NTE with tiles into multiple NTE segments.

 

Example: Here the input NTE

NTE|1||Indication->New LBBB post TAVR~Problems->ATRIAL FIBRILLATION, PERSISTENT, LONGSTANDING [ICD10-I48.11]~Problems->PACEMAKER  DEPENDENT [ICD10-I49.8]~Anticoagulation->Not anticoagulated.

 

I want to add a NTE for each ~

NTE|1|Indication for montoring->Palpitations

NTE|2|Problems->ATRIAL FIBRILLATION, PERSISTENT, LONGSTANDING [ICD10-I48.11]

NTE|3|Problems->PACEMAKER  DEPENDENT [ICD10-I49.8]

NTE|4|Problems->Anticoagulation->Not anticoagulated.

 

There could be multiple of each.
commented Jan 25, 2023 by maria-j-3133 (220 points)
I'm getting this error.
 WrappedException: Wrapped com.qvera.qie.web.exception.MessageModelException: Unable to set node on empty message.  Please initialize the message first.

1 Answer

0 votes

This can be accomplised by using the String.split('~') and then looping through the results. This code will take the original single NTE and replace it with multiple NTE segments.

// get NTE segment
var nte = message.getNode('NTE-3');
qie.debug('NTE-3 Value:' + nte);

// save original NTE segment
var nteSegment = qie.parseHL7String(message.getNode('NTE[1]'));

// remove original NTE segment
message.removeFirstNode('NTE');

// split the data on the tilde
var individualSegments = nte.split('~');
qie.debug('Segments Found:' + individualSegments.length);

// cycle individual segments and create new NTE segment
var segments = '';
for (var i = 0; i < individualSegments.length; i++) {
   qie.debug('Segment ' + i + ':' + individualSegments[i]);
   
   // set NTE sequence
   nteSegment.setNode('NTE-1', i+1);
   
   // set NTE value
   nteSegment.setNode('NTE-3', individualSegments[i]);
   
   qie.debug('NTE Segment ' + i + ':' + nteSegment.toString());
   segments += nteSegment.toString() + '\n';
}

// place new segments after the OBX segment of the original message
message.addChildAfter('OBX', 'NTE', segments);

answered Jan 25, 2023 by amanda-w-3695 (4,840 points)
commented Jan 25, 2023 by maria-j-3133 (220 points)
I'm getting this error.
 WrappedException: Wrapped com.qvera.qie.web.exception.MessageModelException: Unable to set node on empty message.  Please initialize the message first.
...