Sidebar

Can I remove a group of IN1/IN2/ZIN that has a field that is not blank in a message with multiple groups?

0 votes
511 views
asked Oct 5, 2018 by risa-p-1914 (310 points)
I have multiple groups IN1 segments with IN2 and ZIN segments following.Some insurances have expired in IN1-13. Others are still active. I need to completely remove the entire group IN1, IN2 and ZIN segmement if there is a value in IN1-13.

Some could be expired while others are still active.

IN1|1|505|BLU3|BLUE CROSS BLUE SHIELD OF UTAH|PO BOX 1106^^LEWISTON^ ID^83501||(877)417-6222|||||20180831||||ALLSCRIPTS^ELEPHANT^^^^|SE|19800101|1055 N 500 W^^NOWHEREVILLE^UT^84508|||||||||||||||||789789789789|||||||F|
IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZIN||||||||||||||||||||||||||||
IN1|2|508|AET4|AETNA GLOBAL BENEFITS|PO BOX 981543^^EL PASO^ TX^79995||(800)231-7729|||||20180901|20181005|||ALLSCRIPTS^ELEPHANT^^^^|SE|19800101|1055 N 500 W^^NOWHEREVILLE^UT^84508|||||||||||||||||456456456456654|||||||F|
IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZIN||||||||||||||||||||||||||||
IN1|3|510|UMR3|UMR PO BOX 30541|PO BOX 30541^^SALT LAKE CITY^ UT^84130||(800)772-9641|||||20180901||||ALLSCRIPTS^ELEPHANT^^^^|SE|19800101|1055 N 500 W^^NOWHEREVILLE^UT^84508|||||||||||||||||123123123123213|||||||F|
IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZIN||||||||||||||||||||||||||||
IN1|4|483|BYU1|BYU SPORTS MEDICINE|1130 SMITHFIELD HOUSE^^PROVO^ UT^84602||(801)422-2946|||||20180901||||ALLSCRIPTS^ELEPHANT^^^^|SE|19800101|1055 N 500 W^^NOWHEREVILLE^UT^84508|||||||||||||||||3693369369369|||||||F|
IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZIN||||||||||||||||||||||||||||
IN1|5|231|CIG7|CIGNA HEALTH|PO BOX 182223^^CHATTANOOGA^ TN^37422||(800)395-8712|||||20180901||||ALLSCRIPTS^ELEPHANT^^^^|SE|19800101|1055 N 500 W^^NOWHEREVILLE^UT^84508|||||||||||||||||456123456132456123|||||||F|
IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ZIN||||||||||||||||||||||||||||
I would expect that the 2nd IN1/IN2/Zin group would be removed due to the expiration date being in IN1-13.

I tried the syntax  from the KB article: message.removeAllNodes('OBR[group=!OBR;/OBX-5=*]'); but tried to change it to message.removeAllNodes('IN1[group=!IN1;/IN1-15!=""]'); but it removes all IN1/IN2/ZIN segments instead of the indivdial ones I want to remove. I found I couldn't use the function StringUtils.isNotBlank either in that syntax.

I essentially want to do the same thing in the KB article, but want to remove anything that has IN1-13 that is not blank.

1 Answer

0 votes

You can approach this in several ways. Since I'm not 100% certain that there will always be an IN2 or ZIN segment the approach below gets rid of all of the IN1 groups and then only adds back the ones that do not have a date in IN1-13.

 

// Gather all of the segments before the first IN1 segment
var messageBeforeIN1 = source.getNode('MSH[group=!IN1]');

var in1NewGroup = '';

// create an array of IN1 groups
var in1Groups = source.getAllNodes('IN1[group=!IN1]');
for (var i=0 ; i < in1Groups.length ; i++) {
   // create a variable of the specifi instance of IN1 group that we are going to analyze
   var in1Segments = qie.parseHL7String(in1Groups[i]);
   
   // if the date in IN1-13 is empty then we can add this group back to our message
   if (StringUtils.isEmpty(in1Segments.getNode('IN1-13'))) {
      in1NewGroup = in1NewGroup + in1Segments.getNode('/') + '\r';
   }
}

// Replace the entire message with our new composed message of just the IN1 groups that have no date
message.setNode('/', messageBeforeIN1 + in1NewGroup);
 

answered Oct 5, 2018 by michael-h-5027 (14,390 points)
...