Sidebar

How can I select a specific value within a repeating subfield?

0 votes
409 views
asked Jul 24, 2015 by gary-t-8719 (14,860 points)
edited Jul 24, 2015 by gary-t-8719
When an HL7 field repeats such as in PID-3 (patients id), or PV1-9 (providers) how can I select a specific patient id or provider when I don't always know what order the value I want will be in?

1 Answer

0 votes

Here is one example where we are looking for the patient id identified as NHS in PID-3.4.

 

For this example we will look at a PID-3 segment taht looks like the following:

PID|1||670^^^XYZ^AN~MR-000-090^^^NHS^MR~753745187^^^ABC^SS|

Code Sample:

var i = 1;
 
while (StringUtils.isNotBlank(source.getNode('PID-3['+ i+']'))) {
   if (StringUtils.equals('NHS', source.getNode('PID-3['+ i +'].4'))) {
      message.setNode('PID-3', source.getNode('PID-3['+ i +']'));
      break;
   }
   i++;
}
 
 

 

 

answered Jul 31, 2015 by gary-t-8719 (14,860 points)
...