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