Reference·PID Segment·PID-8
HL7 v2 Reference

HL7 v2 PID-8 (Administrative Sex): Format, Values, and Testing Notes

Jul 27, 2026 · 4 min read
PID-1 →

Most integrations are built and tested assuming PID-8 only ever contains M or F — until an upstream feed sends O, U, A, or N and the message gets silently rejected or mis-mapped downstream.

Quick answer

PID-8 is the eighth field of the HL7 v2 PID segment — it carries the patient’s administrative sex as a coded value, used for demographic and billing purposes across ADT, ORU, and other message types.

Valid code values

M
Male
F
Female
O
Other
U
Unknown
A
Ambiguous
N
Not applicable

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 8th field (F) marks the patient as female. Synthetic patient — not a real person.

Where this trips people up

Systems built to expect only M or F will reject or mis-map O/U/A/N values coming from upstream feeds. This is exactly the kind of edge case that passes a happy-path test suite and then fails on real go-live data — worth testing explicitly before launch, not discovering in production.

HL7 v2 PID Segment Guide: Fields, Format, and Testing Gotchas
How to Write EDI Test Cases That Actually Catch Go-Live Failures
Synthetic Patient Data: Complete Guide for Software Testing
Generate every PID-8 code value automatically
Synthibase generates synthetic PID segments covering every administrative sex code — including the edge cases most test suites miss.
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.