Skip to content
The Path

Module 6 · FHIR·12 min

From HL7 v2 to FHIR

Mapping an ORU to an Observation, field by field.

The Leleux Clinic interface engine receives an ORU^R01 from the sleep lab. The patient app wants FHIR. Someone has to decide where each field goes. Good news: HL7 has published an official guide for exactly that, and we are going to use it.

Here is the starting message:

The sleep lab sends Marie Dubois’s AHI. Click each field of the OBX: each has a precise destination in FHIR.

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

The official HL7 v2-to-FHIR guide

HL7 publishes the HL7 Version 2 to FHIR guide, version 1.0.0, STU 1 (Standard for Trial Use), built on FHIR R4. It holds three kinds of tables:

  • message maps: which message gives which resources;
  • segment maps: which field goes into which element;
  • vocabulary maps: which v2 code becomes which FHIR code.

It is not law: every project can adapt it. But starting from the guide saves you from reinventing what others have already argued about for years.

Level 1: the message becomes a bundle of resources

For an ORU^R01, the guide gives:

v2 segment FHIR resource
MSH Bundle and MessageHeader
PID Patient
PV1 Encounter
ORC, OBR ServiceRequest and DiagnosticReport
OBX Observation, one per OBX
NTE a note in the relevant resource

The flat message turns into a network of resources linked by references.

Level 2: PID becomes Patient

v2 field FHIR element In our example
PID-3 Patient.identifier 1024, LELEUX record
PID-5 Patient.name family DUBOIS, given Marie
PID-7 Patient.birthDate 1985-03-12
PID-8 Patient.gender F becomes female
PID-11 Patient.address (empty here)

Two details. The date changes format: 19850312 becomes 1985-03-12. And sex goes through a vocabulary table: F from v2 table 0001 becomes female.

Level 2: OBX becomes Observation

This is the heart of the lesson. Click the OBX fields in the message above as you follow this table.

v2 field FHIR element In our example
OBX-2 picks the type of value[x] NM gives valueQuantity
OBX-3 Observation.code local code AHI, then LOINC 69990-0 as alternate
OBX-5 Observation.value[x] 28.5 in valueQuantity.value
OBX-6 the unit of valueQuantity /h
OBX-7 Observation.referenceRange.text <5
OBX-8 Observation.interpretation H
OBX-11 Observation.status F becomes final
OBX-14 Observation.effectiveDateTime 2026-06-27T06:30:00
OBX-16 Observation.performer (empty here)

Three mechanisms to remember.

OBX-2 decides the shape. NM gives valueQuantity. ST would give valueString. CWE would give valueCodeableConcept. That is why a wrong OBX-2 breaks the conversion.

OBX-3 gives two codes. The local code (components 1 to 3) and the alternate code (components 4 to 6) become two coding entries in the same Observation.code.

OBX-6 gives the unit. The guide puts the first component into the Quantity’s code, and the second one, the label, into unit. Here the second one is empty: the engine often copies the code, /h, as the label. The unit system is not written in our message: in v2.5.1, the coding system table does not list UCUM yet (later versions add it). So the interface engine has to know that /h is a valid UCUM unit, “per hour”, and add http://unitsofmeasure.org.

Here is the result:

{
  "resourceType": "Observation",
  "status": "final",
  "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": { "reference": "Patient/1024" },
  "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" }
      ]
    }
  ],
  "referenceRange": [{ "text": "<5" }]
}

The subject link to Patient/1024 comes from the PID in the same message. The URI of the local code is written nowhere in the v2: L only says “local”. The engine knows it and adds it. The +02:00 offset is not in OBX-14: the interface engine has to know the time zone and add it.

Vocabulary tables

v2 and FHIR codes are not always the same. The guide provides tables to go from one to the other:

v2 table v2 code FHIR code
0085, result status F final
0085 P preliminary
0085 C corrected
0078, abnormal flag H H
0078 L L
0001, sex F female

Some codes have no counterpart. In table 0085, R (results entered, not verified) or I (specimen in lab) have no direct mapping in the guide: your project has to decide. The guide shows a technique to lose nothing: keep the original v2 code in an extension on status.

OBR becomes DiagnosticReport

v2 field FHIR element
OBR-3 DiagnosticReport.identifier
OBR-4 DiagnosticReport.code
OBR-7 and OBR-8 DiagnosticReport.effectivePeriod, start and end
OBR-22 DiagnosticReport.issued
OBR-25 DiagnosticReport.status

So the polysomnography report gets a period: from 26 June, 10 p.m., to 27 June, 6:30 a.m. Each Observation keeps its own point in time.

Check your understanding

1 of 4

In the official v2-to-FHIR guide, where does OBX-5 go when OBX-2 is NM?

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

Reviewed and checked on 27 September 2026