1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
437 views
by brandon-w-8204 (34.1k points)

1 Answer

0 votes

I have this in PID-3: 

1235-1232544^^^GEHC^AN~123^^^GEHC^MR~888-88-8888^^^GEHC^SS~1233-1231331^^^GEHC^PI

Use the the following code:

var pid3Count = StringUtils.splitByWholeSeparator(message.getNode('PID-3'), '~').length;
for (var i = pid3Count; i > 0; i--) {
   var pid3 = message.getNode('PID-3[' + i + ']');
   if (StringUtils.endsWithIgnoreCase(pid3, 'MR')) {
      message.removeFirstNode('PID-3[' + i + ']');
      
   }
}
message.setNode('PID-3', StringUtils.replace(message.getNode('PID-3'), '~~', '~'));

This is the result:

1235-1232544^^^GEHC^AN~888-88-8888^^^GEHC^SS~1233-1231331^^^GEHC^PI

by brandon-w-8204 (34.1k points)
...