Segment Appears More Times Than Allowed
The message structure caps how many times a segment may repeat. The message contains more occurrences than that maximum.
HL7v2 · Error
The error
Segment appears more times than the maximum repeat allowsWhy it happens
Merging multiple messages into one, duplicating a segment instead of using a repeating group, or placing a segment outside the repeating group that was meant to contain it.
How to fix it
Remove the extra occurrences, or restructure so the repeats live inside the group designed to repeat. Check whether the data really belongs in separate messages.
Example
The snippet below triggers the error:
MSH|^~\&|S|S|R|R|20240115||ADT^A01|M1|P|2.5
PID|1||A^^^H^MR||DOE^JOHN
PID|2||B^^^H^MR||ROE^JANEThe corrected version:
MSH|^~\&|S|S|R|R|20240115||ADT^A01|M1|P|2.5
PID|1||A^^^H^MR||DOE^JOHNFrequently asked questions
Some segments repeat freely, why not this one?
Maximum repeats are defined per segment within each message structure. OBX inside an order may repeat many times, while PID in an ADT message is typically singular. The validator uses the structure for your message type and version.
Related
- Open the HL7v2 Validator
- All validation errors
- Message Does Not Begin With an MSH Segment
- MSH-1 Field Separator Must Be Exactly One Character
- MSH-2 Encoding Characters Must Be Exactly 4 Characters
- Delimiter Characters Are Not Unique
- Required Segment Is Missing
- Required Field Is Missing or Empty
- Segment Is Not Defined in This HL7v2 Version
- Invalid Message Type and Trigger Event Combination