Sidebar

AL1 segment followed by a Z segment

0 votes
197 views
asked Jun 17, 2022 by surya-p-7473 (200 points)
edited Jun 21, 2022 by amanda-w-3695
We are dealing with a AL1 segment followed by a ZAL segment(a 'Z' segment). The requirement has 2 parts. If Al1-5 is empty move ZAL7.2.1 to AL1-5 and then remove the corresponding ZAL segments that follow the AL1 segments after moving the value from ZAL7.2.1 to AL1-5.

I am clear about the logic for moving the value from ZAL7.2.1 to AL1-5(if this is empty) but stuck at removing the corresponding ZAL segment.

1 Answer

0 votes

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

answered Jun 21, 2022 by amanda-w-3695 (4,840 points)
...