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