Skip to content
The Path

Module 7 · The full case·20 min

One night at the lab, message by message

Order, appointment, admission, result, report, discharge: the whole chain.

You now know every piece on its own. Here we put them together. We follow Marie Dubois from the pulmonologist’s order to the signed report, and we look at every message her night at the sleep lab sends across the hospital.

Keep an eye on three numbers. They run through the whole story:

  • 1024^^^LELEUX^MR: Marie’s record number, in PID-3;
  • PLACER-7781: the order number, given by the hospital record system (HIS);
  • PSG-2026-0042: the study number, given by the sleep lab (SLEEPLAB).

To make the chain easy to follow, the messages shown are numbered MSG00201 to MSG00207. In real life, each sender keeps its own counter.

1. Monday, June 15: the order

During the consultation, Dr Martin orders a polysomnography (PSG). He clicks in the patient record. The HIS sends an order to the sleep lab.

The hospital record system orders a polysomnography from the sleep lab.

ORM^O01^ORM_O01· Order message
||||||||||
||||||||
||||||||||||
||||||||||||||||

ORC-1 is NW: a new order. ORC-2 holds the placer number, PLACER-7781. ORC-3 is empty: the lab has not given its own number yet. OBR-4 says what to do, here the LOINC code for the polysomnography panel.

Two seconds later, the lab answers:

The sleep lab confirms it received and processed the order.

ACK^O01^ACK· Acknowledgement
||||||||||
||

MSA-1 is AA: accepted. MSA-2 echoes the order’s MSH-10. That link is how the HIS ticks “received” on the right message.

Every message that follows gets its own ACK too, sent back by its receiver. We stop showing them to keep things light, but they are there: six business messages, six acknowledgements.

2. A few minutes later: the appointment

The lab secretary books the night. The sleep lab software is the filler: it announces the booking with an SIU^S12, “new appointment booked”.

The lab books room 201 for the night of June 26 and links the appointment to the order.

SIU^S12^SIU_S12· Appointment scheduled
||||||||||
|||||||||||||||||||||||||||
||||||||
||||||||
||
||||
|||

The key moment sits at the end of the SCH line. SCH-26 recalls the order, PLACER-7781. SCH-27 gives the lab’s number for the first time: PSG-2026-0042. From here on, both systems talk about the same study through two linked numbers. SCH-25 is Booked, and TQ1 carries the time slot: 9:30 pm to 7 am.

Three fields near the start are required in v2.5.1, even if they look minor. SCH-6 gives the event reason, here a local code BOOK, new booking. SCH-16 and SCH-20 name the contact person at the lab and the person who entered the appointment: here, the same lab secretary. Leave them empty and a validator rejects the message.

3. Friday, June 26, 8 pm: admission

Marie checks in at the front desk. She gets room 201. The HIS sends an ADT^A01.

Marie arrives for her night. The hospital record opens an inpatient stay with a bed.

ADT^A01^ADT_A01· Patient admit
||||||||||
||||||
||||||||
||||||||||||||||||||||||||||||||||||||||||||

Why A01 and not A04? The standard keeps A01 for admitted patients who get a bed. A04 is for an outpatient who does not use a bed. Marie sleeps in a bed until morning: A01, with PV1-2 = I (inpatient). Some hospitals file a PSG as outpatient care and send A04 with PV1-2 = O. Both can be defended. What matters: the rule is written in the interface specification, and both sides follow it.

Also note PV1-19: V2026-0815, the visit number. The next messages will hook onto it.

4. The night: what the PSG records

During the night, no HL7 message moves. Everything stays in the polysomnography software. The technologist places the sensors, and each one tells part of the story:

Sensor What it picks up, in plain words
EEG brain activity, to know whether she sleeps and in which stage
EOG eye movements, the giveaway of REM sleep
EMG muscle tone at the chin, and leg movements
Airflow air going in and out through the nose and mouth
Chest and abdominal belts the effort to breathe, even when air stops flowing
Oximeter (SpO2) blood oxygen level, measured at the fingertip

The recording runs from 10 pm to 6:30 am. Dozens of channels, hours of signal: that is the raw material. HL7 will carry only a summary of it.

5. Saturday, June 27, 7 am: discharge

The sensors come off, Marie goes home. The HIS closes the stay with an ADT^A03.

End of the stay: the hospital record announces that Marie has left the lab.

ADT^A03^ADT_A03· Patient discharge
||||||||||
||||||
||||||||
|||||||||||||||||||||||||||||||||||||||||||||

Same visit (PV1-19), same patient. PV1-44 keeps the arrival time, PV1-45 adds the discharge time.

6. Monday, June 29: the result

The technologist scores the night: apneas, hypopneas, desaturations, sleep stages. Once the scoring is validated, the lab sends the numbers in an ORU^R01.

The lab sends the validated key measurements of the night to the hospital record.

ORU^R01^ORU_R01· Observation result (unsolicited)
||||||||||
||||||||
|||||||||||||||||||
|||||||||||||||||||||||||
||||||||||||||
||||||||||||||
||||||||||||||
||||||||||||||

Everything connects. OBR-2 and OBR-3 carry both order numbers. PV1-19 points to the visit. Each OBX is one measurement:

  • OBX-3: what. The AHI carries its local code and, as an alternate, the closest LOINC code (69990-0, see the terminologies lesson). Minimum SpO2 and sleep time only have a local code (^L). The desaturation index only has its LOINC code. Sleep labs often mix all three situations.
  • OBX-5 and OBX-6: the value and its unit.
  • OBX-7: the reference range, such as <5.
  • OBX-8: the flag. H above, L below, empty when there is nothing to report.
  • OBX-11: F, a final result.

Click OBX-8 on the third line: L, the minimum SpO2 is below the range.

7. Tuesday, June 30: the signed report

The doctor reviews, interprets, signs. The lab sends the report PDF in an MDM^T02: notification of a new document, with its content.

The lab sends the signed report as a base64-encoded PDF (cut short here).

MDM^T02^MDM_T02· Medical document
||||||||||
||
||||||||
|||||||||||||||||||
||||||||||||||||||||||
|||||||||||

TXA-12 gives the document a unique number. TXA-17 is LA: legally authenticated. TXA-19 is AV: available for patient care. TXA-22 says who signed and when: Dr Martin, with the signing time in the fifteenth component. In OBX-5, the ED type splits into ^AP^PDF^Base64^ then the data. JVBERi0 is how every base64-encoded PDF begins. A real report weighs tens of kilobytes: we cut it short here. The PDF subtype is not in the base list of table 0291: it is an agreement between the two systems, to be written in the interface specification.

8. The same result in FHIR

If the hospital record spoke FHIR, the AHI would become an Observation resource:

{
  "resourceType": "Observation",
  "status": "final",
  "basedOn": [{
    "type": "ServiceRequest",
    "identifier": {
      "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v2-0203", "code": "PLAC" }] },
      "system": "https://fhir.clinique-leleux.example/sid/demande",
      "value": "PLACER-7781"
    }
  }],
  "code": {
    "coding": [
      {
        "system": "https://fhir.clinique-leleux.example/CodeSystem/labo-sommeil",
        "code": "AHI",
        "display": "Apnea-hypopnea index"
      },
      {
        "system": "http://loinc.org",
        "code": "69990-0",
        "display": "Apnea hypopnea index 24 hour"
      }
    ]
  },
  "subject": { "identifier": { "system": "https://fhir.clinique-leleux.example/sid/dossier", "value": "1024" } },
  "encounter": { "identifier": { "system": "https://fhir.clinique-leleux.example/sid/sejour", "value": "V2026-0815" } },
  "effectiveDateTime": "2026-06-27T06:30:00+02:00",
  "valueQuantity": { "value": 28.5, "unit": "/h", "system": "http://unitsofmeasure.org", "code": "/h" },
  "interpretation": [{
    "coding": [{
      "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
      "code": "H",
      "display": "High"
    }]
  }],
  "referenceRange": [{ "text": "<5" }]
}
FHIR element Comes from
status OBX-11 (F becomes final)
code OBX-3
subject PID-3
encounter PV1-19
effectiveDateTime OBX-14
valueQuantity OBX-5 and OBX-6
interpretation OBX-8
referenceRange OBX-7
basedOn the order (ORC, OBR-2), typed PLAC: the placer number

Look at subject and encounter: here the converter does not know the FHIR id of Marie or of her stay. It points to them by their numbers, record 1024 and visit V2026-0815: a logical reference. The server makes the link. The URIs keep their French words because a URI is an identifier: it stays the same in every language.

One trap: FHIR requires a time zone as soon as a time is given. The v2 value had none, so the converter must add +02:00, Belgian summer time.

9. The full chain

One night at the lab, fast-forward

Patient record

HIS

Sleep lab

SLEEPLAB

  1. ORM^O01 · NW
  2. ACK · AA
  3. SIU^S12
  4. ADT^A01
  5. ADT^A03
  6. ORU^R01 · F
  7. MDM^T02 · PDF

Step Message Trigger Key field
1 ORM^O01 the doctor orders ORC-1 = NW, ORC-2
1b ACK the lab receives MSA-2 = MSG00201
2 SIU^S12 the lab books SCH-27 = PSG-2026-0042
3 ADT^A01 Marie arrives PV1-2 = I, PV1-19
4 none the night everything stays in the software
5 ADT^A03 Marie leaves PV1-45
6 ORU^R01 scoring is validated OBX-5, OBX-8, OBX-11
7 MDM^T02 the doctor signs TXA-17 = LA, OBX-5 as ED
after 2, 3, 5, 6, 7 ACK the receiver gets it MSA-2 = MSH-10 of the message received
8 Observation FHIR conversion status, valueQuantity

What could go wrong

Three incidents an integrator really runs into.

The unknown patient. Imagine the ORU leaves with 1042 instead of 1024 in PID-3. The HIS cannot find that record and replies:

The hospital record rejects the result: it does not know the identifier it received.

ACK^R01^ACK· Acknowledgement
||||||||||
||
|||||||

MSA-2 says which message failed. ERR-2 says where: PID-3. ERR-3 says what: 204, unknown key. In the engine, this message lands in the error queue. You fix the identifier at the source, then resend.

The result before the admission. On Friday evening, the engine’s ADT channel stopped and nobody noticed. The A01 is sitting in a queue. On Monday, the ORU goes through another channel, which works fine. The HIS receives a result for a visit V2026-0815 it does not know. Depending on the system, it rejects it or parks it with the orphans. You spot it by comparing the MSH-7 times of both messages in the logs, and by watching the pending queues. The fix: process messages for the same patient in order, and hold a result until its visit exists.

The duplicate MSH-10. The lab software restarts and its counter goes backwards. Two different messages carry MSG00206. The HIS may take the second one for a repeat and drop it. Or the reverse: a message resent after a timeout with no ACK gets processed twice, and the result shows up twice. You see it by searching that MSH-10 in the logs: same number, different content means a counter bug. The standard asks that MSH-10 identify one single message.

Check your understanding

1 of 5

The sleep lab sends back MSA|AA|MSG00201. Which message has just been accepted?

+50 XPPass the quiz (4 correct answers) to complete the lesson.

Reviewed and checked on 27 September 2026