FHIR Facade Architecture Guide: FHIR for Legacy EHR Integration and Legacy Healthcare Systems
CTO & Co-Founder
CTO & Co-Founder at Nirmitee.io. Architects healthcare integrations across FHIR, SMART on FHIR, ABDM and NHCX, writing from production experience taking hospital software from sandbox to go-live.

Updated October 2026
A FHIR facade is a layer that puts a FHIR API on top of a system that does not speak FHIR, such as a legacy EHR, an HL7 v2 message store or a relational database. The data stays where it is: the facade translates each FHIR request into a query the old system understands and maps the answer back into FHIR resources.
That makes it the usual first option for FHIR for legacy EHR integration when the old system is staying and apps mostly need to read from it. It is a poor fit for bulk export, heavy search or a system you are about to retire. Our FHIR integration services team builds both facades and repositories, and this guide covers how to choose, the FHIR facade architecture, a tested code example and the mistakes that cost the most time.
If the legacy system is on its way out, our healthcare data migration services plan the facade and the move together.
What is a FHIR facade?
A FHIR facade is a FHIR server with no FHIR database behind it. It exposes a FHIR R4 API for the resources and searches you choose to support, declares them in its CapabilityStatement, and answers from the source system at request time.
This answers the question many teams start with: how do we expose legacy clinical data through a FHIR API without moving it? You add a translator in front of the source. Nothing is migrated and clinical staff keep their workflows, which is why facades come up so often in plans for healthcare legacy systems. HAPI FHIR's documentation describes the same idea for its Plain Server: a common FHIR layer on top of a series of existing data sources.
FHIR facade architecture diagram
Every facade does three jobs. It receives FHIR REST calls such as GET /Patient and routes each one to the right adapter. It maps legacy data to FHIR, so a name in HL7 v2 PID-5 becomes a Patient.name HumanName. Then it assembles valid resources, wraps them in Bundles and returns errors as OperationOutcome resources.
How a FHIR facade handles a request
A facade handles a request in seven steps, and step 3 is where most of the design work sits. Here is GET /fhir/Patient?family=Smith from start to finish.
- The client sends a standard FHIR REST request to the facade.
- The facade checks the SMART on FHIR token and its scopes, for example
patient/Patient.rs(patient/Patient.readin SMART v1). - It parses the search parameters and translates them, for example to
WHERE last_name ILIKE 'Smith%'or an HL7 v2 QBP query. - It runs the query against the source system.
- It maps the results to FHIR resources.
- It wraps them in a searchset Bundle with paging links and a self link.
- It returns the response with the right HTTP status and headers.
What is inside a production FHIR facade
A production facade has six parts, and the mapping engine is the hardest of them. Mapping work grows with every resource type and search parameter you add.
| Component | What it does | What to watch |
|---|---|---|
| API gateway or FHIR server shell | HTTP routing, JSON or XML, the CapabilityStatement | Support for _format, _summary and other common parameters |
| SMART on FHIR auth | OAuth 2.0, token checks, scope enforcement | Which launch types your clients need: standalone, EHR launch, backend services |
| Resource router | Sends each resource type to the right adapter | Patient may come from the MPI, Observation from the lab system, medications from pharmacy |
| Mapping engine | Translates between FHIR and legacy data models | Local codes need crosswalks to LOINC, SNOMED CT and similar code systems |
| Legacy adapters | Database, HL7 v2 MLLP, SOAP and REST connections | Connection pooling, retries and each system's own errors |
| Audit logger | Records who read what, when and under which authorization | Part of your HIPAA access logging, so plan it from the start |
Code example: a Python FastAPI facade
This small facade puts a FHIR Patient search on a legacy PostgreSQL table.
from fastapi import FastAPI, Query, Request
from fastapi.responses import JSONResponse
from typing import Optional
from urllib.parse import urlencode
import asyncpg
app = FastAPI(title="FHIR Facade", version="R4")
# Search parameters this facade supports. List the same ones in the CapabilityStatement.
SUPPORTED_PARAMS = {"family", "given", "_id"}
# The legacy system stores one letter. FHIR wants a code from its gender value set.
GENDER = {"M": "male", "F": "female", "O": "other"}
async def get_db():
return await asyncpg.connect(
host="legacy-db", database="hospital_ehr",
user="fhir_readonly", password="***"
)
def map_patient_to_fhir(row: dict) -> dict:
"""Map a legacy patient table row to a FHIR Patient resource."""
return {
"resourceType": "Patient",
"id": str(row["patient_id"]),
"meta": {"lastUpdated": row["modified_at"].isoformat()},
"identifier": [{
"system": "http://hospital.example.org/mrn",
"value": row["mrn"]
}],
"name": [{
"use": "official",
"family": row["last_name"],
"given": [row["first_name"]]
}],
"gender": GENDER.get(row["sex"], "unknown"),
"birthDate": row["dob"].isoformat()
}
def unsupported_search(names: list) -> JSONResponse:
"""400 with an OperationOutcome for search parameters we do not support."""
return JSONResponse(status_code=400, content={
"resourceType": "OperationOutcome",
"issue": [{
"severity": "error",
"code": "not-supported",
"diagnostics": f"Unsupported search parameter(s): {', '.join(sorted(names))}"
}]
})
@app.get("/fhir/Patient")
async def search_patient(
request: Request,
family: Optional[str] = Query(None),
given: Optional[str] = Query(None),
_id: Optional[str] = Query(None, alias="_id")
):
# The R4 spec says servers SHOULD ignore unsupported parameters.
# "Prefer: handling=strict" asks for an error instead.
unknown = [k for k in request.query_params if k not in SUPPORTED_PARAMS]
if unknown and "handling=strict" in request.headers.get("prefer", ""):
return unsupported_search(unknown)
# Translate FHIR search parameters to SQL. FHIR string search is
# case-insensitive and matches the start of the value, so match a prefix.
conditions, params = [], []
if family:
conditions.append(f"last_name ILIKE ${len(params)+1}")
params.append(f"{family}%")
if given:
conditions.append(f"first_name ILIKE ${len(params)+1}")
params.append(f"{given}%")
if _id:
conditions.append(f"patient_id = ${len(params)+1}")
params.append(int(_id))
where = " AND ".join(conditions) if conditions else "1=1"
db = await get_db()
rows = await db.fetch(f"SELECT * FROM patients WHERE {where} LIMIT 50", *params)
await db.close()
# The self link carries only the parameters we applied, so the client can see what was ignored.
base = str(request.base_url).rstrip("/") + "/fhir/Patient"
applied = [(k, v) for k, v in request.query_params.multi_items() if k in SUPPORTED_PARAMS]
return {
"resourceType": "Bundle",
"type": "searchset",
"link": [{"relation": "self", "url": f"{base}?{urlencode(applied)}"}],
"entry": [{
"fullUrl": f"{base}/{row['patient_id']}",
"resource": map_patient_to_fhir(dict(row)),
"search": {"mode": "match"}
} for row in rows]
}
@app.get("/fhir/metadata")
async def capability_statement():
return {
"resourceType": "CapabilityStatement",
"status": "active",
"date": "2026-10-30",
"kind": "instance",
"fhirVersion": "4.0.1",
"format": ["json"],
"rest": [{
"mode": "server",
"resource": [{
"type": "Patient",
"interaction": [{"code": "search-type"}],
"searchParam": [
{"name": "family", "type": "string"},
{"name": "given", "type": "string"},
{"name": "_id", "type": "token"}
]
}]
}]
}
FHIR string search is case-insensitive and matches the start of a value, so family=Smi returns Smith and not Nesmith. The R4 search specification says servers should generally ignore parameters they do not support, and that a client can ask for an error with Prefer: handling=strict. The code does both, and its self link shows only the parameters it applied.
We ran this example on 30 October 2026 with pytest, using a stubbed database and synthetic rows. All 5 tests passed, covering the prefix match, the gender mapping, ignored parameters, the strict 400 response and the metadata endpoint. It has not run against a real PostgreSQL server or a FHIR validator. A production version also needs connection pooling, paging, error handling and SMART on FHIR authorization.
FHIR facade vs repository vs hybrid: how to choose your FHIR architecture
Choose a facade when the source system is staying and clients mostly read small amounts of current data. Choose a repository when you need bulk export, full search or a FHIR-native write path, and a hybrid when different data has different needs.
| Question | FHIR facade | FHIR repository | Hybrid |
|---|---|---|---|
| Where does data live? | In the source system | Copied to a FHIR store | Some copied, some in the source |
| How current is it? | As current as the source | As current as the last load | Varies by resource |
| How fast are reads? | Limited by the source system | Set by the FHIR store | Fast for copied data, source speed for the rest |
| How much FHIR search? | Only what you map | Whatever the server supports | Wider for copied data, limited for live data |
| Writes | Hard: each write must map back to the source | Native to the FHIR store | Needs an agreed path back to the source of record |
| Main risk | Load on the source system | The copy drifting from the source | Running and reconciling both paths |
| Best for | Read-heavy access to systems that are staying | Analytics, bulk export, new systems | Mixed workloads and gradual migration |
Worked example: a payer's claims system
Take an illustrative payer whose claims live in a legacy adjudication system. Apps search by _lastUpdated to pick up changes, and the payer also wants bulk $export for analytics.
With a live facade, every _lastUpdated search hits the claims system. If that system has no reliable last-modified time on every row a resource is built from, the facade cannot answer correctly. A bulk export means reading and mapping every claim at request time, which can load production for hours.
A FHIR store fed from the claims system answers both natively. The cost is that data is only as current as the last load, and you have to reconcile the copy against the source.
The likely answer is a hybrid: a live facade for single-member reads that must match the claims system, and a FHIR store for change search and bulk export. Write down the freshness you agree on, for example "changes visible within 15 minutes", so everyone tests against the same target.
Which legacy systems a facade can wrap
A facade can wrap any source you can query, but the effort differs a lot by source. The ratings below are our judgment of relative difficulty, and your schema can move a source up or down.
| Source | Difficulty | Main challenge |
|---|---|---|
| HL7 v2 message store | Medium | Segments do not map one to one. OBX can feed Observation, DiagnosticReport or DocumentReference depending on context. Our HL7v2 facade implementation guide covers the gateway, message store and search limits. |
| Relational database | Low to medium | Every schema is different, so mapping is built per deployment. |
| C-CDA documents | Medium to high | C-CDA is organized by document section and FHIR by resource, so each section needs parsing. |
| X12 EDI (837, 835, 278) | High | Financial transactions with nested loops do not line up with clinical resources. |
| Proprietary EHR APIs | Varies | Each vendor has its own data model, authorization and rate limits. Epic, Oracle Health and MEDITECH each need their own adapter. |
| Flat files and batch | Low to map, harder to keep current | You have to store the data and detect changes between loads, so this is closer to a small repository. |
What we learned from a multi-EHR FHIR facade
In one multi-EHR FHIR facade case study, we built a single FHIR R4 API for a healthcare data platform company, in front of Epic, Oracle Health (Cerner) and athenahealth. All three support FHIR R4, but authorization, data models and resource coverage differ. athenahealth needed the most adapter work, code system translation never finished, and caching rules had to differ by resource. EHR version drift was a real problem too, which is a good reason to test each adapter again after every vendor upgrade.
What regulations ask for, and what a facade does not settle
US rules ask for FHIR APIs from certain payers and from certified health IT, and neither rule mandates a facade. A facade is one way to build the API, and it has to meet the same implementation guides as any other.
The CMS-0057-F fact sheet covers Medicare Advantage organizations, state Medicaid and CHIP fee-for-service programs, Medicaid managed care plans, CHIP managed care entities and QHP issuers on the Federally Facilitated Exchanges. It sets two groups of dates:
- In 2026: prior authorization decisions within 72 hours for urgent requests and 7 calendar days for standard ones (QHP issuers on the Exchanges are excluded), specific denial reasons, and public prior authorization metrics, first due by March 31, 2026.
- From January 1, 2027, generally: the Patient Access, Provider Access, Payer-to-Payer and Prior Authorization APIs. Exact dates depend on payer type, and drug prior authorizations are excluded.
Hospitals are not directly covered by these API requirements. ONC's certification program is aimed at health IT developers, so a facade you run for your own apps does not need certification unless you plan to certify it. ONC's HTI-5 final rule, issued in October 2026, changes the certification criteria, so check its current list before you plan around any one criterion. If you are a payer planning for these dates, see our CMS-0057-F interoperability suite.
Outside the US, the 2025 State of FHIR survey by HL7 and Firely (expert input from 82 participants across 52 countries) reports FHIR mandated or recommended in 73% of countries with health data regulation.
How to integrate FHIR across legacy hospital systems: build or buy
You have four routes, and the right one depends on your engineers and your existing platform. Not every "FHIR server" is a facade: some products are built to store FHIR data, so check for a way to plug in your own data access.
| Route | Examples | Facade support | Fits teams that |
|---|---|---|---|
| Open-source framework | HAPI FHIR Plain Server (Java) | Built for an arbitrary backend you provide. You write the data access code. | Have Java developers and want control |
| Commercial platform | Firely Server, Smile CDR, InterSystems IRIS | Firely facade plugins, Smile CDR Hybrid Providers, InterSystems FHIR facade | Want vendor support and accept a license cost |
| Cloud FHIR service | Azure Health Data Services, AWS HealthLake, Google Cloud Healthcare API | Mainly FHIR stores, so they fit the repository or hybrid side. Azure's $convert-data converts HL7 v2 and C-CDA to FHIR. | Already run on that cloud and accept a copy of the data |
| Custom build | FastAPI, Express, Go | Whatever you write, including all of the FHIR behavior | Need one narrow API on an unusual system |
Our FHIR server comparison goes deeper on the fhir server architecture of the open-source, commercial and cloud routes. If you are hiring, a FHIR architect should own the CapabilityStatement and the search scope before anyone writes mappings.
Roll it out one resource group at a time
Start with Patient and add resources only when a client needs them, because each one brings its own mapping and terminology work. This is an order of work. Durations depend on your source system.
- Patient: the base of nearly every FHIR interaction, with simpler mapping.
- Clinical core: Condition, AllergyIntolerance and the medication resources.
- Diagnostics: Observation and DiagnosticReport, where varied local codes make mapping harder.
- Documents and visits: DocumentReference, Encounter and Procedure.
- Advanced features: writes and subscriptions, plus a fresh look at whether busy resources should move to a hybrid model.
Common FHIR facade mistakes
Most facade failures come from taking on too much scope or finding the source system's limits late.
Mapping everything at once
FHIR R4 lists about 145 resource types and no client needs all of them. Pick the ones your use case needs, using US Core profiles as a guide if you serve US clients.
Underestimating search
Each FHIR search parameter needs its own translation rule. Patient?name=Smith is simple. Observation?code=http://loinc.org|85354-9&date=gt2024-01-01&_include=Observation:patient is far harder, so decide which searches you will support before you promise them.
An inaccurate CapabilityStatement
Clients use /metadata to learn what your server can do. If it claims more than the facade supports, client apps fail in ways that are hard to trace, and conformance tests fail too.
No plan for load on the source
A pure facade queries the legacy system on every request, and a busy resource can overwhelm an old database. Use connection pooling, enforce _count limits, and resolve _include only when asked. Use HTTP caching headers such as ETag where you can. Any cache holding patient data needs the same security and audit controls as the source.
Skipping terminology mapping
Legacy systems often store local codes such as "Lab code 4532" where FHIR clients expect LOINC or SNOMED CT. Without crosswalk tables, the API returns valid FHIR that clients cannot interpret.
Adding authorization last
Modern FHIR clients expect SMART on FHIR, and retrofitting it leaves gaps. Design scopes and audit logging from the first endpoint.
How to test a FHIR facade
Test it against the FHIR specification and against your source data, because passing one says nothing about the other. A validator shows that a resource is well formed. It cannot show that the patient's allergy is the right one, so compare a sample of mapped records with the source system as well.
Inferno runs conformance tests against FHIR servers, and we use it on our own open-source work. Our open-source headless EHR passed 47 of 47 ONC (g)(10) SMART App Launch Standalone Patient App tests on 27 October 2026. That result covers the SMART group only, not full (g)(10), and that project is an EHR rather than a facade. Check authorization the same way on a facade.
Will a FHIR facade survive the move to R6?
Yes, if mapping code is kept apart from the adapters, because a new FHIR version then changes only the output mapping. FHIR R6 has reached normative balloting, and we found no final publication notice when we checked on 30 October 2026. Our FHIR R6 guide tracks what changes. A repository may also have to migrate stored data, which a facade avoids.
Planning a FHIR facade?
Bring us your source system and the first client you need to serve, and we will tell you whether a facade fits. Our FHIR facade development and API build work is done by a team that is ISO 27001:2022 certified and signs BAAs, and has built 350+ Mirth Connect interfaces. We have also run a SMART on FHIR app against the Epic and Oracle Health developer sandboxes.
Ready to scale?
Talk to our healthcare engineering team about building, integrating, and shipping faster.
Frequently Asked Questions
What is a FHIR facade?
How do we expose legacy clinical data through a FHIR API?
How do we integrate FHIR standards across legacy hospital systems?
What is the difference between a FHIR facade and a FHIR repository?
What are the drawbacks of a FHIR facade?
What components make up a FHIR facade architecture?
Does CMS-0057-F require a FHIR facade?
Which tools can build a FHIR facade?


