How can I use a table to control if code is executed?

0 votes
asked Aug 25, 2016 by brandon-w-8204 (31,870 points)

1.       I have built a cross reference table with a list of orders and cpt codes that require special handling.

2.       If the OBR 4.1 cpt code matches the cross reference table, then all “previous” DG1 lines (prior to the OBR line) need removed, but the DG1 line after the OBR line needs to remain.

3.       If the OBR 4.1 cpt code does not match the cross reference table, then the message is to remain as is and process normally.

1 Answer

0 votes

You can do this with the following table and mapping.

1. Table setup

2. Mapping code

// Get all the nodes including segments that go with the DG1
var dg1Groups = message.getAllNodes('DG1[group=!DG1]');
//Cycle each group to see if the other dg1 groups need to be removed
for (var i = 0; i < dg1Groups.length; i++) {
   //Parse the group from a string to a hl7 message object
   var dg1Group = qie.parseHL7String(dg1Groups[i]);
   //Check if the code should be alone in the message.
   var specialProcess = qie.doTableLookup(dg1Group.getNode('DG1-3.1'), 'N', 'dg1Codes', 'Code', 'Special Process');
   if (StringUtils.equalsIgnoreCase('Y', specialProcess)) {
      // if it is special then remove all but that dg1 group
      message.addChild('/', 'DG1', dg1Group);
      // since we found one we break the for loop to stop processing all othe DG1
answered Aug 25, 2016 by brandon-w-8204 (31,870 points)