Skip to content

source.checkNodeIsNotBlank

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.checkNodeIsNotBlank.

Signature: source.checkNodeIsNotBlank(nodePath, instance*, repetition*)

Returns: Boolean isNotBlank - true if the node is found and not empty and not null and not whitespace

Checks if a node that matches the nodePath exists, is not whitespace, is not empty (''), and is not null.

Note

This method will check if the node exists. If the node does NOT exist it will return false. If the node does exist it will check its value. Returns true if NOT blank else false.

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.)
Integer instance* (optional) the instance to return: segment for HL7, ASTM, EDIFACT, or X12; row for CSV (0=header row) or fixed-length formats; or match for DICOM, JSON, or XML. Use 1 for the first instance. 1
Integer repetition* (optional) the field repeat instance for HL7 or ASTM to return. Use 1 for the first instance. 1

Examples

hl7

// Given an HL7 source message with populated PID fields.
/* source:
'MSH|^~\\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|202311071015||ADT^A01|1234|P|2.5\r' +
'PID|1||123456^^^&1.2.3.4&ISO||Doe^John||19700101|M|||123 Main St^^Metropolis^NY^54321||(123)456-7890'
*/

// Check if the patient ID (PID-3) exists and is not blank.
if (source.checkNodeIsNotBlank('PID-3')) {
    // The patient identifier was supplied.
}

// Check if the patient phone number (PID-13) exists and is not blank for the first instance (1-based).
if (source.checkNodeIsNotBlank(
        'PID-13',   // nodePath
        1           // instance (1-based)
    )) {
    // The first PID segment carries a phone number.
}

json

// Example: Check whether a node exists and is not blank (not null, empty, or whitespace).

/* Sample JSON source structure:
{"people":[
    {"name":"David","favoriteFood":"Crêpes Suzette"},
    {"name":"Nate","favoriteFood":"Lasagna"}
]}
*/

if (source.checkNodeIsNotBlank('/people/[name=David]/favoriteFood')) {
    // David supplied a favorite food.
}

xml

// Example: Check whether a node exists and is not blank (not null, empty, or whitespace).

/* Sample XML message structure:
<patient>
   <name>Jane Doe</name>
   <spouseName>John Doe</spouseName>
</patient>
*/

if (source.checkNodeIsNotBlank('/patient/spouseName')) {
    // The spouse name was supplied.
}