Reference·PID Segment·PID-1
HL7 v2 Reference

Testing HL7 v2 PID-1: What Set ID Actually Needs to Handle

Jul 27, 2026 · 4 min read
← PID-8 PID-3 →

Most messages carry exactly one PID segment with Set ID equal to 1, so parsers rarely get tested against the case where a message legitimately carries more than one — until a merge or linked-account scenario sends a second PID and the receiving system silently keeps only the first.

Quick answer

PID-1 is the first field of the HL7 v2 PID segment — a sequence number that identifies which occurrence a given PID segment is when more than one appears in a single message.

What this field contains

1
First (and usually only) PID segment in the message
2, 3, …
Subsequent PID segments, in cases like linked accounts or merges

Example

Synthetic example Generated by Synthibase
PID|1||847213609^^^HOSP^MR||GARCIA^ELENA^M||19870314|F|||482 OAK ST^^DENVER^CO^80202||3035550142|||M|

The 1 right after PID| is the Set ID marking this as the first PID segment in the message. Synthetic patient — not a real person.

Where this trips people up

Parsers that grab "the PID segment" by type code alone, rather than iterating on Set ID, work fine until a message with two PID segments arrives — then whichever segment the parser happens to match first wins, and the other patient identity data disappears without any error being raised.

HL7 v2 PID Segment Guide: Fields, Format, and Testing Gotchas
How to Write EDI Test Cases That Actually Catch Go-Live Failures
HL7 ADT Messages: A01 through A08 Explained
Generate multi-segment edge cases automatically
Synthibase can generate messages with repeating and multiple PID segments so your parser gets tested against the cases that only show up after go-live.
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.