source.getHL7FieldCount¶
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.getHL7FieldCount.
Signature: source.getHL7FieldCount(nodePath, instance*)
Returns: Integer count - the count of fields in the segment for the nodePath array
Finds the count of fields in the segment that matches nodePath.
Note
This method only applies to HL7 formatted messages.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | nodePath | the node path (HPath) | |
| Integer | instance* | (optional) the segment instance to return. Use 1 for the first instance. | 1 |
Example¶
// Given an HL7 source message with a PID segment.
/* source:
'MSH|^~\\&|SendingApp|SendingFacility|ReceivingApp|ReceivingFacility|202311071230||ADT^A01|123456|P|2.3\r' +
'PID|1||123456^^^&1.2.3.4&ISO||Doe^Jane||19850515|F|||123 Elm St^^Somecity^ST^12345||(555)123-4567^PRN^PH^^^555^1234567'
*/
// Retrieve the number of fields for the PID segment.
var pidFieldCount = source.getHL7FieldCount('/PID'); // expected: 13