Decode an HL7 PID segment
Interactive
Learning objective: by the end of this lab, you will be able to locate the patient identifier, name, date of birth, sex, and address in an HL7 v2 PID segment, including fields that use component delimiters and non-ISO date formats.
HL7 v2 messages are not JSON. They are positional, pipe-delimited strings where meaning lives in the field number and, inside several fields, in caret-separated components. Work through the segment below before reading the field guide.
Sample PID segment (pipe-delimited)
No fields decoded yet. Click a highlighted field.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Click the field in the segment above to reveal what it means.
Step 1: Find the segment header
Every segment starts with a three-letter code. PID means patient identification. Everything after the first pipe is a numbered field: PID.1, PID.2, PID.3, and so on. Empty fields still occupy a position; two pipes in a row (||) mean the field between them is blank.
Step 2: Read the identifier and name
PID.3 holds the medical record number, often with assigning authority components after ^. PID.5 is the legal name as family^given^middle^suffix^prefix. The sample uses Nguyen^Lan^Thi^^Ms: surname Nguyen, given Lan, middle Thi, no suffix, prefix Ms.
Step 3: Decode dates and coded values
PID.7 is date of birth as YYYYMMDD with no hyphens. 19870423 is 23 April 1987, not an ISO string. PID.8 is administrative sex as a single letter. Tables vary by version, but F and M are the ones you will see most often.
Step 4: Address and contact fields
PID.11 is the patient address: street, city, province, postal code, country, each separated by ^. A double caret (^^) means an unused component, usually the second address line. PID.13 is a phone number stored literally, formatting and all.
What to take away
HL7 v2 rewards positional literacy, not memorisation of every optional field. If you can read PID.3, PID.5, PID.7, PID.8, and PID.11, you can orient yourself in most admission feeds long before you touch an interface engine. When a field looks wrong, check whether you are splitting on pipes when you should be splitting on carets.