message.checkNodeIsBlank¶
Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.checkNodeIsBlank.
Signature: message.checkNodeIsBlank(nodePath, instance*, repetition*)
Returns: Boolean isBlank - true if the node is not found, null, empty or whitespace
Checks if a node that matches the nodePath exists and is whitespace, empty ('') or null.
Note
This method will check if the node exists. If the node does NOT exist it will return true. If the node does exist it will check its value. Returns true if 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 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
// Example: Check whether a node exists and is blank (null, empty, or whitespace).
// assumes `message` is an HL7 message model object, like:
// MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|202311071015||ADT^A01|1234|P|2.5
// PID|1||123456^^^&1.2.3.4&ISO||Doe^John||19700101|M|||123 Main St^^Metropolis^NY^54321||(123)456-7890
// Check if a node is blank (any instance)
if (message.checkNodeIsBlank("PID-4")) {
// No alternate patient identifier was supplied.
}
// Check if a specific instance is blank
if (message.checkNodeIsBlank(
"PID-12", // node path
1 // instance
)) {
// The first PID segment carries no county code.
}
json
// Example: Check whether a node exists and is blank (null, empty, or whitespace).
// Sample JSON message structure
message = qie.createJSONMessage(`{"people":[
{"name":"David","favoriteFood":""},
{"name":"Nate","favoriteFood":"Lasagna"}
]}`);
if (message.checkNodeIsBlank('/people/[name=David]/favoriteFood')) {
// David supplied no favorite food.
}
xml
// Example: Check whether a node exists and is blank (null, empty, or whitespace).
// Sample XML message structure
message = qie.createXMLMessage(
'<patient>' +
'<name>Jane Doe</name>' +
'<spouseName></spouseName>' +
'</patient>'
);
if (message.checkNodeIsBlank('/patient/spouseName')) {
// The spouse name element is present but empty.
}