---
title: "HL7 vs FHIR: when to use each in an EMR integration"
description: "HL7 v2 and FHIR solve different problems. A practical guide to choosing, combining and testing both in a healthcare integration."
url: "https://mitrix.io/blog/hl7-vs-fhir-when-to-use-each/"
author: "Dmitri Koteshov"
date: 2026-11-10
---

# HL7 vs FHIR: when to use each in an EMR integration

A team asks whether to use HL7 or FHIR. The useful answer is usually both, for different jobs. HL7 v2 is how most US clinical data still moves between hospitals, labs and vendors. FHIR is how newer APIs, patient access and bulk exchange are shaped.

Choosing one as a matter of principle leads to expensive rewrites. Choosing by interface, latency and partner capability leads to a system that works.

## What HL7 v2 is good at

HL7 v2 is an event-messaging standard. It is designed to say “this happened” and push a message to another system. The common message types are familiar to anyone who has worked in a hospital interface team:

- **ADT** for admissions, discharges and transfers.
- **ORU** for observations and lab results.
- **ORM** for orders.
- **SIU** for scheduling.

It is mature, widely implemented and relatively cheap to connect. Most EHRs, labs and ancillary systems already speak it. The weaknesses are real: the schema is loose, local variants are everywhere, Z-segments carry custom data, and the standard is not a query model. Two senders can implement the same field differently.

## What FHIR is good at

FHIR is a resource-oriented API standard. It models clinical concepts as resources such as Patient, Encounter, Observation, MedicationRequest and DocumentReference, with RESTful access and JSON or XML payloads. It is a better fit for patient-facing apps, mobile clients, partner APIs and bulk data exchange.

US Core profiles narrow FHIR for US interoperability. Bulk FHIR supports population-level export. SMART on FHIR supports app launch inside an EHR. TEFCA and other exchange networks use FHIR-based exchange, though the operational details vary by network and participant.

FHIR is still evolving. Profiles, implementation guides and vendor support differ, and mapping a legacy data model to FHIR is real work. It is not a free data model.

## A hybrid architecture

Most working systems use both:

1. **HL7 v2 at the edge** for event messages from hospitals, labs and legacy systems. Parse, validate and store the raw message.
2. **A canonical model in the middle** that normalises patient, encounter, order and result data. This is where reconciliation and identity live.
3. **FHIR at the product edge** for apps, partners and patient access. Expose the canonical model as FHIR resources with the right profiles.
4. **Flat files and vendor APIs** where neither standard exists. Keep them behind the same ingestion contract.

The canonical layer is the part teams skip. Without it, every new interface becomes a new mapping and every consumer sees a different version of the patient.

## A lab result, two ways

Consider a lab result that needs to reach a clinician and a patient portal.

In an HL7 v2 flow, the lab sends an ORU message. The interface parses the message, maps the patient and order identifiers, stores the observation, and notifies the EHR. The message is the event. If the interface is down, the lab may resend it, and the system has to avoid duplicating the result.

In a FHIR flow, the lab exposes an Observation resource, or the integration layer creates one after ingesting the message. The portal queries the Observation for the patient, with pagination and authorization. The same clinical fact now has two representations, and the canonical model has to keep them consistent.

Neither approach removes the hard parts: patient matching, units, reference ranges, status codes and provenance. The standard changes the transport; the semantics stay.

## Mapping pitfalls

Most integration defects are semantic, not syntactic. Watch for these:

- **Identifiers.** A medical record number is local. A patient may have several, and an order may carry a different identifier from the result.
- **Terminology.** LOINC for labs, SNOMED CT for clinical findings, ICD-10 for diagnoses, NDC for drugs and local codes for everything else. A code without a system is not a code.
- **Status and units.** Preliminary versus final, corrected versus cancelled, mg/dL versus mmol/L. These change the clinical meaning.
- **Reference ranges.** A value can be normal in one lab and abnormal in another. Keep the range and the lab that produced it.
- **Time.** Time zones, precision and the difference between collection time and result time.

## When to add a FHIR facade

A FHIR facade is worth building when a patient-facing app, a partner or a reporting product needs queryable access to data that currently arrives as messages. It is not worth building only to satisfy an architecture preference. Start with the resources the consumer needs, expose them through a stable API, and keep the mapping in one service.

## How to choose for a specific interface

Ask five questions:

- Does the source system send events, or does the consumer need to query?
- What does the partner actually support today, not on a roadmap?
- Is the data needed in real time, or is a nightly batch acceptable?
- Does the consumer need a longitudinal record or a single encounter?
- Who owns the mapping when the source changes a field?

A lab result feed is often HL7 v2 because the lab sends ORU messages. A patient-facing app is often FHIR because it needs granular queries and a stable API. A reporting pipeline may be neither: flat files and bulk export are cheaper.

## Testing both

HL7 v2 tests need real message samples in addition to the specification. Keep a corpus per sender, validate segments and fields, and test missing optional fields, unexpected Z-segments, encoding characters and out-of-order messages. Store the raw message so you can replay it.

FHIR tests need profile validation, terminology checks, pagination, search parameters, error responses and authorization. Test against the partner’s implementation guide as well as the base specification. A resource that validates against R4 can still fail the US Core profile the partner requires.

## Who owns the interface after launch

Interfaces fail quietly. A lab feed stops at 2am, a sender adds a Z-segment, a payer changes a code, or a certificate expires. The team that built the interface is not always the team that operates it. Name the owner before go-live.

Monitoring should be per interface, not per server. Track message volume, error rate, lag, duplicate rate and reconciliation counts. Alert on absence as well as errors: a feed that sends nothing is often worse than one that sends bad data, because nobody notices.

Make replay, schema changes and vendor tickets part of the runbook. A change to a mapping should be reviewable, versioned and reversible. The person on call should be able to see the raw message and the last successful one without opening a database console.

## Security and consent

FHIR and HL7 carry the same PHI as the clinical record. Scope access per interface, log every read, and avoid broad service accounts. Consent and patient access rules belong in the API layer. If a partner only needs observations for one patient, do not give it a population query.

## What not to do

Do not rewrite a working HL7 interface in FHIR because FHIR is newer. Do not expose raw HL7 messages to product teams and call it an API. Do not assume a FHIR facade solves patient identity or consent. Do not let each team build its own mapping layer.

## How Mitrix handles it

Mitrix has built EMR integrations with HL7 XML exchange, flat-file and third-party database ingestion, mapping, retries, monitoring and schema versioning. We keep the reconciliation view alongside the pipeline, because the interface is not finished when the first message lands.

For the broader integration picture, read [EMR integration: HL7, flat files and reconciliation](/blog/emr-integration-hl7-flat-files-reconciliation/). For the product scope, see [EHR vs EMR](/blog/ehr-vs-emr-difference-for-product-teams/). If you are choosing an interface approach, [talk to us](/contacts/).
