So I was working off this link:
https://www.qvera.com/kb/index.php/768/how-do-i-properly-remove-segments-using-a-for-loop
The problem I'm running into is if I have a situation like this in my HL7 message:
OBX|1||TEST|1|NAME: DOE, JOHN DATE OF EXAM: 10-31-2020
OBX|1||TEST|2|DATE OF BIRTH: 08-12-1951 CHART #: 123456-AA
OBX|1||TEST|3|PHYSICIAN: Dr. Feelgood, M.D.
OBX|1||TEST|4|This is the part of the report I want to keep now.
Code:
var obx5 = message.getAllNodes('OBX-5');
for (var j= 0; j < obx5.length; j++) {
if (StringUtils.starsWithIgnoreCase(obx5[j],'NAME: ')) {
message.removeAllNodes('OBX[@5=' + obx5[j] + ']');
}
}
Also IF statements for 'DATE OF EXAM:' , 'PHYSICIAN' etc.
What I"m finding is that this will match if it's the ONLY thing in OBX-5, but if there is information afterwards it's not matching. Is there a better way to match what the line starts with, or wildcard for a phrase in the line?