message.getAllNodes¶
Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.getAllNodes.
Signature: message.getAllNodes(nodePath)
Returns: String[] matchingNodes - an array of values for all nodes that match the nodePath
Get the array of values for all nodes that match the nodePath.
Note
This method only applies to the following formatted messages: HL7, ASTM, CSV, DICOM, EDIFACT, Old Fxd Width, Fxd Length, ISO 8583, JSON, Text, X12, XML.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | nodePath | the node path (XPath, HPath, Column ID, etc.) |
Examples¶
hl7
// assumes `message` is an HL7 message model object, like:
// MSH|^~\&|LAB|HOSPITAL|EHR|HOSPITAL|20260317103000||ORU^R01|MSG00001|P|2.5
// PID|1||123456^^^HOSPITAL^MR||Doe^John||19800101|M
// PV1|1|O|OPD^^^HOSPITAL
// OBR|1||ORDER123|88304^Lab Panel^L
// OBX|1|NM|GLU^Glucose^L||105|mg/dL|70-110|N|||F
// OBX|2|NM|WBC^White Blood Cell Count^L||7.2|10*3/uL|4.0-11.0|N|||F
// OBX|3|ST|COVID^COVID Result^L||Negative|||N|||F
// Get all OBX-5 values (observation values)
var allObservations = message.getAllNodes('OBX-5'); // ['105', '7.2', 'Negative']
json
// Given a JSON message like:
message = qie.createJSONMessage(
'{' +
'"patient": {' +
'"id": "123456",' +
'"name": "John Doe"' +
'},' +
'"observations": [' +
'{ "code": "GLU", "value": 105 },' +
'{ "code": "WBC", "value": 7.2 },' +
'{ "code": "COVID", "value": "Negative" }' +
']' +
'}'
);
// Get all observation values
var allObservationValues = message.getAllNodes('/observations/value'); // ['105', '7.2', 'Negative']
xml
// Given an XML message like:
message = qie.createXMLMessage(
`
<people>
<person>
<name>Nate</name>
<age>30</age>
</person>
<person>
<name>John</name>
<age>41</age>
</person>
<person>
<name>Jane</name>
<age>52</age>
</person>
</people>
`
);
// Retrieve all nodes that match the nodePath
var allNodes = message.getAllNodes(
"/people/person"
);
// allNodes is a java.lang.String[] (0-based), containing the serialized XML for each matched node, returned in document order.
// allNodes[0] // <person><name>Nate</name><age>30</age></person>
// allNodes[1] // <person><name>John</name><age>41</age></person>
// allNodes[2] // <person><name>Jane</name><age>52</age></person>