Skip to content

source.getAllNodes

Use when: You want to read values from the original incoming message before any mapping changes. If you need the modified message during mapping, use message.getAllNodes.

Signature: source.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, 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

/* Given a HL7 source:
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 = source.getAllNodes('OBX-5'); // ['105', '7.2', 'Negative']

json

/* Given a JSON source:
{
    "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 = source.getAllNodes('/observations/value'); // [105, 7.2, "Negative"]

xml

// Example: Retrieve all nodes that match a given node path.

/* source:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
   <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>
*/

// Get all matching nodes
var people = source.getAllNodes(
   "/people/person" // node path
);

// people is a String[] (0-based)
var count = people.length;      // 3
var secondPerson = people[1];   // "<person><name>John</name><age>41</age></person>"