Free preview
3.2 · Segments, fields, components, subcomponents
Section 3 · Module 3 · Reading a healthcare message · 15 min
Four levels, and one rule for each
A v2 message nests four levels deep, and each level has its own separator. Learn the four and you can find anything.
| Level | Separated by | Example |
|---|---|---|
| Segment | a new line | PID |
| Field | | | PID-3 |
| Component | ^ | PID-5.1 |
| Subcomponent | & | PID-5.1.1 |
Plus one that is not a level but sits alongside: repetition, separated by ~, which is the same field occurring more than once.
Segments
One line, one segment. The first three characters name it, and the name tells you what kind of information is on that line.
A message has a required order — MSH first, always — and some segments may repeat. A result message carries one OBX per analyte, so a full blood count has four of them in a row.
Fields
Everything between two | characters, counted from the segment name.
PID|1||9990000018^^^NHS^NH||OKONKWO^Margaret^Rose^^Mrs||19510314|F
PID-1 is 1. PID-2 is empty. PID-3 is the identifier. PID-4 is empty. PID-5 is the name.
Two rules, and the second is where people go wrong.
Count separators, not values. Exactly as in lesson 2.1, and for the same reason.
An empty field still occupies its position. || is a field that exists and has no value. It is not skipped. Three consecutive bars are two empty fields, and a reader who treats them as one will be wrong about everything to the right.
Components
A field can be structured. The patient name is not one value; it is a set:
OKONKWO^Margaret^Rose^^Mrs
PID-5.1 surname, PID-5.2 first given name, PID-5.3 second given name, PID-5.4 empty (suffix), PID-5.5 title.
Which components a field has is fixed by the standard for that field. PID-5 is always a name structured that way; PV1-3 is always a location structured as ward, room, bed, facility.
Subcomponents
One level further, separated by &. Rare in the messages you will meet, common in addresses and in coded values that carry their own coding system. Know it exists; you will not often need it.
Finding the ward, by counting only
PV1|1|I|ACU^ACU-04^1^STAIDANS||||C2101234^Hollins^Peter^^^Dr|||300^General Medicine
The ward is in PV1-3.1. Find it without reading anything.
Step one — count fields. Start after PV1. Field 1 is 1. Field 2 is I. Field 3 is ACU^ACU-04^1^STAIDANS.
Step two — split field 3 on ^. Four components: ACU, ACU-04, 1, STAIDANS.
Step three — take component 1. ACU.
Now check yourself by continuing the count. Fields 4, 5 and 6 are empty — that is the run of |||| after STAIDANS, which is four bars and therefore three empty fields, taking you to field 7. Field 7 is the consultant, C2101234^Hollins^Peter^^^Dr. If you land on the consultant at position 7, your count of the empty fields was right.
That self-check — count to a field whose content you can recognise — is the fastest way to catch an off-by-one, and it costs nothing.
Repetition
The ~ separates repeats of a whole field.
PID-3 = 9990000018^^^NHS^NH~1204432^^^STAIDANS^PI
That is one field containing two identifiers. Split on ~ first, then treat each part as a normal field with components:
9990000018^^^NHS^NH— the value, assigning authorityNHS, typeNH(NHS number)1204432^^^STAIDANS^PI— the value, authoritySTAIDANS, typePI(patient internal identifier)
The order is not guaranteed. A receiver looking for the NHS number must find the repetition whose type is NH, not take the first one. Systems that took the first one have been sending the hospital number where the NHS number belongs for years without anybody noticing.
How many fields are in PID|1||9990000018^^^NHS^NH||OKONKWO^Margaret, and what is the highest-numbered one that has a value?
Five fields; the highest with a value is PID-5.
Count the bars after the segment name: there are five, and five separators means five fields follow — 1, empty, the identifier, empty, the name.
The trap is the double bars. || after 1 is field 2, empty. || after the identifier is field 4, empty. Read by eye and both vanish, giving you three fields and a name that appears to be PID-3.
There is a second trap worth noticing: this is a *fragment*, not a real PID segment. A real one continues to field 8 and beyond. A line that stops early is not a line with fewer fields — the remaining fields are absent, which is different from empty, and lesson 6.2 comes back to why a specification has to say which it means.
Empty, absent, and null
Three different things, and v2 distinguishes them:
- Empty —
||. The field is present and carries no value. Usually means "not recorded". - Absent — the segment ends before that field. Means the sender had nothing to say and did not
say it.
- Null —
|""|, two double quotes. Means "this value has been deliberately cleared". You will
meet this in an update message where a previously recorded value is being removed.
Most receivers treat empty and absent identically. Almost none handle null correctly, which is why an address deleted at the sending end so often persists at the receiving one.
A receiver stores the patient's title as Rose. The name field is OKONKWO^Margaret^Rose^^Mrs. What has gone wrong, and is the message at fault?
The receiver is reading component 3 where it should read component 5. The message is correct.
PID-5 components run surname, first given name, second given name, suffix, prefix. Margaret Rose has two given names, so Rose sits at component 3 and Mrs at component 5.
The receiver was almost certainly written against a patient with one given name — where the layout looks like SMITH^John^^^Mr, component 3 is empty, and counting to the title by eye lands somewhere that happens to work.
Note what this predicts. Patients with one given name are stored correctly; patients with two get the second given name as their title. It will affect a minority of records, look like sporadic data entry error, and survive for years — because nobody compares the two cases side by side.
The way to find faults like this is to test with a *deliberately awkward* record rather than a typical one, which is the same lesson as the four-examples point in module 6.
What goes wrong
- Skipping empty fields. The single most common error in reading v2 by hand.
- Taking the first repetition. Check the type, do not trust the order.
- Counting
MSHlike any other segment. It is not, and lesson 3.3 is entirely about why.
---
Next: lesson 3.3, the header — the one segment that must be read before any other, and the two fields in it that break every rule you have just learned.
You will do all of this by hand in lab R3.
That is one lesson of 41
(ECIF) – EduQan Certified Integration Foundations runs to 41 lessons across 6 sections, and ends in an assessed, dated certificate you can have verified by anyone.