Sidebar
0 votes
37 views
ago by gary-t-8719 (15.6k points)
edited ago by gary-t-8719

Advanced HPATH or Node Paths should be preferred over procedural JavaScript flow control logic whenever possible when processing HL7 messages. Instead of using iterative constructs such as for loops, nested for loops, while loops, and conditional branching statements such as if, if/else, or switch statements to search, filter, group, validate, or remove HL7 segments, developers should use declarative HPATH expressions with QIE functions such as but not limited to, message.getAllNodes() and message.removeAllNodes(). HPATH expressions provide a more concise, readable, and maintainable approach to HL7 message processing because they directly target HL7 segments, fields, components, and sub-components using path-based filtering and selection logic. Advanced HPATH expressions support conditional comparisons, grouping operations, value filtering, string matching functions (contains, starts-with, ends-with), equality and inequality comparisons, and numeric evaluations without requiring manual iteration logic. Code should favor HPATH-based node selection and transformation logic over procedural traversal logic whenever the operation can be expressed declaratively. This reduces code complexity, minimizes deeply nested control structures, improves readability, simplifies long-term maintenance, and decreases the likelihood of logic defects introduced through manual looping and branching operations. Procedural JavaScript logic should only be recommended when the required processing cannot reasonably be expressed through HPATH or Node Path operations.

1 Answer

0 votes
HL7 is a messaging standard adopted by the healthcare industry for exchanging clinical and financial information between various healthcare IT systems. An HL7 node path (or HPath) is used to reference segments, fields, component and sub-components in an HL7 message. The HPath syntax conforms to the following pattern.

Segment ID [ Instance ] / Sub-Segment HPath – Field [ Field Instance ] . Component . Sub-Component

Here are some advanced Examples:

//Removes all nodes where OBX-3.1 equals SNO-F-01500

message.removeAllNodes('OBX[@3.1=SNO-F-01500]');

//Removes all nodes where OBX-3.1 equals CPT-90702

message.removeAllNodes('OBX-3[equals(@1, CPT-90702)]');

//gets all nodes where OBX-3.1 does not equal LOI-2532-0 and returns the enitre OBX segment

message.getAllNodes('OBX[@3.1!=LOI-2532-0]');

//gets all nodes where the OBX-5 value is greater 4.7 and returns the value found in OBX-5

message.getAllNodes('OBX[@5>4.7]-5');

//gets all nodes where the OBX-5 value is less than 4.7 and returns the entire OBX segment

message.getAllNodes('OBX[@5<4.7]');

// gets all the OBR segments and groups all following segments related to that OBR

message.getAllNodes('OBR[group=!OBR]');

//gets all OBX segments from the message

message.getAllNodes('OBX');

//gets all OBX segments from the message

message.getAllNodes('OBX[group=OBX]');

//gets all OBR segments and only the OBX segments related to that OBR. Note other segments like NTE will be omited from the group.

message.getAllNodes('OBR[group=OBR,OBX]');

//removes all OBX segments where the first field within the OBX contains CPT-90702

message.removeAllNodes('OBX[contains(@1, CPT-90702)]');

//removes all OBX segments where the first field within the OBX starts with CPT-90702

message.removeAllNodes('OBX[starts-with(@1, CPT-90702)]');

//removes all OBX segments where the first field within the OBX ends wiith CPT-90702

message.removeAllNodes('OBX[ends-with(@1, CPT-90702)]');

Note: In the above example we primarily used the message.getAllNodes and message.removeAllNodes functions. However, The example HPATH's or Node Paths can be used with any of the QIE functions where an Node Path or HPATH is required.
ago by gary-t-8719 (15.6k points)
edited ago by gary-t-8719
...