message.checkNodeIsNotBlank¶
Use when: You want to read values from the modified message during mapping. If you need the original incoming message, use source.checkNodeIsNotBlank.
Signature: message.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 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 not blank (not 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 exists and has a value (any instance)
if (message.checkNodeIsNotBlank("PID-3")) {
// The patient identifier was supplied.
}
// Check if a specific instance exists and has a value
if (message.checkNodeIsNotBlank(
"PID-13", // node path
1 // instance
)) {
// 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 message structure
message = qie.createJSONMessage(`{"people":[
{"name":"David","favoriteFood":"Crêpes Suzette"},
{"name":"Nate","favoriteFood":"Lasagna"}
]}`);
if (message.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
message = qie.createXMLMessage(
'<patient>' +
'<name>Jane Doe</name>' +
'<spouseName>John Doe</spouseName>' +
'</patient>'
);
if (message.checkNodeIsNotBlank('/patient/spouseName')) {
// The spouse name was supplied.
}