Most FHIR integrations pass their sandbox demo. The trouble starts months later, when a second health system connects, a token expires at night, or a write-back lands on the wrong encounter.
Those failures are rarely about the FHIR specification. They come from architecture decisions made in the first sprint, when one EHR and one test patient made everything look simple. This post lists the mistakes we find most often when we are asked to rescue an integration, and what to build instead.
What are the most common FHIR integration architecture mistakes?
Connecting to Epic over FHIR?
Our Epic FHIR capabilities page lists the APIs, scopes and bulk data options a build has to plan for.
The most common FHIR integration architecture mistakes are treating the EHR's API as a database to copy, sharing one token across every user and site, skipping profile validation, ignoring paging and rate limits, and writing back without an idempotency key. Agnotic Technologies sees each of these break integrations that worked well in the sandbox.
None of them shows up in a single-site pilot. All of them show up when volume, a second EHR or a real clinician arrives.
Why is copying the EHR on a timer a mistake?
Teams often poll every Patient, Encounter and Observation into their own store every few minutes. It works for ten patients and fails at ten thousand, because the EHR throttles the calls and the copy drifts out of date.
- What it looks like: a cron job that pages through whole resource types and overwrites a local table.
- Fix: fetch on demand at the moment of use, cache with an expiry, and use the EHR's bulk export or event feed for population work.
- Rule of thumb: keep a local copy only of data your product owns or must analyze, and record where each value came from.
Why does one shared token cause trouble?
A single system token used for every request hides who did what. When an audit asks which user read a chart, the logs only show the integration account.
The SMART App Launch implementation guide uses OAuth 2.0 and OpenID Connect so that apps can launch from an EHR with the user's and patient's context and only the access scopes they were granted.
- User-facing actions: launch with the clinician's context so the EHR scopes and logs the request to that person.
- Back-end jobs: use a separate client with the narrowest system scopes the job needs.
- Per-site clients: register a client per health system, so one site revoking access does not stop the others.
What happens when you skip profile validation?
Base FHIR resources allow a lot. The EHR you connect to sends a profiled subset, and your code should check incoming data against that profile instead of assuming every field is present.
US Core is the HL7 FHIR implementation guide that profiles FHIR resources for the USCDI data classes used in the United States.
Validate at the edge, log what fails, and decide per field whether a missing value blocks the workflow or only hides a screen element. A silent null in a medication list is worse than a visible error.
How do paging and rate limits break integrations?
They break them quietly. A search returns the first page, the code never follows the next link, and the product shows a partial list as if it were complete.
- Always follow Bundle next links until they stop, and cap the total so one patient cannot stall a queue.
- Back off on 429 and 503 responses and retry with jitter, instead of hammering the endpoint.
- Track calls per site per hour, so you see a limit approaching before the EHR team calls you.
How do identifiers get mixed up?
A FHIR resource id is local to one server. The medical record number, the enterprise id and the id in your own database are different things, and a mapping table that mixes them will eventually merge two people.
Store the system and value of every identifier, keep the source server with each resource id, and never use a resource id from one EHR to look up a record in another.
Hard-coding one vendor's extensions
Each EHR adds its own extensions and code systems. If your parsing logic reads those directly, the second vendor means a rewrite.
Put vendor-specific reads behind an adapter per EHR, and keep your internal model in terms of the profile, not the vendor. Our Epic FHIR API guide covers the Epic-specific side; the same pattern applies to Oracle Health (Cerner) and athenahealth.
What goes wrong with write-back?
Write-back fails when the same note or result is posted twice, or posted to the wrong encounter. Both happen when a retry runs after a timeout that actually succeeded.
- Idempotency: send a client-generated identifier with each write and check for it before retrying.
- Context check: confirm the patient and encounter on the server just before the write, not only when the screen opened.
- Provenance: record which user and which version of your app created the resource.
- Reconciliation: run a daily job that compares what you sent with what the EHR holds.
Terminology, logging and environments
- Terminology in code: mapping local codes to LOINC or SNOMED CT inside if statements. Fix: a versioned mapping table with an owner.
- PHI in logs: full request and response bodies in application logs. Fix: log resource type, id and status, and send payload capture to a restricted store only when debugging.
- Sandbox equals production: assuming the vendor sandbox matches a live site. Fix: a per-site configuration record for endpoints, scopes, enabled resources and known quirks.
How do you find these mistakes in a live integration?
Start from the evidence the integration already produces: its logs, its call counts and its own database. A short audit of those three sources usually shows which mistakes are present before anyone reads the code.
- Call pattern: if outbound requests spike on a fixed schedule rather than following clinician activity, the integration is copying the EHR on a timer.
- Audit trail: if the EHR's access log shows one client name for every chart view, tokens are shared.
- Duplicates: query for two resources with the same content and patient created seconds apart, which points to unsafe retries.
- Identifier table: look for rows where one local person maps to resource ids from more than one server without a typed system.
- Error handling: search the code for FHIR responses read without checking for a next link or an OperationOutcome.
Rank what you find by clinical risk, not by effort. A wrong-encounter write-back outranks a slow sync, even if the sync is easier to fix.
How should you test a FHIR integration before go-live?
Test it against the conditions that broke the integrations described above, not only the happy path in a vendor sandbox. A test plan that only checks one patient and one login proves very little.
- Volume: run the busiest screen and the nightly jobs against a realistic number of patients and watch call counts.
- Expiry: let tokens expire mid-session and confirm the app refreshes or asks the user to sign in again.
- Partial data: feed resources with missing optional fields and confirm the screens degrade clearly.
- Failure: return 429, 500 and timeout responses from a stub and confirm retries stop at a sensible limit.
- Duplicates: replay the same write twice and confirm only one resource is created.
- Second vendor: repeat the core flows against another EHR's sandbox.
Keep these as automated tests in the pipeline, so a later change that reintroduces a mistake fails before it reaches a clinic.
Who should own the integration after launch?
Name one owner per connected site, plus one engineering owner for the integration code. Integrations fail quietly, and without an owner nobody notices until a clinician reports missing data.
The owner watches error rates, token failures and queue depth on a dashboard, keeps the per-site configuration record current, and joins the EHR team's upgrade planning. EHR upgrades change endpoints, scopes and data more often than teams expect, and the integration owner should hear about them before go-live weekend, not after it.
Write a short runbook for the common failures: a site revokes the client, a certificate expires, an endpoint moves, a resource stops returning a field. Each entry should say how to detect it, who to call at the site and how to recover.
What are FHIR integration architecture best practices?
The best practices mirror the mistakes: fetch on demand, scope tokens to people, validate profiles, page and back off, keep identifiers typed, isolate vendor code, and make every write safe to retry.
Write these down as a one-page integration contract before the build, and test each one with a second EHR's sandbox even if the first customer only uses one. That second sandbox is the cheapest way to find the hard-coded assumptions.
How Agnotic can help
Agnotic builds and repairs FHIR integrations for product teams and health systems. A typical engagement starts with a review of your current integration against the list above, then fixes in order of risk: write-back safety first, then tokens and identifiers, then sync design.
Build your FHIR integration with Agnotic
We design the adapters, token model and write-back checks before the second site connects.
Related reading on Agnotic
The full FHIR project path, target design and Epic specifics.


