HL7 v2 Data Types Reference
HL7 data types define how values are structured within segment fields. A single field like PID-3 (Patient Identifier List) contains multiple components — ID number, assigning authority, identifier type — packed into one composite data type (CX). Understanding these data types is essential for parsing and building HL7 messages.
Identification Data Types
Section titled “Identification Data Types”CX — Extended Composite ID with Check Digit
Section titled “CX — Extended Composite ID with Check Digit”Used for patient identifiers, account numbers, and visit numbers.
Found in: PID-3, PID-18, PV1-19, IN1-3
MRN12345^^^MAIN_HOSP^MR| Component | Name | Example | Purpose |
|---|---|---|---|
| CX.1 | ID Number | MRN12345 | The actual identifier value |
| CX.2 | Check Digit | (empty) | Optional validation digit |
| CX.3 | Check Digit Scheme | (empty) | M10, M11, etc. |
| CX.4 | Assigning Authority | MAIN_HOSP | Organization that issued the ID |
| CX.5 | Identifier Type | MR | Type code: MR, AN, VN, SS, PI |
Common CX.5 type codes:
| Code | Type | Description |
|---|---|---|
| MR | Medical Record Number | Primary patient identifier |
| AN | Account Number | Billing/financial account |
| VN | Visit Number | Encounter identifier |
| SS | Social Security Number | SSN (use cautiously — HIPAA sensitivity) |
| PI | Patient Internal | Internal system identifier |
| PT | Patient External | External/cross-system identifier |
| DL | Driver’s License | State-issued ID |
| NPI | National Provider ID | Provider NPI number |
EI — Entity Identifier
Section titled “EI — Entity Identifier”Used for order numbers, document IDs, and equipment identifiers.
Found in: ORC-2, ORC-3, OBR-2, OBR-3, TXA-12
ORD5678^EPIC| Component | Name | Example | Purpose |
|---|---|---|---|
| EI.1 | Entity Identifier | ORD5678 | The identifier value |
| EI.2 | Namespace ID | EPIC | Assigning application |
| EI.3 | Universal ID | (empty) | OID or UUID (optional) |
| EI.4 | Universal ID Type | (empty) | ISO, UUID, DNS (optional) |
Person and Name Data Types
Section titled “Person and Name Data Types”XPN — Extended Person Name
Section titled “XPN — Extended Person Name”Used for patient, contact, and guarantor names.
Found in: PID-5, NK1-2, GT1-3, IN1-16
DOE^JOHN^ALEXANDER^^JR^MD| Component | Name | Example | Purpose |
|---|---|---|---|
| XPN.1 | Family Name | DOE | Last name |
| XPN.2 | Given Name | JOHN | First name |
| XPN.3 | Second Name | ALEXANDER | Middle name |
| XPN.4 | Suffix | (empty) | Jr., Sr., III |
| XPN.5 | Prefix | JR | Title prefix |
| XPN.6 | Degree | MD | Academic/professional degree |
| XPN.7 | Name Type | L | L (Legal), D (Display), M (Maiden), A (Alias) |
XCN — Extended Composite ID Number and Name
Section titled “XCN — Extended Composite ID Number and Name”Used for provider identification — combines an ID with a name.
Found in: PV1-7, PV1-8, ORC-12, OBR-16, EVN-5
ATT1234^SMITH^JANE^^^MD| Component | Name | Example | Purpose |
|---|---|---|---|
| XCN.1 | Person Identifier | ATT1234 | Provider ID (NPI or local) |
| XCN.2 | Family Name | SMITH | Last name |
| XCN.3 | Given Name | JANE | First name |
| XCN.4 | Second Name | (empty) | Middle name |
| XCN.5 | Suffix | (empty) | Jr., Sr. |
| XCN.6 | Prefix/Degree | MD | Credential |
| XCN.9 | Assigning Authority | (empty) | Organization that assigned the ID |
| XCN.13 | Identifier Type Code | (empty) | NPI, UPIN, local |
Address and Contact Data Types
Section titled “Address and Contact Data Types”XAD — Extended Address
Section titled “XAD — Extended Address”Used for patient, contact, and facility addresses.
Found in: PID-11, NK1-4, IN1-5, IN1-19
123 MAIN ST^^ANYTOWN^OH^44101^USA| Component | Name | Example | Purpose |
|---|---|---|---|
| XAD.1 | Street Address | 123 MAIN ST | Street line 1 |
| XAD.2 | Other Designation | (empty) | Apt, Suite, Floor |
| XAD.3 | City | ANYTOWN | City name |
| XAD.4 | State | OH | State/province |
| XAD.5 | Zip Code | 44101 | Postal code |
| XAD.6 | Country | USA | ISO 3166 country code |
| XAD.7 | Address Type | H | H (Home), B (Business), M (Mailing) |
XTN — Extended Telecommunication Number
Section titled “XTN — Extended Telecommunication Number”Used for phone numbers, fax, email, and other contact methods.
Found in: PID-13, PID-14, NK1-5, NK1-6
^PRN^PH^^^^^555-867-5309| Component | Name | Example | Purpose |
|---|---|---|---|
| XTN.1 | Telephone Number | (deprecated) | Legacy format — use XTN.12 |
| XTN.2 | Use Code | PRN | PRN (Primary Residence), WPN (Work), EMR (Emergency) |
| XTN.3 | Equipment Type | PH | PH (Phone), FX (Fax), CP (Cell), Internet (Email) |
| XTN.4 | Communication Address | (empty) | Email address (when XTN.3 = Internet) |
| XTN.7 | Local Number | 555-867-5309 | Phone number (or XTN.12 in newer versions) |
| XTN.12 | Unformatted Number | 5558675309 | Full number without formatting |
Coded Data Types
Section titled “Coded Data Types”CE — Coded Element
Section titled “CE — Coded Element”The most widely used coded data type in HL7 v2. Carries a code, description, and coding system identifier.
Found in: PID-10, OBR-4, OBX-3, DG1-3, AL1-3
R50.9^Fever, unspecified^I10| Component | Name | Example | Purpose |
|---|---|---|---|
| CE.1 | Identifier | R50.9 | Code value |
| CE.2 | Text | Fever, unspecified | Human-readable description |
| CE.3 | Coding System | I10 | Which coding system (ICD-10, LOINC, SNOMED, etc.) |
| CE.4 | Alternate Identifier | (empty) | Alternate code |
| CE.5 | Alternate Text | (empty) | Alternate description |
| CE.6 | Alternate Coding System | (empty) | Alternate coding system |
CWE — Coded With Exceptions
Section titled “CWE — Coded With Exceptions”Introduced in v2.5 as a replacement for CE. Identical structure but supports “text only” entries when no code is available.
Found in: OBX-3 (v2.5+), ORC-16, many v2.5+ fields
The key difference: CWE allows CE.1 to be empty when CE.2 contains free text — useful when a coded value doesn’t exist in the coding system.
IS vs ID — Coded Values
Section titled “IS vs ID — Coded Values”| Type | Source | Description |
|---|---|---|
| IS | User-defined table | Facility-specific codes (e.g., PV1-2 patient class values) |
| ID | HL7-defined table | Standard HL7 codes (e.g., MSH-11 processing ID: P, T, D) |
IS values vary between implementations; ID values are standardized across all HL7 systems.
Date/Time Data Types
Section titled “Date/Time Data Types”TS — Timestamp
Section titled “TS — Timestamp”The standard date/time format in HL7 v2.
Found in: MSH-7, PID-7, EVN-2, OBR-7, OBR-22
20260301143000-0500| Precision | Format | Example | Meaning |
|---|---|---|---|
| Year | YYYY | 2026 | Year only |
| Month | YYYYMM | 202603 | March 2026 |
| Day | YYYYMMDD | 20260301 | March 1, 2026 |
| Hour | YYYYMMDDHH | 2026030114 | 2:00 PM |
| Minute | YYYYMMDDHHMI | 202603011430 | 2:30 PM |
| Second | YYYYMMDDHHMMSS | 20260301143000 | 2:30:00 PM |
| Timezone | +/-HHMM suffix | -0500 | EST (UTC-5) |
Common pitfall: Some systems send timestamps without timezone offsets. Receiving systems should default to the sending facility’s timezone when no offset is present.
DR — Date/Time Range
Section titled “DR — Date/Time Range”A pair of TS values representing a range.
Found in: FT1-4, IN1-12/13 (as separate DT fields)
20260301140000^20260301150000Component 1 is the range start; component 2 is the range end.
Location Data Types
Section titled “Location Data Types”PL — Person Location
Section titled “PL — Person Location”Structures the patient’s physical location in a facility.
Found in: PV1-3, PV1-6, PV1-11, PV1-42
ICU^0101^01^MAIN_HOSP^^^^NURS| Component | Name | Example | Purpose |
|---|---|---|---|
| PL.1 | Point of Care | ICU | Unit/department/ward |
| PL.2 | Room | 0101 | Room number |
| PL.3 | Bed | 01 | Bed number |
| PL.4 | Facility | MAIN_HOSP | Facility identifier |
| PL.5 | Location Status | (empty) | Active, inactive |
| PL.6 | Person Location Type | (empty) | C (Clinic), D (Department), N (Nursing) |
| PL.7 | Building | (empty) | Building code |
| PL.8 | Floor | NURS | Floor/nursing station |
HD — Hierarchic Designator
Section titled “HD — Hierarchic Designator”Identifies an application, facility, or other entity in a hierarchy.
Found in: MSH-3, MSH-4, MSH-5, MSH-6
EPIC^1.2.3.4.5^ISO| Component | Name | Example | Purpose |
|---|---|---|---|
| HD.1 | Namespace ID | EPIC | Application/facility name |
| HD.2 | Universal ID | 1.2.3.4.5 | OID for the application |
| HD.3 | Universal ID Type | ISO | OID type (ISO, UUID, DNS) |
Other Common Types
Section titled “Other Common Types”| Type | Name | Description | Example |
|---|---|---|---|
| ST | String | Free text, no formatting | Patient reported nausea |
| NM | Numeric | Numeric value | 98 |
| SI | Sequence ID | Integer sequence number | 1, 2, 3 |
| FT | Formatted Text | Text with HL7 escape sequences | Line 1\.br\Line 2 |
| TX | Text Data | Long free text | Clinical note content |
| TQ | Timing/Quantity | Schedule timing (deprecated in v2.5+ — use TQ1) | ^^30^202603011400^202603011430 |
| CP | Composite Price | Amount with currency | 350.00^USD |
Key Implementation Considerations
Section titled “Key Implementation Considerations”Component Separator Rules
Section titled “Component Separator Rules”HL7 v2 uses three levels of separation within fields:
| Level | Character | Purpose | Example |
|---|---|---|---|
| Field | | (pipe) | Separates segment fields | PID|1|...|DOE^JOHN |
| Component | ^ (caret) | Separates components within a field | DOE^JOHN^ALEXANDER |
| Sub-component | & (ampersand) | Separates sub-components within a component | MAIN_HOSP&1.2.3&ISO |
| Repetition | ~ (tilde) | Separates repeated values | MRN12345~SSN98765 |
These characters are defined in MSH-2 and should be read dynamically, not hardcoded.
Null vs Empty Fields
Section titled “Null vs Empty Fields”HL7 v2 distinguishes between empty fields and explicitly null fields:
| Representation | Meaning | Action |
|---|---|---|
|| | Empty/not valued | Do not update the stored value |
|""| | Explicitly null | Clear/delete the stored value |
This distinction is critical for ADT^A08 (Update Patient) messages — an empty field means “no change” while "" means “remove the previous value.”
Version Compatibility
Section titled “Version Compatibility”Many data types were expanded or replaced across HL7 versions:
| v2.3 | v2.5+ | Change |
|---|---|---|
| CE | CWE | Added “exceptions” support |
| TQ | TQ1 segment | Moved from field to segment |
| XTN.1 | XTN.12 | Phone number field relocated |
| CM | Various | Generic CM replaced with specific types |
When integrating systems on different HL7 versions, the integration engine should map between data type versions as part of message transformation.