Lesson 5 of 51 · Message Structure in Depth
Data Types — from ST and NM to XPN, XAD, CX, and CWE
Fields are typed
Earlier lessons treated a field as “the text between two | characters.” That is
true on the wire, but every field is also declared to have a data type that
says how to interpret it 1. A data type can be primitive
(a single value) or composite (several components with defined meanings). Knowing
a field’s type is what lets a parser turn 19800101 into a date and
DOE^JANE^Q^^DR^MD into a structured name.
Primitive types you will see constantly
| Type | Name | Example | Notes |
|---|---|---|---|
ST |
String | Final report |
Short free text. |
TX |
Text | Patient reports... |
Longer text; may contain formatting. |
NM |
Numeric | 7.4 |
A number, no units attached. |
DT |
Date | 20240601 |
YYYYMMDD. |
DTM/TS |
Date-Time | 202406011230 |
Date with time, optional precision. |
ID / IS |
Coded value | F, AA |
A code drawn from an HL7 or local table. |
The single most important habit: a value’s meaning comes from its type plus its
position, never from the text alone. F in a sex field means “female”; F in a
result-status field means “final.” Both are the ID type pointing at different
tables.
Composite types: a field with internal structure
Composite types use the component delimiter (^) to pack related pieces into one
field. The figure below shows XPN, the extended person name:

A few composites carry most of the clinical weight:
XPN— extended person name: family, given, middle, suffix, prefix, degree.XAD— extended address: street, other designation, city, state, zip, country.XCN— extended composite name & number for persons: an id and a name, used for providers (e.g.,004777^SMITH^JOHN).CX— extended composite id with check digit: an identifier plus its assigning authority and identifier type — howPID-3carries a medical record number (100711^^^HOSP^MR).CWE— coded with exceptions: the workhorse for coded clinical data — a code, its display text, and the coding system it came from. The next course on terminologies returns toCWEin depth.
Why this matters
Most interface defects are type defects: a date in the wrong format, a coded field populated with free text, an identifier missing its assigning authority so two systems can’t agree whose “100711” it is 2. Reading a segment well means reading each field as its declared type — the structure is there even when the delimiters make it look like plain text.
References
- HL7 Standards — Section 1d: Version 2 (V2). HL7 International. verified
- Tim Benson, Grahame Grieve. Principles of Health Interoperability: FHIR, HL7 and SNOMED CT. 4th ed. Springer. 2021. verified