Login
Register
Home
Q&A
Questions
Tags
Send feedback
Sidebar
In PV1-3 there are multiple occurances such as 4 for example. How can I just pull out 2 of the 4.
0
votes
257
views
asked
Sep 9, 2020
by
douglas-l-4571
(
190
points)
Example: PID|1||2200216279^^^0^UI~1005274^^^2^CMRN~916759^^^1^HMRN~1003277^^^3^AMRN||INTERFACE^TEST1^^^^||. How can I just pass the 2200216279^^^0^UI~916759^^^1^HMRN to the receiving system. I can pass 1 occurance but not 2.
-
Please
log in
or
register
to add a comment.
Please
log in
or
register
to answer this question.
1 Answer
0
votes
You can reference each patient ID by the instance if they will always be the first and third.
message.setNode('PID-3', source.getNode('PID-3[1]') + '~' + source.getNode('PID-3[3]'));
answered
Sep 9, 2020
by
michael-h-5027
(
14,030
points)
commented
Sep 9, 2020
by
douglas-l-4571
(
190
points)
No, they will not always be the same instance. Here is the code I used to pull out 1 instance
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, 'UI')) {
message.setNode('PID-3', source.getNode('PID-3['+ i +']'));
break;
} else {
message.removeLastNode('PID-3[' + i + ']');
}
}
commented
Sep 9, 2020
by
michael-h-5027
(
14,030
points)
var pid3Count = StringUtils.splitByWholeSeparator(message.getNode('PID-3'), '~').length;
var newPid3;
var foundPid3 = false;
for (var i = pid3Count; i > 0; i--) {
var pid3 = message.getNode('PID-3[' + i + ']');
if (StringUtils.endsWithIgnoreCase(pid3, 'UI')) {
if (foundPid3) {
newPid3 = newPid3 + '~' + source.getNode('PID-3['+ i +']');
} else {
newPid3 = source.getNode('PID-3['+ i +']');
foundPid3 = true;
}
}
if (StringUtils.endsWithIgnoreCase(pid3, 'HMRN')) {
if (foundPid3) {
newPid3 = newPid3 + '~' + source.getNode('PID-3['+ i +']');
} else {
newPid3 = source.getNode('PID-3['+ i +']');
foundPid3 = true;
}
}
}
message.setNode('PID-3', newPid3);
commented
Sep 9, 2020
by
douglas-l-4571
(
190
points)
Works perfectly! Thank you,
Doug
Please
log in
or
register
to add a comment.
...