Skip to content

source.getASTMRepetitionCount

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

Signature: source.getASTMRepetitionCount(nodePath, instance*)

Returns: Integer count - the count of repetitions in the field for the nodePath array

Finds the count of repetitions in the field that matches nodePath.

Note

This method only applies to ASTM 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 ASTM source message with repeating values in P-6.
/* source:
'H|^~\\&|95243|HAMMO001|COMMUNITY AND FAMILY MEDICINE|BOX 2914^DUKE UNIVERSITY MEDICAL CENTER^DURHAM^NC|919-684-6721|||\r' +
'P|1|999-99-9999|||GUNCH^MODINE^SUE|00279~1&2&3&4^00998~2&3&4&5^00998~3&4&5&6|19430704|F|RT 1, BOX 97^ZIRCONIA^NC^27401||704-982-1234||DOCTOR^PRIMARY^A^^DR. '
*/

// Retrieve the number of repetitions for the P-6 field.
var pRepetitionCount = source.getASTMRepetitionCount('/P-6'); // expected: 4