Sidebar

How to remove everything from HL7 where OBX-4 is not equal to null?

0 votes
358 views
asked Mar 2, 2020 by adam-d-5091 (320 points)
Brand new to coding in Qvera so i'll apologize off the bat for bad use of terms. Just getting my grips on basic understanding of the logic so hopefully i'm asking the question right. I have a peice of code that Qvera provided us to remove OBX segments where OBX-4 equals or not equals a value for example:

message.removeAllNodes('OBX[@4=2]');
var old2 = source.getNode('OBX[@4=2]');
message.addChildAfter('PV1', 'OBX', old2);

or

message.removeAllNodes('OBX[@4!=1]');
var old2 = source.getNode('OBX[@4!=1]');
message.addChildAfter('PV1', 'OBX', old2);

I get it and understand this (mostly), but what i need is to keep the line that is null and 1 and dump everything else. So in my head something like remove all if OBX-4 isn't null or 1. So to get the null piece I tried:

message.removeAllNodes('OBX[@4!=null]');
var old2 = source.getNode('OBX[@4!=null]');
message.addChildAfter('PV1', 'OBX', old2);

This removed every line which is where I decided to come here and make my first post.

Any idea? Am I even treking down the right path.

Thanks in advance!

1 Answer

+1 vote
To find blank fields use the following hpath:

message.getNode("OBX[@3.1!='']")

The '' Specifies to look for an empty field. When you use null it is look for the string null.
answered Mar 2, 2020 by (160 points)
edited Mar 2, 2020 by brandon-w-8204
...