Reference·ERR Segment·ERR-2
HL7 v2 Reference

HL7 v2 ERR-2 (Error Location): Format, Values, and Testing Notes

Jul 28, 2026 · 4 min read
ERR-3 →

ERR-2 is the field that tells a developer exactly where to look in a rejected message instead of re-reading the whole thing line by line, and generators that leave it blank turn a precise diagnostic tool into a guessing game.

Quick answer

ERR-2 is the Error Location field. It is a composite value that names the segment ID, the segment occurrence number if the segment repeats, the field position within that segment, and optionally the component and sub-component position, so a receiving application can point directly at the offending piece of data.

What this field contains

Component 1
Segment ID — the three-letter segment code where the problem was found, e.g. PID or OBX
Component 2
Segment sequence — which occurrence of that segment in the message, important when a segment like OBX repeats many times
Component 3
Field position — the numbered field within the segment, e.g. 8 for the eighth field
Component 4
Field repetition — which repetition of the field, used when the field itself allows multiple values
Component 5
Component/sub-component — optional deeper pointer into a specific component of a composite field

Example

Synthetic example Generated by Synthibase
ERR||OBX^3^5^1|102^Data type error^HL70357|E|||Numeric observation value contains non-numeric characters

A synthetic ERR segment pointing to the third OBX occurrence, fifth field, first repetition, where a numeric value was malformed.

Where this trips people up

Teams building error-handling logic often assume ERR-2 will always resolve to a single, unambiguous segment and field, then get surprised the first time a repeating segment like OBX or DG1 is involved and the location pointer needs the occurrence number to mean anything. Test data that only ever triggers errors on non-repeating segments like PID never exercises that occurrence-counting logic, so it breaks the first time a real message with ten OBX segments fails validation on the seventh one.

HL7 v2 ERR Segment Guide: Fields, Format, and Testing Gotchas
EDI 999 vs 997: What's the Difference and Why It Matters
EDI Rejection Codes: Complete List and How to Fix Them
Test precise error-location handling with confidence
Synthibase can generate synthetic messages with defects planted in repeating segments and specific components, so your ERR-2 parsing logic gets tested against the exact scenarios that trip it up in production.
Start free trial →
This page is written independently by Synthibase for testing and informational purposes. It is not an official publication of HL7 International or X12/Washington Publishing Company, and is not a substitute for reviewing the official standard or your trading partner's companion guide. See our Terms of Service for full legal terms.