Exporting OpenEMR data for analytics with FHIR Bulk Data

Feed a data warehouse or population health tool from OpenEMR using scheduled FHIR Bulk Data exports in NDJSON, with scoped access and protected PHI.

On this page

How OpenEMR FHIR Bulk Data exports feed an analytics platform

Analytics teams that need OpenEMR data in a warehouse on a schedule should use the FHIR Bulk Data export rather than screen scraping or ad hoc database queries. OpenEMR implements FHIR Bulk Data v1.0 export at system, patient and group level in NDJSON format, which means a client can request resources in bulk and receive them as newline-delimited JSON files, one resource per line. That output loads directly into most warehouse and lakehouse ingestion tools, and the same mechanism supports bulk extraction for migrations. The project documentation describes this capability in the OpenEMR FHIR README, but the README describes the feature, not the exact behavior of your installed version. Confirm which resource types, search parameters and export levels your release returns before you design pipelines around them.

The three export levels suit different analytics questions. A system-level export covers the whole FHIR data set the client is authorized to read, a group-level export limits output to a defined patient group, and a patient-level export covers individual patients. Group exports usually fit population health work, because the cohort definition stays with the analytics team and the file set stays small. System exports are heavier and need broader scopes, so they belong only in a warehouse zone with matching access controls. Test each level against a non-production copy of your site, record file counts, file sizes and the resources returned, and compare them with what the reporting team expects.

Each export is a data copy that leaves the EHR, so the team must decide who may request it, where the NDJSON files land and how long they remain. Treat the export client as a privileged integration: register it with the narrowest scopes that work, keep the export files in encrypted storage with restricted access, and set retention rules before the first scheduled run. The HIPAA technical safeguards in 45 CFR 164.312 cover unique user identification, audit controls and encryption, and the warehouse operator may also need a business associate agreement under 45 CFR 164.314. Confirm those obligations with your privacy and legal teams before the pipeline runs against live patient data.

What you need in place before the first OpenEMR bulk export

A bulk export is only as safe as the environment around it. These cards cover the OpenEMR platform, the API settings, the client identity, the landing zone and the data approvals that need to be settled before the first scheduled pull runs.

OpenEMR version and runtime

Confirm the OpenEMR release line you will run and the PHP version it requires. Recent releases require PHP 8.3 or later and a MySQL- or MariaDB-compatible database. Check the release notes for each version you deploy, since 8.3.0 and 8.4.0 both included security fixes in the FHIR API. Plan to be on a current patch level before you build an export pipeline on top of it, and confirm the database version and any Docker image requirements with the OpenEMR project and your own platform team.

OpenEMR releases

FHIR API enabled behind TLS

The bulk export runs through the FHIR API, so the API must be turned on for the sites you will export from and reachable only over HTTPS. The Securing OpenEMR guidance is to allow only HTTPS and consider opening only port 443. Decide which network paths can reach the API, such as the warehouse extract host or an internal integration network, and keep it off the public internet unless your design needs it. Confirm certificate management and the base URL for each site with your OpenEMR administrator.

Securing OpenEMR

Backend system client with narrow scopes

Scheduled exports should authenticate as a backend system client, not as a person's login. Register the client through OpenEMR's OAuth 2.0 controls, grant only the system-level bulk export scopes and resource types your analytics model needs, and record who approved each scope. Confirm with your OpenEMR administrator how client credentials are issued, rotated and revoked, and whether the client can be disabled without affecting other integrations.

Access-controlled warehouse landing zone

Exported NDJSON files are full copies of clinical data, so the landing location needs the same access rules as the source system. Define a dedicated bucket or directory, restrict write access to the export job and read access to the loader, and turn on encryption at rest and access logging. Decide how long raw files stay before they are deleted or moved into a curated store. Confirm the storage controls your platform team can enforce, because OpenEMR does not manage the downstream location.

Written approval to hold PHI

Before any export runs, get written sign-off from the privacy officer and security lead that the analytics platform may receive and store electronic protected health information for this purpose. Confirm whether a business associate agreement is needed with each vendor that touches the data, including the warehouse host and loader tooling. The HIPAA Security Rule applies to covered entities and business associates for all ePHI they create, receive, maintain or transmit, so the approval should name the data elements, the purpose and the retention period.

Configure scheduled group exports step by step

This sequence takes an OpenEMR instance from a closed FHIR API to a scheduled group export that writes NDJSON files your loader can pick up. Each step ends with a check you can record before moving on.

  1. Enable the FHIR API for the export site

    An administrator turns on the FHIR API in OpenEMR's global settings for the site that holds the data, following the FHIR README for your release. Confirm the exact setting name and the base URL for each site in your version before you change anything, because multisite installations expose a base URL per site. Keep the endpoint behind TLS and reachable only from the export host and the administrative network. Done means a capability statement request to the metadata endpoint succeeds over HTTPS from that host.

  2. Register a system client with bulk scopes

    Create a backend client for the export job using the OAuth 2.0 client credentials pattern for system-to-system access. Grant read scopes only for the resource types the warehouse needs, such as Patient, Observation and Condition, plus Group read for cohort selection. Confirm the system scope format for your version in the FHIR README. Store the client secret or private key in your secrets manager and record the client identifier and token endpoint. Done means a token request returns an access token whose granted scopes match the list you approved.

  3. Define the group that drives the export

    Create or confirm a FHIR Group resource that lists the patients in the cohort, such as an attributed panel or a registry population, and agree the membership rule with the data owner. A group-level export only returns patients who are members, so an outdated Group produces an incomplete extract. Confirm how your OpenEMR version exposes Group resources, then record the Group identifier and its member count from your source system. Done means a read of the Group returns the expected identifier and count.

  4. Run a test kick-off and poll status

    Send a group-level export request to the Group's $export operation with the Prefer header set to respond-async, which is the asynchronous pattern in the Bulk Data specification. The server should answer 202 Accepted and return a Content-Location header pointing to a status URL. Poll that URL with the bearer token, pausing between requests, until it returns 200 with a manifest listing output files, or returns an error with an OperationOutcome. Done means you hold a completed manifest and a logged job ID.

  5. Download and check the NDJSON files

    Download each file listed in the manifest with the same authorization, store them in a restricted staging location and record a checksum for each file. An NDJSON file holds one FHIR resource per line, so count lines per resource type and compare the Patient count with the Group member count from the previous step. Open a sample of records and check identifiers and dates against the chart in OpenEMR. Done means every listed file downloaded, the checksums are logged, and the counts reconcile or each gap is explained.

  6. Load the files and schedule the job

    Point your loader at the staging location and load the files into a raw zone of the warehouse, keeping the exported files as the source for reruns. Schedule the kick-off, polling and download as one job with retries, a limit on polling time and an alert when the status request returns an error. Set retention on staged files and restrict read access to the service account that loads them, since exported files contain PHI. Confirm the run frequency with the data owners. Done means one scheduled run completes unattended and its counts match the manual test.

Choosing between system, patient and group exports

Pick the export level before you write any scheduler job, because it decides what data leaves OpenEMR, how large each file gets and how hard reconciliation will be later. A system-level export fits a full warehouse load: it covers every resource the server is willing to return for the authorized client, so it suits an initial backfill or a periodic full refresh where the warehouse needs complete tables. Its cost is volume. The export runs against the whole installation, output files grow with the practice, and a failed run is expensive to repeat. Confirm in your OpenEMR version which resource types the system export returns and whether it needs a dedicated system scope, since those answers determine the job's runtime and the access it grants.

A group export limits the cohort to members of a defined group, which is usually the right shape for a population health tool that scores a panel of patients, a registry or a payer program. Files are smaller, the load is faster, and the export matches the population the tool is licensed or governed to see. The trade-off is that the group is only as stable as its definition. If membership changes between runs, counts will move for reasons unrelated to clinical activity, so the reader should confirm how groups are created, who maintains membership and whether the group ID used by the export stays constant across upgrades. A patient-level export is useful for one-off troubleshooting, a single patient's data in a research or legal request, or validating a warehouse transform against a known record. It is rarely the basis of a scheduled pipeline.

How FHIR resources map to warehouse tables

This table pairs each US Core 8.0 resource in a group or system export with a proposed warehouse table, its key and the handling it needs. Treat each row as a design decision to test against your own OpenEMR data, not as a guaranteed output of the export.

ResourceProposed table and keyHandling to validate
Patientdim_patient, keyed on the Patient logical id from the exportPatient is the anchor for joins. Confirm which identifiers OpenEMR emits and whether your MRN or external IDs need a separate crosswalk table.
Encounterfact_encounter, keyed on Encounter id, with a patient_id foreign keyConfirm the subject reference resolves to a Patient in the same export. Map status and class codes to your own reference tables.
Conditionfact_condition, keyed on Condition id, with patient_id and encounter_idDiagnosis code systems (for example ICD-10-CM or SNOMED CT) vary by record. Store the system and code as separate columns and validate value set coverage.
Observationfact_observation, keyed on Observation id, with patient_id and encounter_idVitals, labs and social history share one resource. Split by category and LOINC code, and plan for multiple components per observation.
MedicationRequestfact_medication_request, keyed on MedicationRequest id, with patient_idConfirm how the medication code is populated in your data. Decide whether medication lists and prescriptions are one table or two.
Procedurefact_procedure, keyed on Procedure id, with patient_id and encounter_idCheck performed dates and status values, which can be partial. Plan for procedures without an encounter reference.
Reference resolution (all resources)Load order and a reference check step, keyed on the resource type and id pairReferences can point to resources outside a group or to records not yet exported. Quarantine unresolved references rather than dropping them silently.
Deleted and updated recordsStaging table with load timestamp and a current-state viewConfirm how your export run identifies changed or removed resources before you choose between full refresh and incremental merge.

Loading NDJSON into the warehouse by environment

A cloud warehouse usually receives bulk export files through a staging area in object storage, then a load step copies them into tables. The main decision is how much structure to impose at load time. Loading each NDJSON line as a raw JSON record keeps the pipeline simple and lets analysts add flattened views later, while loading into typed tables for each FHIR resource type gives faster queries and clearer data quality checks but requires you to maintain a mapping as resource profiles change.

  • Staging layout: Write each export to a path keyed by export date and resource type, and keep the manifest file that the export returns so every load references exactly the files that belong to one run.
  • Schema approach: Choose raw landing tables with views for analysts, or typed tables for high-use resources such as Patient, Encounter and Observation. Confirm which US Core 8.0 elements your analysts need before you type anything.
  • Incremental runs: Confirm with your OpenEMR administrator whether your export configuration supports the filters you need. Plan for full reloads of reference resources and a narrower window for clinical resources if the export supports it.
  • Idempotent reloads: Key each record by its FHIR resource ID and version, and use merge or upsert logic so a rerun of the same export does not duplicate rows.
  • Load audit: Record the export ID, file counts, row counts and load timestamp in a control table so a failed or partial load is visible and can be rerun.

Before go-live, confirm with your warehouse team how deleted or merged resources will be handled, since a bulk export does not by itself tell the warehouse what was removed.

Protecting exported PHI in transit and at rest

Every NDJSON file a bulk export writes is electronic protected health information, and it leaves OpenEMR's controls the moment it is written to disk or pulled by a client. The cards below cover the controls that protect the export path, the storage that holds the files and the contractual terms a warehouse vendor must accept before it receives them.

Scope the export client narrowly

Register a dedicated system client and grant only the bulk export and resource scopes that the warehouse loads need, not broad patient-wide read access. Confirm which resource types the client can export and which it cannot, and review the grant against the list of tables the analytics team actually uses. A token that can read everything is the largest exposure in this pipeline. Record who approved the client and when, and revoke it when the project ends.

OpenEMR FHIR README

Keep the FHIR endpoint on HTTPS

The export request, the bearer token and the returned NDJSON all travel over the connection to the FHIR endpoint, so that connection must use HTTPS only. The Securing OpenEMR guide says to allow only HTTPS and consider exposing only port 443. Confirm that plain HTTP is closed at the load balancer and web server, and that the warehouse loader validates certificates rather than accepting any certificate.

Securing OpenEMR guide

Block web access to the documents directory

OpenEMR stores uploaded and generated documents under the site's documents path, and a file there can be requested directly if the web server allows it. Block direct web access to sites/*/documents and remove setup.php and other admin scripts after installation. Test the block by requesting a known file path from outside the network. Export files should never be written into a path the web server serves.

Encrypt stored exports where policy requires

Decide whether exported files sit on encrypted volumes, in encrypted object storage or both, and document that decision with the security owner. The Securing OpenEMR guide mentions an option to encrypt items stored on drive, which covers OpenEMR's own files but does not cover the copies your export job writes to scratch space. Set retention on the staging location so files are deleted after a successful load, and confirm that backups of the staging location follow the same encryption rule.

Control access to the landing bucket

Limit read and write access to the landing bucket or staging directory to the loader service account and a short list of named administrators. Use separate identities for writing exports and for reading them into the warehouse, and log every access. Confirm that the bucket is not public, that listing is restricted, and that access logs are retained long enough for your incident review.

Technical safeguards and audit controls

The HIPAA Security Rule's technical safeguards in 45 CFR 164.312 ask covered entities and business associates to limit ePHI access to authorized users, identify users uniquely, log activity and protect data in transit and at rest. The rule's implementation specifications for encryption are addressable, so your risk analysis must record whether you encrypt and why. Map each export client, loader and storage location to these safeguards and keep the mapping with the risk assessment.

45 CFR Part 164 Subpart C

Business associate terms for the warehouse vendor

A warehouse or analytics vendor that stores or processes ePHI for your organization is generally a business associate, and 45 CFR 164.314 requires a written contract that obliges it to comply with the Security Rule, flow the same terms to subcontractors that handle ePHI and report security incidents, including breaches of unsecured PHI. Ask counsel to confirm the contract's coverage of hosted copies, backups and support access. Ask the vendor to name the regions and subprocessors that hold exported files.

45 CFR 164.314 text

Common export failures and how to fix them

This table lists the failures teams most often hit when running OpenEMR FHIR Bulk Data exports into a warehouse, with the likely cause, the check to run and the fix for each. Read it top to bottom when a export fails, and start with the scope and client settings before changing the loader.

FailureLikely causeCheck and fix
Token rejected for the bulk scopeThe client was registered without the system-level bulk export scope, or the token was requested for patient or user scopes instead of system scopes.Decode the access token and confirm the system scope is present. Re-register or edit the client in OpenEMR to grant the system scope needed for system-level export, then request a new token.
Export kick-off returns an authorization errorThe export was started against a group or patient endpoint, but the client only holds system-level access, or the user behind the request lacks rights to the data.Compare the endpoint called with the scopes granted. Match the export level (system, group or patient) to the scope set, and confirm the approving admin has granted the client access.
Group export returns no data or an empty fileThe Group resource is empty, lists patients from another site, or lists identifiers the FHIR server does not recognize.Read the Group resource and count its members. Confirm member references resolve to patients in the site you are querying, then correct the group membership and rerun the export.
Polling never reaches completeThe client is polling the wrong status URL, does not send the authorization header on each poll, or the server is still processing a large export.Poll the Content-Location URL returned at kick-off, send the same bearer token, and respect the Retry-After header. Log each status response. If the job remains in progress well beyond your normal runtime, check server logs and job load before restarting.
Partial NDJSON files after a timeoutThe HTTP client or proxy closed the download before the file finished, or a gateway timeout cut the transfer.Compare file sizes with the output manifest and check that each file ends on a complete JSON line. Raise client and proxy read timeouts, download files to disk with resumable logic, and re-download any file that fails validation.
Loader fails on a truncated last lineThe loader parses a file that was not fully written, so the final line is an incomplete JSON object.Validate each line as JSON before loading and quarantine the file. Reload only after a clean download, and do not load a file whose size differs from the manifest.
Duplicate records after a reloadThe loader inserts rather than upserts, or a rerun reuses the same target table without keying on the FHIR resource id.Key the target tables on resource type and id, use upserts, and record the export id per load. Delete or replace the prior batch for the same export before reloading.
Resources missing from the exportThe client cannot read certain resource types under its granted scopes, or the requested _type list omits them.Compare the resource types requested with those returned in the manifest. Check the granular read scopes on the client and the user role in OpenEMR, then add the missing scopes and rerun the export for those types only.

Questions teams ask before exporting OpenEMR data

How much effort does a FHIR Bulk Data export project take?

The effort depends mostly on how many resource types you export, how many sites or groups are in scope, and how much transformation your warehouse needs before the data is usable. OpenEMR implements FHIR Bulk Data v1.0 export at system, patient and group level in NDJSON format, so the export side is a configuration and testing task, while the loader, schema mapping, scheduling and monitoring are the larger share of the build. Ask any provider to split the quote into export configuration, OAuth client setup, loader development, data validation, and operations handover, and to state which OpenEMR version and FHIR resources the work assumes.

Can our internal team run a bulk export project alone?

Often yes, if you already run a data pipeline tool, know OAuth 2.0 client credentials, and have an engineer who can own PHI handling. The OpenEMR side needs someone comfortable with the FHIR R4 API, US Core 8.0 resources and granular scopes, and the warehouse side needs someone who can map FHIR resources to tables and handle NDJSON reliably. Teams without that mix usually find the gaps in access control and validation, not in the export call itself. Decide early which parts you will staff internally and which you will buy as a fixed-scope engagement with written deliverables.

What do we need from the OpenEMR and warehouse owners?

You need named owners on both sides who can approve decisions that touch production data. On the OpenEMR side, that means the team that controls the server, the FHIR API settings, and the registration of the system client that will run the export. On the warehouse side, it means the owners of the target schema, retention rules, access groups and the scheduled pipeline. Both sides should agree on which patient group or population is exported, how often, who receives the output, and where it is stored. Put these decisions in the scope document before any build starts.

How long does a first export and loader take to set up?

No supplied figure gives a duration, so treat any number as something to confirm. The timeline depends on your export scope, the number of groups, the volume of data in OpenEMR, the warehouse technology, and how many validation rounds your data governance team requires. Ask the provider for a schedule with milestones for a test export, a loader that reads NDJSON files, reconciliation against source counts, and a production cutover. Ask what sizing assumptions the estimate uses and what changes if your population or resource list grows.

Does a FHIR bulk export make our OpenEMR data HIPAA compliant?

No. A FHIR export is a data transfer method, not a compliance outcome. The HIPAA Security Rule applies to covered entities and business associates for all electronic protected health information they create, receive, maintain or transmit, so the exported files, the loader, the warehouse and every person with access are in scope. There is no HIPAA certification, and HHS states that no Security Rule standard requires certifying compliance. Your team needs documented safeguards for access control, unique user identification, audit logging, encryption and automatic logoff, plus a business associate contract where a vendor handles ePHI.

What security controls should protect exported PHI?

Start with the export credentials, since a system client with broad scopes can pull an entire population. Use granular scopes, restrict the export to the groups you need, store client secrets in a managed secrets store, and log every export request. Keep NDJSON files encrypted at rest, limit where they land, delete intermediate copies on a defined schedule, and restrict warehouse access by role. The OpenEMR Securing OpenEMR guide also recommends HTTPS only and blocking direct web access to document directories, so confirm those settings on the server that serves the API.

What should a written quote for this work include?

A written quote should list the OpenEMR version and deployment type, the FHIR resources and groups in scope, the OAuth client and scope design, the loader technology and target warehouse, the validation method, and the handover of runbooks. It should separate one-time build costs from recurring costs such as scheduled runs, upgrades after OpenEMR security releases, and monitoring. Ask who is responsible for the warehouse licenses and cloud storage, what happens when OpenEMR is upgraded, and what acceptance tests end the engagement. DeployOpen provides fixed-scope quotes based on the written scope.

Where DeployOpen fits in an analytics export project

DeployOpen plans and implements the FHIR Bulk Data export inside your own infrastructure, so the export runs where your OpenEMR instance and your warehouse already live. The work covers the pieces that decide whether an export is safe to run on a schedule: the OAuth 2.0 client registration for the export job, the system-level or group-level scopes it is granted, the loader that reads the NDJSON output into your warehouse, and the controls that keep exported protected health information (PHI) limited to the people and systems that need it. Each of these is configured against your environment, not a generic template, so the design reflects which OpenEMR site, which patient group and which warehouse team own each step.

The scope of a typical engagement also includes the evidence your security and compliance reviewers will ask for. That means documented client registrations and their granted scopes, the export schedule and its access logs, the loader's error handling and retry behavior, storage and encryption settings for the output files, and test results showing that a client without the right scope cannot pull data. DeployOpen prepares these artifacts and the test evidence for your review. It does not issue audit reports, attestations or certifications, and the HIPAA Security Rule has no certification to obtain, so the document to confirm with your own assessor is what your review requires.

Most engagements are fixed-scope, so the deliverables, the environments covered and the acceptance tests are agreed in writing before work starts, and a quote follows from that written scope. Ask for the export inventory, the named data groups, the expected job frequency and the retention rules for the warehouse copy when you request a quote, because these drive the effort more than the number of OpenEMR sites does. Once the export is live, OpenEMR upgrades, scope reviews and periodic re-testing can run as an ongoing retainer, which suits a pipeline that the warehouse team depends on every day.

How DeployOpen scopes, delivers and supports OpenEMR exports

DeployOpen plans, builds, tests and documents scheduled FHIR Bulk Data exports from OpenEMR inside the client's own infrastructure. The work follows a written scope, so the client's security, compliance and data teams can review the export path, the access model and the PHI handling before the first warehouse load.

How we scope

  • We confirm which OpenEMR sites, group definitions and resource types the export must cover, in writing.
  • We agree which system scopes, client registrations and network paths the export job will use.
  • We define who receives the NDJSON files, where they land, and how long they are kept.

How we build

  • We configure the bulk export job, scheduled runs and the system client with granular scopes.
  • We build the NDJSON loading pipeline and test it against a non-production OpenEMR copy.
  • We set encryption, access restrictions and logging on every location where exported PHI is stored.

How we hand over

  • We deliver runbooks covering schedules, credential rotation, failed-export handling and restore steps.
  • We document the data flow, field mappings and access controls for your security and compliance reviewers.
  • We walk your engineers through the pipeline and confirm the handover checklist against the agreed scope.

How we support

  • Engagements are fixed-scope, so changes to resources, sites or destinations go through a written change request.
  • Ongoing support, OpenEMR upgrades and continuous testing are available as a retainer.
  • Retainer work includes retesting the export path after OpenEMR security releases that touch the FHIR API.

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.