Setting up the OpenEMR FHIR R4 API

A practical guide to enabling OpenEMR's FHIR R4 API, exposing it safely over TLS, and testing it against the capability statement before any app connects.

On this page

How to set up the OpenEMR FHIR R4 API safely

If your integration team needs apps or an exchange partner to read OpenEMR data through FHIR R4, the safe path is to enable the API deliberately, expose only the endpoints you need over HTTPS, and test the server's published capability before any client connects. OpenEMR's FHIR API implements FHIR R4 (4.0.1), US Core 8.0 and SMART on FHIR v2.2.0, with OAuth 2.0 and OpenID Connect, PKCE for public apps and granular scopes. This section covers enabling, exposing and testing the API. Who may obtain tokens and what each client can read are covered in the sibling pages on OAuth2 client registration and launching SMART on FHIR apps.

OpenEMR is licensed under the GNU GPL v3.0 and is free to download and run, and there is no paid edition of the software. That means the cost of this work is in your own staff time, your infrastructure and any outside help you hire, not in a license fee. Start by confirming the exact OpenEMR version you run, because the FHIR API has received security fixes in recent releases. The 8.3.0 and 8.4.0 releases fixed vulnerabilities in FHIR APIs, so confirm your version against the OpenEMR releases page before you enable anything. Then confirm the PHP and database versions your release requires, since recent releases need PHP 8.3 or later.

Before you expose the API, decide the network boundary. The HTTPS-only rule from the Securing OpenEMR guide is the baseline: allow only HTTPS, consider opening only port 443, and block direct web access to sites/*/documents. Remove setup.php and other admin scripts after installation. In a multisite deployment, confirm the base URL for each site separately, because each site has its own FHIR endpoint and its own exposure risk. Ask your security team to review the Securing OpenEMR guide against your hosting setup, and test the result from outside your network to confirm that only the intended paths answer. Finally, retrieve the capability statement from each site's metadata endpoint and compare it with the resources you approved. Any resource or operation you did not approve should be removed or blocked at the gateway, and the check should be repeated after every upgrade.

What you need before enabling the FHIR API

Enabling the FHIR API touches the application release, the database, the network edge and the people who sign off on access. Settle these items before anyone flips the connector setting, because each one decides how the API is exposed and who can change it later. Confirm each point with your own environment and the current release notes.

Supported 8.x release line

Start from a current 8.x release that carries the latest security fixes, not whatever version is already running. Recent 8.x releases fixed security issues in the FHIR APIs, so an older install may expose the API without those fixes. Check the release line and patch level against the releases page before planning, and record the exact version you will deploy so the test results can be tied to it.

Latest release in sources
8.4.1
OpenEMR releases

PHP and database platform

Recent OpenEMR releases require PHP 8.3 or later and run on a MySQL- or MariaDB-compatible database. Confirm the exact PHP and database versions the release you chose supports, since minimums change between releases. Check that your hosts, container images and managed database service all match those minimums before the change window.

Docker or host deployment choice

Decide whether OpenEMR runs from the project's Docker options or on a traditional host, because that choice sets who patches the PHP runtime, the web server and the database client. Docker images move the runtime into a build pipeline you must own. Write down the choice now, since it determines where configuration, the sites directory and TLS termination live.

TLS certificate and DNS name per site

Each OpenEMR site that exposes the FHIR API needs its own DNS name and a valid TLS certificate, because the FHIR base URLs are built from the site's address. Apps and clients will reject mismatched or self-signed certificates unless you deliberately manage trust. Plan certificate issuance, renewal and the owner of the private keys before testing begins.

Firewall and reverse proxy ownership

Name one team that owns the firewall rules and the reverse proxy in front of OpenEMR. The Securing OpenEMR guidance favors allowing only HTTPS, and considers opening only port 443, so the edge configuration decides what the API exposes. Agree who approves changes to allowed sources, path routing and header forwarding before the connector is enabled.

Securing OpenEMR guide

Named administrator account

Create a named administrator account for the person who will configure the connector, rather than sharing a generic login. Confirm that multi-factor authentication and a strong password policy are in place for that account before enabling the API, since the API settings are administrative. Record who holds this role so that changes to the connector can be traced later.

Configuration sequence for enabling and exposing the API

This sequence takes an OpenEMR installation from a confirmed release to a FHIR R4 endpoint that is reachable only over HTTPS, with each site's base URL and resource list verified from the capability statement. Work through it in order, because the exposure controls only matter once the API is on and the metadata check depends on the correct base URL.

  1. Confirm release and patch level

    Record the OpenEMR version, PHP version and database engine before changing any setting. Recent 8.x releases require PHP 8.3 or later and run on a MySQL- or MariaDB-compatible database. Confirm that the installed version includes the security fixes for the FHIR API published in the 8.3.0 and 8.4.0 releases, and move to the current patch if it does not. The check is a written record of the version string, the PHP version and the database version, with the release notes reviewed against your installed build. Confirm the exact upgrade path with your vendor or your DeployOpen scope before you change the version.

  2. Enable the FHIR API for each site

    An administrator turns on the FHIR API in the Administration Globals settings for each site in the installation, then saves and reloads the configuration. Multisite installs keep these settings per site, so a site left disabled will not answer FHIR requests even when its neighbors do. Check that each site's configuration has the API enabled and record the change in your change log. The check is a successful request to the capability statement on every site that should expose the API.

  3. Confirm the base URL for each site

    Write down the public base URL that each site's FHIR endpoint answers on, and confirm it matches the hostname, path and certificate that clients will use. In multisite installs each site has its own base URL, so do not assume one hostname covers all of them. Ask your application owners which URL they will register in SMART apps and integrations, because a mismatch here causes token and launch failures later. The check is a table of site names mapped to base URLs, confirmed against a DNS lookup and a certificate check for each host.

  4. Restrict exposure to HTTPS on port 443

    Configure the web server so that the FHIR endpoints accept only HTTPS, and open only port 443 at the firewall and load balancer for public access. The Securing OpenEMR guide recommends this approach, and it means that plaintext HTTP requests to the API should never reach the application. Make sure that any HTTP listener redirects or refuses traffic rather than serving data. The check is a plain HTTP request to a FHIR endpoint that is refused or redirected, and a port scan from outside your network that shows no open port other than 443 for the application.

  5. Block web access to the documents directory

    Configure the web server to deny direct browser access to the sites/*/documents directory on every site. Uploaded clinical documents stored there should only be reachable through the application's own access controls, not by guessing a file path. Test this on each site, because a rule that covers one site may not cover the others. The check is a direct request to a known document path on each site returning a denial, and a legitimate document still opening through the application for an authorized user.

  6. Remove setup.php and admin scripts

    After installation is complete, remove setup.php and any other administrative scripts that the web server should not serve. The Securing OpenEMR guide asks for this step, and it prevents anyone from reaching installation or maintenance pages through the public endpoint. Keep a copy of the removed files in your build or change records in case you need to reinstall. The check is an HTTP request to the path of each removed script returning a not-found response from the web server.

  7. Fetch and review the capability statement

    Request the metadata endpoint, which is the FHIR capability statement, from each site's base URL over HTTPS. Confirm that the document reports FHIR R4 and lists the resources and search parameters your integrations need, and that the security section describes OAuth 2.0 with the scopes you expect. Compare the result with the resources described for US Core 8.0 in OpenEMR's FHIR documentation and record any resource that is missing or unexpected. The check is a saved capability statement per site, with a list of differences that your team has reviewed and accepted or raised with the vendor.

How a FHIR request reaches OpenEMR

The request starts at a client app outside your network and passes through a TLS terminator or reverse proxy before crossing the firewall boundary into the OpenEMR web tier. The web tier serves the per-site base URL and the capability statement, while the OAuth 2.0 authorization server inside OpenEMR checks the token before any FHIR resource is read from the database. Check that only HTTPS on port 443 reaches the proxy, that the capability statement is reachable for the sites you intend to expose, and that the database stays inside the internal zone.

Request path from a client app through the edge into OpenEMR's FHIR endpoints.

Choosing how much of the API to expose

Internal-only exposure keeps the FHIR endpoint reachable from integration engines and clinical systems on the same network segment, with no path from the internet. This model usually has the smallest attack surface, but it still carries ePHI, so access must be narrowed to named callers and documented. Confirm how your network design and OpenEMR's documented settings handle each point below.

  • TLS termination: Decide whether TLS ends at the web server running OpenEMR or at an internal load balancer, and confirm that traffic between the hop and OpenEMR is encrypted if it crosses a network boundary.
  • Allowed sources: Restrict inbound connections to the specific addresses or subnets of integration engines, using firewall rules that you can show an auditor.
  • Logging: Send web server access logs and OpenEMR audit records to a central store, and confirm which caller identity each FHIR request records.
  • Review: Re-check the list of allowed sources and registered clients on a schedule you set, and after any change to the integration engine.
  • Port scope: Confirm the OpenEMR securing guidance to allow only HTTPS and consider opening only port 443 applies to this model.

Before go-live, confirm that the internal network design matches the documented allowed sources and that a test client outside the approved range is refused.

Which US Core 8.0 resources the API returns

The capability statement is the authoritative list of resources, search parameters and operations for the OpenEMR version you have installed, so start there and not with a list copied from documentation or a blog post. OpenEMR's FHIR API implements FHIR R4 (4.0.1) and US Core 8.0, but the resources a given site actually serves, and the search parameters and operations on each, must be read from the server's metadata endpoint on that installation. Export the capability statement, then compare it line by line against the US Core 8.0 profiles your applications and data consumers plan to use. Any profile your use case needs that is missing or only partly supported becomes a gap to resolve before build starts, either by changing the use case, adjusting the app or accepting a documented limitation. Confirm the supported profiles and search parameters with the OpenEMR FHIR README for your version.

Resources map to OpenEMR's relational tables rather than to FHIR-native storage, so each exposed resource is a view built from several sources. Patient demographics come from the patient data tables, encounters from the form and calendar data for visits, and observation-style data such as vital signs and lab results from the forms and results tables that clinicians fill in. Gaps usually appear where clinical practice and data entry diverge: vitals recorded in a free-text form instead of structured fields, problems or allergies entered as text, encounters without a consistent class or type, or results that were never linked to an order. Ask your clinical informatics lead which fields are structured in your templates before assuming a resource is complete. Your own templates and local customizations change these mappings, so the table-level behavior must be verified in your installation, not assumed from a generic description.

Test each resource with representative records from your own site, not with a demo patient. Build a test set that includes the common case, incomplete records, records with multiple encounters, corrected or amended entries, and patients who have moved between sites in a multisite setup. For each resource, request single reads and the search parameters your apps will use, then compare the returned fields, codes and references against the US Core 8.0 profile and your data mapping document. Use a validator to check profile conformance and record every mismatch with the resource, the field and the expected behavior. Repeat the test after each OpenEMR upgrade, since the capability statement and mappings can change between releases.

Mapping FHIR resources to OpenEMR data

This table maps the FHIR resources teams most often request to the OpenEMR areas that hold their data, with what to verify and where gaps tend to appear. Confirm every resource, search parameter and operation against the capability statement of the release you have installed, since coverage can differ between versions. Treat any row without a matching resource in that statement as a gap to plan around, not an assumption to build on.

FHIR resourceOpenEMR areaWhat to verifyCommon gap
PatientPatient demographics and registrationIdentifiers, names, birth date and telecom values return as recorded, and search by identifier works for your key fieldsMultiple identifiers or external IDs from another system may not map cleanly
ObservationVitals, lab results and social history entriesWhich categories and LOINC codes appear in the capability statement and how units are returnedFree-text entries or locally coded results may arrive without standard codes
ConditionProblem list and diagnosesCode system, clinical status and onset fields for your coded problemsLegacy entries coded in ICD-9 or free text may not validate against your profile
MedicationRequestPrescriptions and medication listMedication codes, dosage fields and status values for active versus stopped itemsHistorical medications entered without structured dosage data
AllergyIntoleranceAllergy and intolerance listsReaction and severity fields, and whether no-known-allergy statements are representedNegative assertions such as no known allergies may be missing or inconsistent
EncounterVisits, scheduling and encounter recordsClass, type and period fields, and how encounters link to patients and providersEncounters without a finished status or with incomplete provider links
DocumentReferenceUploaded documents and clinical documentsAccess to the document content, content type and the patient linkFiles stored outside the expected documents path or without a patient link

Security controls to set before any client connects

The FHIR API inherits the exposure of the web application it runs in, so the perimeter, the admin surface and the identity controls need to be in place before any app or client is registered. Each card below is a control to set, verify and keep as evidence. None of them is a certificate, because HIPAA does not issue one.

HTTPS only on port 443

Serve OpenEMR and the FHIR endpoints only over HTTPS on port 443, and close plain HTTP at the load balancer or web server. The Securing OpenEMR guide suggests opening only port 443 to the internet. Check from outside your network that no other port answers, and confirm that the FHIR base URL for each site is the HTTPS address your clients will use.

Securing OpenEMR guide

TLS certificate management

Assign ownership for the certificate on each public hostname, including its renewal date, chain and key storage. Confirm that the certificate covers the exact host name in each site's FHIR base URL, since SMART apps and bulk export clients will fail on a name mismatch. Record who receives expiry alerts, and test renewal before the first client is registered.

Remove setup and admin scripts

Delete setup.php and other administrative scripts after installation, as the Securing OpenEMR guide recommends. Confirm the removal from the public web root after every upgrade or redeploy, because a fresh file copy can restore them. Keep installer access limited to a maintenance window and record who performed it.

Block direct access to documents

Block direct web requests to sites/*/documents, where uploaded patient files are stored. Patient documents should only be reachable through the application's own access checks, not by guessed URL. Test this from an unauthenticated browser and from a logged-in session that lacks rights to the patient, and keep the test results with your configuration evidence.

MFA and strong passwords for admins and API users

Require multi-factor authentication for administrators and for any account that holds API or app authorization rights. Apply the strong password rule and expiration settings in OpenEMR's administration globals to every account type, including service accounts where they apply. Confirm which accounts can approve clients, since those accounts control what apps can read.

Prior passwords blocked
5
Administration Globals wiki

Review the FHIR fixes in 8.3.0 and 8.4.0

The 8.3.0 and 8.4.0 releases fixed security vulnerabilities in the FHIR APIs, along with the patient portal, billing, fax and SMS module and fee sheet. Confirm the running version, read the release notes for each fix, and plan an upgrade to 8.4.1 or the current release before connecting clients. Record the version and date in your change log as evidence of patching.

OpenEMR releases

Why the FHIR endpoint fails and how to fix it

This table pairs common FHIR endpoint failures with their likely causes and fixes in an OpenEMR deployment. Work down the rows in order, because the capability statement is the fastest check that the API is enabled, reachable and serving the expected base URL. Each fix should be verified before moving to the next row.

SymptomLikely causeFix and verification
Capability statement at the metadata endpoint does not loadThe FHIR API is not enabled in Administration settings, or the request is going to a path without the site identifierEnable the FHIR API option in the global settings, then request the metadata endpoint for the exact site path. Verify that a 200 response returns a CapabilityStatement with FHIR version 4.0.1.
TLS or certificate errors when a client connectsThe certificate does not match the public hostname, the chain is incomplete, or the client trusts a different CA than the one that issued the certificateInstall the full certificate chain on the web server and confirm the hostname matches. Verify with an external TLS checker and by fetching the metadata endpoint from a client machine without custom trust settings.
Wrong base URL on a multisite installThe client was configured with the default site path or with a hostname that does not map to the intended siteConfirm which site identifier each client should use and build its base URL from that site. Verify by comparing the capability statement and sample patient search results across two sites.
Expected resources are missing from the capability statement or responsesResource support depends on the US Core 8.0 set the build exposes, and some resources may be disabled or not yet populated for the siteCompare the resource list in the capability statement against the US Core 8.0 resources your app needs, and confirm the matching scopes are granted to the client. Verify with a test request per resource using a test patient.
Requests blocked before reaching OpenEMRA reverse proxy, WAF or firewall rule blocks the FHIR path, strips the Authorization header, or limits request methodsAllow the FHIR path through the proxy, pass the Authorization header unchanged, and permit the methods the API uses. Verify with the same request sent directly to the application server and through the proxy, and confirm the responses match.
Token requests fail while metadata loadsThe OAuth2 token or authorization endpoint is not reachable through the proxy, or the external base URL in the configuration differs from the public addressSet the public site address the server advertises, then confirm the token and authorization endpoints are reachable externally. Verify by reading the discovery document and calling each endpoint it lists.
Responses show the internal host name or wrong schemeThe application is behind a TLS-terminating proxy and does not know the external scheme or hostConfigure the proxy to forward the original host and protocol headers and confirm the application builds URLs from them. Verify that the links in the capability statement use https and the public hostname.
Only HTTP, not HTTPS, is reachablePort 80 or an HTTP listener is open without a redirect, or the server only listens on port 443 but clients use httpAllow only HTTPS as the Securing OpenEMR guide advises, redirect or reject plain HTTP, and confirm the port exposure with an external scan. Verify that http requests fail or redirect and https requests succeed.

Questions teams ask before setting up the OpenEMR FHIR API

How much effort does setting up the OpenEMR FHIR API take?

Effort depends less on switching the API on and more on what surrounds it: the number of sites, the apps that will connect, the TLS and network design, and how many resources and scopes each app needs. Enabling the FHIR connector in OpenEMR is a configuration step, but a production exposure also involves a reverse proxy or load balancer, certificate management, firewall rules, client registration and a test plan. The OpenEMR FHIR README lists FHIR R4 (4.0.1), US Core 8.0 and SMART on FHIR v2.2.0, so each app's requirements should be mapped to those before work starts. Ask any partner for a written scope that lists sites, apps, environments and the verification steps.

Can our in-house team set up the OpenEMR FHIR API without a partner?

Yes, if your team already runs OpenEMR and has someone comfortable with web server configuration, OAuth 2.0 and TLS. The hard parts are rarely the connector itself. They are deciding which networks may reach the API, keeping the base URL and certificate correct for each site, understanding which scopes an app is requesting, and testing against the capability statement before a clinical app touches live data. Your team will need an environment where changes can be tested safely, and someone who owns the decision to expose the API. Teams that lack these skills, or that must hand over documentation for an audit, often bring in an outside implementation partner for part of the work.

What does the setup need from our organization before work starts?

Expect to provide several things before any configuration begins:

  • Administrative access to OpenEMR for each site, and to the web server, reverse proxy and DNS records that will front it
  • A certificate authority or certificate process for the public hostname, plus the rules for renewal
  • Firewall and network change approvals, including which source networks may reach the API
  • Test data or a non-production copy of OpenEMR, so that resource queries can be checked without exposing real patient records
  • Named owners for security review, the identity provider and each connecting application

The Securing OpenEMR guide advises allowing only HTTPS and considering opening only port 443, so confirm your change process covers that rule before the build.

How long does the FHIR API setup take across multiple sites and integrations?

Duration grows with the number of sites, the number of connecting applications and the number of environments that must be validated. A single site with one app and an existing reverse proxy is a far smaller job than a multisite group where each site has its own base URL, its own clients and its own network path. No duration figure is given here because it depends on your environment and scope. Ask for a timeline that is broken down by site, by application and by environment, and that names the change windows, approvals and retesting you are expected to supply.

What drives the cost of a DeployOpen FHIR API setup, and what should we ask for in a quote?

DeployOpen does not publish a price list. A quote follows from written scope, and most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. The main cost drivers are the number of sites and base URLs, the number of applications and scopes to validate, the network and TLS design, the state of your existing infrastructure, and the documentation and testing you require. Ask for a quote that lists each site and application, the environments covered, what is delivered (configuration, runbook, test results), and what you must provide. Ask separately whether ongoing support or upgrades are priced as a retainer.

Can DeployOpen hand over a documented FHIR API configuration that our team can maintain?

Documentation is a normal deliverable of a fixed-scope engagement, and it should be named in the written scope. A useful handover covers the enabled connector settings and base URL for each site, the TLS and proxy configuration, the firewall rules, the registered clients and their scopes, the test results against the capability statement, and the steps for upgrades and certificate renewal. Ask for the handover format, who receives it, and whether it will be kept current after each OpenEMR release. Documentation of this kind supports later review, but it does not replace an independent audit, and DeployOpen does not issue audit reports or certifications.

What should we test before any app connects to the OpenEMR FHIR API?

Start with the capability statement served by each site's FHIR endpoint, and confirm that it reports FHIR R4 and the resources your apps need. Then check that unauthenticated requests are refused, that TLS certificates validate from outside the network, that only the approved source networks can connect, and that each client receives only its granted scopes. Test with synthetic patients in a non-production environment first, and record the results so the same tests can be repeated after each OpenEMR upgrade. Because OpenEMR 8.3.0 and 8.4.0 fixed security vulnerabilities in FHIR APIs, retest after each security release.

How to test the API against the capability statement

Start with the capability statement. Request the server's metadata endpoint on the base URL for each site and compare what it returns against the resources you agreed to expose, the US Core 8.0 profiles and the search parameters your apps depend on. The OpenEMR FHIR README describes the server as implementing FHIR R4 (4.0.1), US Core 8.0 and SMART on FHIR v2.2.0, so treat those as the claims to verify, not as proof that every resource in your configuration is live. Record the statement from each site separately, because the base URL is per site and a multisite deployment can differ between sites. Confirm the SMART and OAuth 2.0 security entries in the statement match the authorization server you configured, and keep a dated copy so a later upgrade can be diffed against it.

Next, run a small set of read requests against test patients. Pick two or three synthetic patients loaded for this purpose and request each resource type you expose, a search by identifier or name, and one search that uses a parameter your apps rely on. Check that the returned bundles use the expected resource shape and that unsupported search parameters fail in a predictable way rather than silently returning everything. Then run the negative tests: a request with no access token must be refused, an expired or wrong-scope token must be refused, and a plain request must not return data and must not be redirected into a session. Confirm the response to a plain HTTP request is a refusal or a redirect to HTTPS, and that the Strict-Transport-Security` header is set at the web server. Ask your administrator which TLS versions and cipher suites are enabled, because the statement does not tell you that.

Keep this testing away from production PHI wherever you can. Use a separate OpenEMR site or a staging instance loaded with synthetic patients, and use test client registrations that are never reused in production. If you must test against a live site, limit the test accounts to the minimum scopes, log each test run, and remove the test clients afterward. Ask your integrator to document the test cases, expected results and the version of OpenEMR tested, so the same suite can be rerun after each security release. Plan to repeat the suite after every upgrade and after any change to the reverse proxy, certificates or network rules, since those changes can alter the TLS and access results without touching the FHIR code.

How DeployOpen scopes and supports your FHIR API setup

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure, including OpenEMR. For the FHIR R4 API, that means agreeing in writing which resources, sites, clients and network paths are in scope, then building and testing them against the capability statement before handover.

How we scope

  • Written scope lists which OpenEMR sites expose the FHIR API and the base URL each one uses.
  • Scope names the US Core 8.0 resources to be enabled and the ones that stay off for your use case.
  • Scope records the network path, TLS termination point and who may reach the API from outside your network.

How we build

  • We enable and configure the FHIR connector per site, then check the OpenEMR version and PHP and database requirements against your target release.
  • We place TLS, reverse proxy rules and firewall exposure in your infrastructure, limiting inbound traffic to HTTPS on port 443.
  • We test authorization, scopes and resource access, and compare the live capability statement with the agreed resource list.

How we hand over

  • You receive the agreed configuration record, base URLs per site, enabled resources and network diagram.
  • You receive test evidence, including capability statement checks, scope tests and a list of any open findings with fixes.
  • You receive runbook notes for enabling new resources, rotating certificates and applying OpenEMR security releases.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • A retainer can cover retesting the API after each OpenEMR upgrade, including the 8.x line and any security release.
  • Confirm with us during scoping which support hours, response expectations and change handling your retainer includes.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.