HL7 FHIR Integration: How to Connect Your Healthcare App to EHR Systems
HL7 FHIR integration step by step: SMART on FHIR sign-in, FHIR API calls, HL7 v2 mapping, testing and EHR go-live, with the 2026 US rules.

Your app works in the demo. Clinicians like it. Then the first hospital asks how it will read their patient charts, and the project stalls for months. The code is rarely the problem. Data access, authorization and the hospital’s own approval are three separate hurdles, and each one has its own rules.
This guide walks through HL7 FHIR integration from the first scoping call to go-live at a health system. It covers SMART on FHIR sign-in, FHIR API calls and HL7 v2 mapping. It also covers testing and the US rules that took effect on January 1, 2026. It is written for product owners, CTOs and engineers at healthtech companies. If you want one team to build the whole product, see our healthcare software development services.
Key takeaways
- FHIR is the API that apps use to read and write EHR data. HL7 v2 still carries most hospital system-to-system traffic, so many projects need both.
- In the US, certified EHRs must expose FHIR R4 with US Core 6.1.0 and SMART App Launch 2.0.0 since January 1, 2026.
- Decide the launch type early. An app inside the clinician’s EHR, a patient app and a backend job each use a different authorization flow.
- The sandbox is the easy part. Each health system reviews and turns on your app separately, and that step sets most timelines.
- Most FHIR integration delays come from patient matching, code mapping and rate limits. Plan for them before the first line of code.
What is HL7 FHIR integration?
HL7 FHIR integration means connecting your software to an EHR or another clinical system through FHIR, the data standard published by HL7 International. The app sends web requests to the EHR’s FHIR API and gets back records such as patients, lab results or appointments as JSON. Healthcare interoperability is the wider goal: data entered once is usable everywhere it is needed.
FHIR stands for Fast Healthcare Interoperability Resources. Each type of record is a “resource” with a fixed structure, such as Patient or Observation. The API follows ordinary REST rules, so a developer who has built against any modern web API can read a FHIR request. A typical setup looks like this: your app calls the FHIR API, and behind that API sit the EHR, the lab system and billing.
HL7 vs FHIR: what is the difference and which do you need?
HL7 is the organization and its family of standards. FHIR is its newest standard. In a hospital, “HL7” usually means HL7 v2 messages. This pipe-separated text format dates back to the late 1980s. It still moves admissions, orders and results between internal systems.
| Standard | Format | How data moves | Typical use | Best for |
|---|---|---|---|---|
| HL7 v2 | Pipe-delimited text segments | Messages pushed over a network connection, usually through an interface engine | Admissions, lab orders and results, scheduling feeds | Event feeds between systems inside one hospital |
| HL7 CDA / C-CDA | XML documents | Whole documents exchanged or downloaded | Discharge summaries, care transition records | Sending a complete summary to another provider |
| FHIR | JSON or XML resources | REST API calls on demand | Apps, patient access, analytics, data sharing | Any app that reads or writes specific records |

So the question is rarely HL7 vs FHIR. Most hospitals run both. FHIR serves the app that a clinician or patient opens. Behind the scenes, HL7 v2 keeps the lab system and the EHR in step. If your product only reads a patient’s chart, FHIR may be all you need. If it must react the moment a patient is admitted, you will probably consume HL7 v2 feeds as well.
FHIR R4, US Core and the 2026 baseline
Build on FHIR R4. FHIR R5 exists, but R4 is the version US EHRs expose and the version federal certification names. Under the ONC HTI-1 final rule (opens in a new tab), USCDI v3 became the data baseline for certified health IT on January 1, 2026.
The standardized API criterion, 170.315(g)(10) (opens in a new tab), spells out the pieces a certified EHR must support:
| Piece | What it is | Version in the 2026 baseline |
|---|---|---|
| FHIR | The base standard: resources, REST API, search | 4.0.1 (R4) |
| USCDI | The list of data classes, such as allergies, labs and clinical notes, that must be shareable | v3 |
| US Core | The US profile of FHIR: which fields are required and which code systems to use | 6.1.0, with later versions allowed |
| SMART App Launch | How an app signs in and gets permission to read data | 2.0.0 |
| Bulk Data Access | Export of data for many patients at once, for population work | 1.0.0, with 2.0.0 allowed |
The practical effect: basic reads from a certified US EHR are far more predictable than they were five years ago. Writes, custom fields and anything outside US Core still vary by vendor.
Outside the US, national profiles take the place of US Core. The UK uses its own UK Core profiles, and Germany publishes national FHIR profiles for hospital and practice software. On a European project, check the national profile before you fix any data model.
FHIR resources every healthcare app should know
FHIR R4 defines about 145 resource types. Most apps touch fewer than ten:
- Patient: name, birth date, identifiers such as the medical record number.
- Encounter: a visit or a hospital stay.
- Observation: lab results, vital signs, survey scores.
- Condition: diagnoses and problems on the problem list.
- MedicationRequest: prescriptions and medication orders.
- AllergyIntolerance: allergies and reactions.
- DocumentReference: notes and documents, including ones your app writes back.
- Practitioner: the clinician.
- Appointment: booked visits.
A trimmed Patient resource looks like this:
{
"resourceType": "Patient",
"id": "example-123",
"identifier": [{ "system": "https://hospital.example.org/mrn", "value": "MRN-0042" }],
"name": [{ "family": "Rivera", "given": ["Ana"] }],
"gender": "female",
"birthDate": "1984-03-12"
}
Pro tip: Match resources to the app type before scoping. A telemedicine app mostly needs Patient, Appointment and Encounter. A remote monitoring app lives on Observation. A patient portal pulls a little of everything, which is why its scope grows fastest.
How to connect your healthcare app to an EHR, step by step
Eight steps take an app from idea to a live EHR connection. The order matters, because each step narrows the choices for the next one.
1. Define the use case and the data scope
Every FHIR integration starts on paper. Write down which resources you read, which you write, and who triggers each call. A clinician opening your app mid-visit is a different case from a nightly job that pulls lab results. Keep the first release small. Read-only access to three resources goes live much sooner than two-way writes across ten.
2. Choose the launch pattern
SMART defines three ways in. An EHR launch starts your app from inside the clinician’s EHR screen, already pointed at the open patient. A standalone launch starts outside the EHR, for example a patient opening your mobile app. Backend services have no user at all and suit scheduled syncs and analytics.
3. Pick a FHIR server strategy
You can call each EHR directly, or put your own layer in between.
| Option | Good when | Watch out for |
|---|---|---|
| Call the EHR’s FHIR API directly | One or two EHRs, read-mostly, live data each time | Each vendor’s quirks end up in your app code |
| Your own FHIR server (for example HAPI FHIR) | You store and combine data from several sources | You now run, secure and back up a clinical database |
| Managed cloud service (Azure Health Data Services, AWS HealthLake, Google Cloud Healthcare API) | You want a FHIR store without running the servers | Cloud cost at volume, and the BAA with that provider |
| Integration engine (Mirth Connect, Rhapsody) | Many HL7 v2 feeds that need routing and translation | Another product to license, host and staff |
4. Implement SMART on FHIR authorization
SMART runs on OAuth 2.0. The app redirects to the EHR’s authorization server and the user signs in. Back comes an access token limited to the scopes the app asked for. The next section covers the flows and scopes.
5. Build the FHIR API calls
Use FHIR search parameters rather than pulling everything and filtering in your code. Follow the “next” links that the server returns for paging. Handle errors per request. A 401 means the token expired and a 403 means a missing scope. The response body usually carries an OperationOutcome resource that says what went wrong.
6. Map the data
If part of the data arrives as HL7 v2 messages, you must translate it into FHIR resources, or the other way round. This is where most effort hides. We cover it in its own section below.
7. Test in a sandbox, then validate
Epic and Oracle Health both run sandboxes with test patients. Ask any other vendor early what test access it offers. Run the official FHIR validator against everything you write, so a malformed resource fails in testing and never reaches a hospital.
8. Go live with each health system
Expect a security review, app configuration in the hospital’s environment and a short pilot with real users. Then add monitoring, alerting on failed calls and a rollback plan.
SMART on FHIR: authorization and launch flows
SMART on FHIR is the sign-in and permission layer on top of FHIR. The SMART App Launch guide (opens in a new tab) describes each flow, and certified US EHRs must support version 2.0.0.
- EHR launch: the EHR opens your app and passes a launch token. Your code swaps it for an access token that already knows the patient and the user.
- Standalone launch: your app sends the user to the EHR’s sign-in page, and the user picks the patient record or their own record.
- Backend services: a server-to-server flow with no user present. The guide prefers authentication with an asymmetric key pair over a shared secret.
Scopes say what the token may do. SMART v2 changed the syntax. A scope such as patient/Observation.rs lets the app read and search observations for the current patient only. user/Encounter.rs covers encounters the signed-in user may see, and system/ scopes belong to backend services.
Pro tip: Ask for the smallest set of scopes your first release needs. A hospital security team reads that list line by line, and a short one is easier to approve.
Authorization is only one control. Data must stay encrypted while stored and while it travels. Your app also needs its own user roles, audit logs and a clear record of patient consent. Our guide to a HIPAA compliant chatbot walks through those controls for a product that handles patient data.
FHIR API integration: a worked example
This is an illustrative example, not a client project. Say your app shows a patient’s recent blood pressure readings and saves a visit summary back to the chart.
First, the read. With a valid token, the app searches for vital signs:
GET [fhir-base]/Observation?patient=example-123&category=vital-signs&code=http://loinc.org|85354-9&_sort=-date&_count=20
Authorization: Bearer [access-token]
Accept: application/fhir+json
The server returns a Bundle of Observation resources, newest first, with a “next” link if more pages exist. The LOINC code 85354-9 is the blood pressure panel, and each reading holds its systolic and diastolic values as separate components.
Next, the write. Here the app posts a DocumentReference that holds the visit summary and points at the patient and the encounter. Many EHRs accept notes only in specific document types, so check the vendor’s documentation before you design this screen.
When a call fails, read the status code first. A 404 on a search usually means a wrong base URL, while an empty Bundle means the search worked and found nothing. A 422 with an OperationOutcome tells you which field the server rejected.
The same pattern sits behind AI note-taking tools. Our guide to AI clinical documentation software explains why the EHR write-back comes last in that kind of build.
HL7 to FHIR mapping: converting legacy feeds
Here is a typical EHR integration case. A lab system sends ORU result messages and the hospital sends ADT admission messages. Your product works in FHIR, so each message has to become one or more resources.
| HL7 v2 segment | Holds | Usual FHIR resource |
|---|---|---|
| PID | Patient identity and demographics | Patient |
| PV1 | Visit details, location, attending doctor | Encounter |
| ORC / OBR | The order and the requested test | ServiceRequest, DiagnosticReport |
| OBX | Each individual result value | Observation |
| AL1 | Allergies | AllergyIntolerance |
| DG1 | Diagnoses | Condition |
You can run the translation in an interface engine such as Mirth Connect or Rhapsody, use an open source converter, or write the mapping yourself. Engines suit hospitals with dozens of feeds. A product with two or three feeds often gets by with a small mapping service it controls. We are building a similar layer for HUSK, where one sign-in opens five separate wellness products. Our software integration services cover that kind of work.
Expect the same traps on every project. Local codes do not match LOINC or SNOMED CT. One hospital fills a field that another leaves blank. Custom “Z” segments appear, and dates arrive without time zones.
Pro tip: Collect a week of real, de-identified messages from each source before you write the mapping. A sample file from the vendor shows the ideal format, and production traffic shows what you will actually get.
Connecting to specific EHRs: Epic, Oracle Health and others
Each large EHR vendor runs its own developer program. The FHIR standard is shared, but sign-up, sandboxes and the route to production differ.
| EHR | Developer program | Sandbox | Going live |
|---|---|---|---|
| Epic | Epic on FHIR, a free resource for developers | Yes, with client registration | Through each Epic customer. Showroom is Epic’s app listing site |
| Oracle Health (Cerner) | Millennium Platform APIs, apps registered in code Console | Yes, with sample patients | The client health system requests provisioning of your app for its tenant |
| athenahealth | Developer portal with a FHIR R4 implementation guide | Check the portal for current access | Through the practice, with a marketplace partner program for listed apps |
Epic FHIR API: the current path
Start at Epic on FHIR (opens in a new tab). Create an account, register your app as a client, and build against the testing sandbox. The Epic FHIR API follows the same R4 and SMART rules as everyone else, so code written well against the standard needs few Epic-only changes.
The slow part comes after the sandbox. Every Epic customer runs its own environment. Your app goes through review and activation at each health system before real patients flow through it. Plan one go-live per customer, not one go-live for Epic. A listing on Showroom helps buyers find your app, and you can ask Epic for one through the developer site.
The route at Oracle Health is similar. Its app provisioning guide (opens in a new tab) has the client request a tenant ID and then ask Oracle to provision your app against it. Oracle also lists optional paid programs, which you do not need to build and deploy an app.
Testing, validation and go-live checklist
Testing an EHR integration starts in the vendor sandbox. Test there first, then against a copy of the hospital’s own configuration if they offer one. Real hospitals add custom fields and local codes the sandbox never shows.
- Every resource you write passes the official FHIR validator against US Core.
- Searches handle empty results, paging and the server’s rate limits.
- Expired tokens, revoked access and missing scopes all fail cleanly with a clear message.
- Load tests run at the busiest hour you expect, plus a margin.
- A penetration test covers the app and the integration service.
- The audit trail shows which user opened or edited each patient record, with a timestamp.
- Alerts fire on failed calls and stalled feeds, and someone is on call to act on them.
- A rollback plan exists, and the hospital knows the contact for each issue type.
Our software testing services page explains how we plan and run this kind of testing.
Common FHIR integration challenges and how to avoid them
- Every EHR reads the standard a little differently. Test each vendor separately and keep vendor quirks in one adapter layer, so they do not spread through your code.
- Rate limits and slow searches. Cache data your app reads often, and use Bulk FHIR for large exports.
- Patient matching. Names and birth dates collide. Match on identifiers where you can, and send uncertain matches to a person for review.
- Codes that do not line up. Map local lab codes to LOINC and diagnoses to SNOMED CT or ICD-10, and keep the mapping table under version control.
- Security review takes longer than the build. Prepare your security documents, data flow diagram and scope list before the hospital asks.
- Consent and privacy. Record what each patient agreed to share, and sign a business associate agreement with every vendor that touches the data.
How long does FHIR integration take and what does it cost?
Three things decide the timeline: the number of EHRs, read-only versus two-way, and whether HL7 v2 feeds are involved. A read-only connection to one EHR sandbox is a short piece of work. Two-way writes across several vendors, with legacy feeds to map, run much longer. Then every hospital’s own review adds weeks, and that part is outside your control.
For budgets, our healthcare software development cost guide breaks down integration next to the other features of a medical product. Once we have scoped the work with you on a free call, the price comes in writing with the scope it covers.
How CodesClue approaches FHIR integration
We start with the data scope and the launch pattern, because those two choices decide everything after them. Then we build against the vendor sandbox and validate every resource we write before a hospital sees it. A privacy and compliance review runs before launch. Before we open your codebase, we sign an NDA. A BAA follows whenever your project needs one.
Engineering happens in Ahmedabad, and CodesClue runs two more offices, one in the USA and one in Germany. For a sense of pace, HEOS, a platform for healthcare leaders, reached a working product in three months, built by a team of five. Therapix.AI, an AI tool for clinical notes, shows how we handle patient data and clinician review in a regulated product.
Plan your HL7 FHIR integration before you write code
A working HL7 FHIR integration comes from early decisions. Settle the data, the launch type, the server setup and the approval route at each health system. Build on FHIR R4, US Core and SMART v2, map legacy feeds with care, and budget real time for each hospital’s review.
If you are planning an EHR connection now, book a 30-minute call with our engineers. Bring your EHR list and the data you need. On the call, an engineer maps the likely route and the steps that tend to slow it down. Or read more about our healthcare software development work first.
HL7 FHIR integration: questions teams ask
Which FHIR version should I build on, R4 or R5?
Build on R4 for anything that connects to a US EHR today. Federal certification names FHIR 4.0.1, so that is the version Epic, Oracle Health and other certified systems expose. R5 adds useful features, but few production EHRs offer it. Keep your data layer clean and version-aware, so a later move to a newer release touches one part of the code.
Do I need my own FHIR server?
Not always. An app that reads live data from one or two EHRs can call their APIs directly and store very little. You need your own FHIR store when you combine records from several sources, run analytics, or keep history the EHR does not. A managed cloud service saves you running the database, but it adds cost at volume and needs its own BAA.
Is SMART on FHIR the same thing as FHIR?
They are two layers. FHIR defines the data and the API. SMART on FHIR defines how an app signs in, which patient it may see and which actions its token allows. You need both for an app that clinicians open inside the EHR or that patients sign in to. A backend job also follows SMART rules, through the backend services flow with a key pair.
Does FHIR integration make my app HIPAA compliant?
No. FHIR and SMART control how data moves and who may request it. HIPAA covers the whole product, from risk analysis and encryption to access controls and audit logs. It also needs staff training and an agreement with every vendor that handles the data. A secure FHIR connection is one control inside that program. No product is HIPAA certified, so be wary of anyone who sells one that way.
Can a patient app pull records from a US hospital through FHIR?
Yes, in most cases. Certified US EHRs must support patient access for standalone apps, so a patient can sign in with their portal account and approve your app. Each EHR still asks you to register the app first. The patient sees only their own record, and your scopes decide which parts of it your app receives.



