If you are building software that touches clinical data, you will meet two acronyms early: HL7 v2 and FHIR. Both are standards from HL7 International for exchanging healthcare information, but they come from different eras and work very differently. Most real products end up supporting both.
This guide explains each one in plain terms, how they compare, and how to plan integrations without getting stuck.
HL7 v2: the workhorse
HL7 version 2 dates back to the late 1980s and is still the most widely used healthcare messaging standard inside hospitals. When a patient is admitted, a lab result is ready or an order is placed, systems often tell each other using HL7 v2 messages.
A message is plain text made of segments, one per line, with fields separated by the pipe character:
MSH|^~\&|LAB|CITYHOSP|EHR|CITYHOSP|202611211030||ORU^R01|MSG00001|P|2.5
PID|1||123456^^^CITYHOSP^MR||Sharma^Anita||19840312|F
OBR|1||LAB7788|CBC^Complete blood count
OBX|1|NM|718-7^Hemoglobin^LN||13.2|g/dL|12.0-15.5|N|||F
- MSH is the header: who sent it, who receives it, the message type and the version.
- PID identifies the patient.
- OBR and OBX describe an order and its result observations.
Common message types include ADT (admit, discharge, transfer), ORM or OML (orders) and ORU (results). Messages usually travel over MLLP, a simple framing protocol on top of TCP, through an interface engine inside the hospital network.
The catch is that HL7 v2 is flexible to the point of being inconsistent. Each hospital and vendor uses optional fields and custom Z-segments differently, so "we support HL7" rarely means two systems will work together without mapping work.
FHIR: the modern API standard
FHIR (Fast Healthcare Interoperability Resources) is HL7's newer standard, built for the web. Instead of messages, it models data as resources such as Patient, Encounter, Observation, MedicationRequest and Appointment, exchanged over a REST API in JSON or XML.
The same haemoglobin result as a FHIR Observation looks like this, shortened:
{
"resourceType": "Observation",
"status": "final",
"code": { "coding": [{ "system": "http://loinc.org", "code": "718-7", "display": "Hemoglobin" }] },
"subject": { "reference": "Patient/123456" },
"valueQuantity": { "value": 13.2, "unit": "g/dL" }
}
Developers can read it, query it with ordinary HTTP requests and test it with ordinary tools. Release R4, published in 2019, has normative parts that are stable, and it is the version most systems support today.
FHIR also comes with an ecosystem:
- Profiles and implementation guides that narrow the standard for a country or use case.
- SMART on FHIR, which uses OAuth 2.0 so apps can launch inside an EHR and access data with the user's permission.
- Terminologies such as LOINC and SNOMED CT for coding lab tests, conditions and procedures consistently.
Regulation is pushing adoption. In the United States, certified EHRs must provide FHIR APIs. In India, the Ayushman Bharat Digital Mission (ABDM) uses FHIR R4-based profiles for exchanging health records.
How they compare
| HL7 v2 | FHIR | |
|---|---|---|
| Style | Event messages | REST API over resources |
| Format | Pipe-delimited text | JSON or XML |
| Transport | Usually MLLP over TCP | HTTPS |
| Typical use | Inside hospitals: admissions, orders, results | Apps, patient access, data sharing between organisations |
| Consistency | Varies by site and vendor | Better, especially with profiles |
| Developer experience | Needs specialist tools and knowledge | Familiar web tooling |
Which one will you need?
It depends on who you connect to:
- Connecting to hospital systems on site? Expect HL7 v2 feeds for admissions and results, usually through the hospital's interface engine.
- Building a patient app or connecting to modern EHR APIs? Expect FHIR, often with SMART on FHIR for authentication.
- Exchanging records under a national programme such as ABDM? Expect FHIR with that programme's profiles.
Many products receive HL7 v2 from one side and expose FHIR on the other. A sensible architecture accepts both at the edge and stores data in one internal model, often based on FHIR resources, so the rest of the product never has to care where the data came from.
Planning an integration
- Get sample data early. Ask each partner for real (de-identified) messages or API responses. Specifications describe what is allowed; samples show what you will actually receive.
- Map fields explicitly. Write down how each source field maps to your model, including codes and units. Expect differences between sites.
- Validate on arrival. Reject or quarantine messages that fail validation, with clear errors, instead of storing partial data.
- Keep the original. Store each raw message alongside the parsed version, so you can reprocess when mappings change and trace any value back to its source.
- Monitor the feeds. An interface that silently stops is a clinical risk. Alert on missing heartbeats, error rates and unusual volumes.
- Protect the data. Encrypt in transit and at rest, restrict access by role, log every access, and keep test environments free of real patient records.
The short version
HL7 v2 is how hospital systems talk to each other today. FHIR is how modern applications access and share health data. Plan for both, normalise them into one model, and invest early in validation and monitoring. That is what keeps an integration reliable after launch.
We build clinical data platforms, EHR and device integrations for MedTech teams. If you're planning an integration, talk to us about your systems and data.