The code below will loop through all the AL1 segments and if AL1-5 is blank it will grab the corisponding ZAL-7[2].1.1 to put in the AL1-5. Then it will delete the ZAL segment that is associated with the AL1 that was just updated.
var al1Groups = source.getAllNodes('AL1[group=!AL1]');
for (var i = 0; i < al1Groups.length; i++) {
var al1Group = qie.parseHL7String(al1Groups[i]);
var al1 = qie.parseHL7String(al1Group.getNode('AL1'));
var zal = qie.parseHL7String(al1Group.getNode('ZAL'));
if (StringUtils.isBlank(al1.getNode('AL1-5'))) {
message.setNode('AL1-5',zal.getNode('ZAL-7[2].1.1'),(i+1));
message.removeAllNodes('AL1['+(i+1)+';group=!AL1]/ZAL');
}
}