Sidebar

How can I remove the MR patient identifier from the PID-3 segment.

0 votes
319 views
asked Jan 31, 2017 by brandon-w-8204 (33,270 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

answered Jan 31, 2017 by brandon-w-8204 (33,270 points)
...