Syncing Medplum with external FHIR servers and Bulk FHIR

Medplum can read from and write to other FHIR servers through CLI profiles, and pull partner data on a schedule with Bulk FHIR. This page covers the method, setup sequence, mapping, security and failure points.

On this page

How Medplum syncs with external FHIR servers and Bulk FHIR

Your team needs Medplum to talk to another FHIR server in one of three ways: confirming that a new patient already exists in a partner system, pushing finalized encounter documentation to another server, or pulling new data from a partner on a schedule. Medplum's docs describe external FHIR server connections for all three, with CLI profiles storing the credentials used to reach each server and Bulk FHIR covering the scheduled pull. Plan the work around those two building blocks, and expect that the docs do not provide a packaged sync engine. Your team designs the matching rules, the write logic and the schedule.

The existence check is the most sensitive of the three because it decides whether a record is created or reused. Define the identifiers you will match on, such as a medical record number issued by a shared authority or a combination of name, date of birth and sex, and decide what happens when two candidates match or none do. Record the outcome, including the external identifier you stored, so a later reader can see why a patient was linked. Confirm with the partner which identifier systems their server exposes before you write any matching code, because a mismatch here creates duplicate or merged patients that are difficult to unwind.

Finalized encounter sync and partner Bulk pulls share a different risk: duplicates and gaps over time. Push only encounters that have reached a final status in Medplum, and store the remote resource ID so that retries update rather than recreate. For Bulk FHIR, confirm with the partner which resource types, export scope and authorization method they support, then decide how you will track the last successful export, handle a failed or partial run and reconcile records that the partner later corrects. The Medplum CLI documentation is the natural next read for profile setup, and the partner's own FHIR capability statement should settle what the remote server actually supports.

What you need before connecting Medplum to another FHIR server

Connecting Medplum to another FHIR server touches your deployment, the partner's server, their credentials, your network and the data contract between you. Confirm each of these before writing any sync or Bulk FHIR code, because a gap in one usually surfaces later as a failed pull or a rejected write.

Medplum deployment and version

Confirm whether you run Medplum Cloud or a self-hosted deployment, and which version you are on. Check the version against the release page before you plan the work, since a self-hosted server that lags several minor versions may need an upgrade first. Record the version in the project plan so the CLI, the server and any Bots are tested against the same release.

Medplum releases

Remote FHIR endpoint and version

Get the base URL of the partner's FHIR server and the FHIR version it implements. Ask whether it supports the Bulk FHIR API, which search parameters it accepts and whether a sandbox exists for testing. A server that is not on the version your mapping assumes will need its resource profiles and payloads checked before any data moves.

Partner-issued credentials

Agree on the authentication method the partner will issue, such as client credentials for server-to-server access, and who owns rotation and revocation. Store the credentials in Medplum CLI profiles rather than in scripts or shared files, and keep one profile per partner environment so test and production access stay separate. Confirm the scopes granted match the resources you need.

External FHIR servers docs

Network paths and allow-listing

Map the outbound route from your Medplum server or Bot runtime to the partner endpoint, including DNS, firewalls, proxies and TLS certificate chains. Ask the partner which source IP addresses they will allow and whether they require a fixed egress address. Test the path from the same environment that will run the sync, not from a developer laptop, because self-hosted networks often differ from the design.

Shared resource and identifier contract

Agree in writing which FHIR resources move in each direction, which encounter status triggers a push and how each side identifies a patient, such as a shared identifier system or a demographic match rule. Without this, two servers can hold duplicate Patient records that look valid individually. Document the contract in the same place as the mapping specification so it can be reviewed by both teams.

Configuring a CLI profile and first read from a remote server

This sequence takes a partner FHIR server from credentials to a working read path in Medplum, with a check at each stage so that the encounter push and scheduled Bulk FHIR pull only start once the connection is proven. Work it in a non-production environment first, using the partner's sandbox where one exists.

  1. Collect the partner connection details

    Before touching Medplum, the integration lead gets the remote server base URL, the FHIR version the partner supports, and the credential type the partner issues (for example, a client ID and secret for client credentials access). Confirm with the partner whether a sandbox or test endpoint exists and which scopes the account will have, including whether it can run Bulk FHIR exports. Store the secret in your own secrets manager, not in a ticket or chat thread. The step is complete when the team has a written list of these items, signed off by the partner's technical contact.

  2. Create a CLI profile for the remote server

    On a workstation or build runner that your team controls, the engineer creates a Medplum CLI profile that holds the remote server base URL and the credentials for that server, following the profile setup in the Medplum external FHIR servers documentation. Keep one profile per partner server and per environment so a test profile cannot write to production. Restrict who can read the profile file and confirm the credentials are not committed to source control. The profile is in place when the CLI lists it under the expected name and points at the partner's test endpoint.

  3. Verify reachability with a capability request

    The engineer runs a metadata request against the remote server through the profile, which asks the server to describe its capabilities. A successful response returns a CapabilityStatement, and the engineer checks the reported FHIR version against the version confirmed in the first step. If the call fails, check the base URL, network egress from the runner, and whether the credentials were accepted before changing any other setting. The check passes when the response is received with the expected version and the auth method succeeds without a manual token.

  4. Confirm FHIR version and resource support

    The integration lead compares the CapabilityStatement against the resources and operations the integration needs, such as Patient search, Encounter create and update, and the Bulk FHIR export operation if a scheduled pull is planned. Note any gaps, including supported search parameters, read-only resources, or missing operations, and send them to the partner before building mappings. Record the server's reported version in the integration design document. This step is done when every required resource and operation is marked as supported or as a documented gap with an agreed workaround.

  5. Run a patient existence search

    The first functional use case is checking whether a patient from Medplum already exists on the partner server, which avoids creating duplicate records. The engineer runs a Patient search on the remote server using identifiers and demographics that the partner's matching rules accept, and logs the result count without copying clinical content into the console. Run the search against a few test patients that you created or that the partner provided, and confirm that a known match returns and a known non-match returns nothing. The step is complete when both cases behave as the test data predicts.

  6. Round-trip an encounter in a test environment

    Before pushing finalized encounters to production, the engineer writes one test Encounter from a Medplum test patient to the partner's sandbox, reads it back, and compares the stored fields with what was sent. Check identifiers, status, class, period and references to the patient, since reference handling is a common source of failure between servers. Confirm the partner's acceptance rules for finalized documentation and whether updates to a finalized encounter are allowed. Delete or mark the test resource according to the partner's sandbox policy. The check passes when the read-back matches the source and the partner confirms the record meets its rules.

  7. Schedule the Bulk FHIR pull from the partner

    Once reads and writes are verified, the team adds the scheduled Bulk FHIR pull. The engineer starts a test export on the partner's sandbox, polls the status endpoint until the export completes, downloads the NDJSON output, and checks file counts and resource types against the expected scope. Then schedule the job on the platform that runs your other pipelines, with the export kick-off, polling and download logic, and alerting on failed or partial exports. Ask the partner about export size limits, retention of export files and how incremental pulls are marked. The step is complete when two consecutive scheduled runs in the test environment finish with validated output.

  8. Promote the profile to production under review

    Before any production profile is created, the integration lead reviews the test results, the credential ownership, the scopes granted and the audit trail of each request with the security and compliance contacts. Create the production profile separately with production credentials, confirm the same capability check passes against the production endpoint, and run the patient existence search with a single agreed test record. Document who can rotate the credentials and how a revoked credential is handled. The sequence is complete when the production capability check and single patient search succeed and the review is recorded.

How to match patients across servers without duplicates

Patient matching depends on identifiers, demographics and the partner's rules, not on a single built-in algorithm. Medplum's external FHIR server docs describe checking whether a new patient already exists on another server, but the decision of whether two records are the same person belongs to your team and to the partner. Before any sync runs, agree in writing which identifier system is authoritative, which demographic fields are compared, and which fields may be used only as supporting evidence. Choose the identifier with the most care. A medical record number issued by one organization is stable within that organization but may not exist on the partner's server, so confirm with the partner which identifier system their Patient resources carry and whether it is the same system your Medplum Patient uses. Record the system URI exactly as each side stores it, because a mismatch in that string is a common source of false negatives.

Demographics change and are often incomplete. Names get married names or nicknames, addresses move, phone numbers are reassigned, and birth dates are sometimes entered wrong. Define what happens when a field is missing on one side, when it differs, and when two fields disagree. A common approach is to require an exact identifier match before any automatic link, to route candidates with matching demographics but no identifier to a manual review queue, and to create a new record only when no candidate passes. Set a near-match threshold in the rules and decide who reviews it, how long a pending decision can wait, and whether a sync should pause for that patient or continue with others. Test these rules against a sample of realistic duplicates from both systems (created here as illustrative cases) before enabling scheduled runs, because a rule that looks correct on paper often fails on real name spellings.

Log every match decision, including automatic links, manual merges, rejected candidates and new record creations. Each entry should capture the two resource IDs, the identifiers and fields compared, the rule or reviewer that decided, and the timestamp, so an auditor or a clinician can reconstruct why two records were joined. Keep those logs with the sync configuration and the credentials used, and review the rules whenever the partner changes its identifier practices. Confirm with your compliance lead how long these records must be retained and who may access them, since the match log itself contains patient data.

Mapping Medplum resources to the remote FHIR server

This table compares how Medplum fields map to the remote FHIR server for Patient, Encounter and related resources, and which direction each mapping runs. Read it as a starting point: the rules for finalized versus draft data must be confirmed against the partner's FHIR profile and implementation guide before any pipeline is built.

Medplum resource or fieldRemote resource or fieldDirectionRule for finalized versus draft data
Patient identifiers (MRN, partner ID)Patient.identifier with system and typeMedplum to remote for existence checks, remote to Medplum for matchesMatch only on identifiers the partner marks as authoritative. Do not write drafts to a partner record.
Patient demographics (name, birth date, gender, address)Patient.name, birthDate, gender, addressTwo-way, with the source of truth agreed per fieldSend demographics only after the source record is verified. Confirm required elements in the partner profile.
Encounter status and periodEncounter.status, Encounter.periodMedplum to remotePush only when status is finished. Drafts and in-progress encounters stay in Medplum.
Encounter class, type and reasonEncounter.class, Encounter.type, Encounter.reasonCodeMedplum to remoteConfirm the partner's code systems and value sets. Send with the finished encounter, not before.
Practitioner referencesPractitioner or PractitionerRole, matched by identifierTwo-way lookup, then referenceReference only practitioners already present on the remote server. Confirm how the partner expects identifiers.
Location referencesLocation, matched by identifier or nameTwo-way lookupMap to the partner's location catalog. Unmatched locations need a rule agreed with the partner before pushing.
Observation resultsObservation, linked through encounterMedplum to remote or remote to MedplumConfirm the partner accepts preliminary results. Many partners accept only final statuses.

How data moves between Medplum and the partner server

The flow starts in Medplum, where the CLI profile holds the credentials used to reach the partner's FHIR server. Three paths leave from there: a patient existence check before registration, an encounter push when documentation is finalized, and a scheduled Bulk FHIR pull of new partner data. Each path passes through a matching and logging step that records which remote record was matched. Check that every trust boundary has an agreed credential owner and that the logs reveal no more patient data than your audit policy allows.

Credentials, existence checks, encounter pushes and scheduled Bulk FHIR pulls across two organizations.

Securing credentials, scopes and partner data

Syncing Medplum with an external FHIR server gives a single CLI profile or client the ability to read and write patient records across organizational boundaries. The cards below cover where that access lives, how narrowly it is granted, how traffic and logs are protected, and how it is reviewed over time.

CLI profile credential storage

CLI profiles store the credentials used to reach a remote FHIR server, so the profile file is effectively a secret. Confirm where your team's profiles are written on each workstation or build host, who has operating system access to those paths, and whether the file is excluded from backups and shared repositories. Ask the Medplum team which storage behavior applies to your installed CLI version before you rely on it.

External FHIR server docs

Least-privilege scopes on the remote server

The partner server should grant the sync client only the resource types and interactions the workflow needs, such as reading Patient and Encounter for a match check or reading Bulk FHIR exports for one scheduled pull. Write access for finalized encounter pushes should be limited to the specific resource types that flow. Ask the partner to show the granted scopes in writing before go-live.

Client credentials for server-to-server access

Medplum's authentication docs describe client credentials for server-to-server access, which fits unattended sync jobs better than a person's login. Create one client per job or per partner so that revoking one does not interrupt the others. Confirm with the partner how the client secret is issued, rotated and revoked, and who on each side holds it.

Medplum authentication docs

Transport encryption between systems

Every request carrying patient data should travel over TLS between Medplum, the sync runner and the partner endpoint. Check certificate validation settings in the HTTP client and confirm that no job falls back to plain HTTP or disables verification for a test endpoint and forgets to re-enable it. Document which certificate authority the partner uses and who receives notice of certificate changes.

PHI in sync job logs

Sync jobs log request URLs, resource identifiers and error payloads, and these can contain names, dates of birth and identifiers. Set a rule for what each job may print, keep failed-payload dumps out of shared log platforms, and set retention on the log store. Test one failed match in a non-production environment and inspect what was written before enabling the job in production.

Periodic access review

Credentials and scopes drift as partners change contacts and jobs are added. Schedule a review that lists every CLI profile, client, granted scope and job owner, then removes anything that no longer maps to a live partner agreement. Ask the partner for the same list from their side so that both organizations confirm the same access.

Common failures when syncing with Bulk FHIR and external servers

This table lists the failures teams most often hit when Medplum reads from or writes to another FHIR server, with the likely cause and first fix for each. Use it as a triage guide before opening a support case or changing the sync design. The main takeaway is that most failures trace to credentials, version alignment, matching rules, or timing of the push and pull, which are all decisions you can set in advance.

SymptomLikely causeFix
Sync jobs fail with authorization errors after working earlierClient credentials or the CLI profile token have expired, or the client was granted a broader or narrower scope than the export or write needsConfirm the scopes the partner granted, rotate the secret, and store the updated credentials in the CLI profile. Test one read and one write before scheduling the job again.
Records arrive but fields are missing or fail validation on writeThe partner server runs a different FHIR version (for example R4 against STU3) or a different profile than the one Medplum mapped toAsk the partner for its FHIR version and implementation guide, then align resource mappings and profiles before the first live push.
Same patient appears twice on the external serverMatching relies on name and date of birth alone, or on identifiers that differ between systemsMatch on a shared identifier where one exists, and require a second attribute for fallback matches. Route uncertain matches to manual review instead of creating a new Patient.
Encounter appears on the partner server before clinicians finish documentationThe push trigger fires on encounter creation or status changes that are not finalTrigger the write only when the encounter reaches a finalized status agreed with the partner, and make the trigger idempotent so re-sends do not duplicate records.
Bulk export job stays in progress or finishes after the next scheduled runExport volume is larger than expected, the partner throttles requests, or the schedule overlaps with a previous runAsk the partner for expected export size and throttling limits, stagger the schedule, and prevent a new job from starting while an earlier one is still running.
Pull ends with fewer resources than the partner reportsA network interruption or timeout stopped the download partway, and the job did not record which files were completeRecord the export file list and progress per run, resume or re-request only incomplete files, and reconcile counts against the partner before marking the pull successful.

Questions teams ask before syncing Medplum with another FHIR server

What drives the cost of syncing Medplum with an external FHIR server?

The cost depends mainly on how many systems are involved, how different their FHIR data is from Medplum's, and how many business rules must be agreed before any code is written. Work usually splits into discovery with the partner, mapping and matching design, building the connection and jobs, testing against the partner's sandbox, and handover. Most of this is one-time work. Recurring costs come from keeping the connection running, handling partner version changes, maintaining Medplum upgrades, and reviewing failed records. Ask any partner to separate one-time build from recurring support in the written quote, and to list which partner systems and endpoints are in scope.

How long does a first sync between Medplum and another FHIR server take?

The duration is driven by factors rather than a standard figure. The main ones are how quickly the partner gives access to a test environment, how many resource types and profiles must map, how cleanly patients can be matched across the two systems, and how many review cycles the clinical and data owners need. A single one-way push of finalized encounters usually moves faster than a bidirectional sync with scheduled Bulk FHIR pulls, because the latter adds volume testing and failure handling. Ask the partner to tie the timeline to named milestones and to confirm which dependencies sit outside its control.

What does our team need to provide before a partner can start?

A partner needs a named contact on each side, the base endpoints for both FHIR servers, and a test environment that mirrors production as closely as the partner allows. You will also need to supply client credentials with the least access the job requires, along with written sign-off on the mapping between source and target resources. Clinical and data owners should approve matching rules and which encounter statuses trigger a push. Confirm with the partner how credentials will be stored, who can rotate them, and where CLI profiles will live on your machines.

Can an in-house team set up Medplum to talk to another FHIR server?

An experienced FHIR and integration team can build this in-house, and Medplum's external FHIR server documentation covers the core pattern of storing credentials in CLI profiles and calling the other server from Medplum. The harder parts are usually outside the tooling: matching patients reliably, handling partner errors and retries, and getting sign-off from clinical and compliance owners. Consider whether your team has people who know both the partner's FHIR implementation and Medplum's data model, and who can own the connection after go-live. A partner can fill gaps in any of these areas, and an internal team can take over at handover.

How does a scheduled Bulk FHIR pull differ from an event-driven push?

A scheduled Bulk FHIR pull requests a set of data from a partner at fixed intervals, which suits batch-oriented partners and large initial loads. An event-driven push sends a single resource to the partner when something happens in Medplum, such as an encounter being finalized. Pulls are easier to reason about for reconciliation but can lag behind real activity, while pushes are closer to real time but need strong retry and duplicate handling. Many programs use both. Ask the partner which pattern the source system supports, how it handles re-runs, and how failed batches are recovered.

How should we scope a fixed-scope FHIR sync engagement?

Start by writing down the systems in scope, the direction of data flow, the resource types and profiles, the triggers, and what counts as done. DeployOpen works from a written scope with agreed deliverables and timelines before work starts, so the written scope is the main control on cost and schedule. Include testing expectations, the environments used, handover material, and any ongoing support as a separate item. Ask for a quote that lists assumptions and exclusions, such as partner-side changes, so that changes to scope can be priced against the agreed baseline.

What risks should we review before connecting patient data between two servers?

The main risks are mismatched patient records, duplicate resources created by retries, credentials with more access than needed, and data sent to a partner without a documented basis. Review how patients are matched, how conflicts are logged, and who receives alerts when a sync fails. Confirm where audit logs are kept and what the partner is contractually allowed to do with the data. Medplum's compliance documentation describes compliance as a shared responsibility between Medplum and its customers, so the data-sharing agreements and controls for this connection remain your responsibility to confirm with your compliance team.

Official Medplum and HAPI FHIR documentation to read first

Start with the Medplum documentation on connecting to external FHIR servers before you write any sync code. It explains the three scenarios this topic covers: checking whether a new patient already exists on another server, synchronizing finalized encounter documentation, and pulling new partner data on a schedule with a Bulk FHIR API. It also describes how CLI profiles store the credentials for each external server, which is the first decision to settle with your security team. Read it alongside the Medplum external FHIR servers docs and note which profile holds each partner's credentials, who can read them, and how they rotate.

Next, read the Medplum authentication documentation, because every connection to a partner server depends on how Medplum and that server authenticate each other. Pay attention to client credentials for server-to-server access, since a scheduled Bulk FHIR pull typically runs without a user present. Confirm with each partner which grant type, token lifetime and scopes they will issue, and whether they require multi-factor authentication for any human-initiated step. The Medplum authentication docs cover the Medplum side of this. The partner's own documentation covers the rest, and that is the document to request during planning.

Some partners will ask you to run their FHIR server, or you may need a test server to rehearse the sync. HAPI FHIR is an Apache 2.0 licensed Java FHIR server that many organizations use for this purpose, and its JPA server starter supports PostgreSQL and Microsoft SQL Server for production. Before you rely on it, read the HAPI FHIR security introduction. It states that HAPI provides building blocks such as the AuthorizationInterceptor, rather than a single security layer, so the access rules, audit logging and CORS settings are your responsibility to design and verify. Confirm which HAPI FHIR version and JDK your team will support before you start.

How DeployOpen scopes and delivers Medplum FHIR server syncs

DeployOpen plans, builds, tests and documents the connections between a self-hosted Medplum deployment and external FHIR servers inside your own infrastructure. Each engagement starts from a written scope that names the partner servers, the direction of data flow, the credentials and the schedules before any build begins.

How we scope

  • Inventory every external FHIR server, its version, its authorization model and who administers it on the partner side.
  • Define each sync direction, whether checking for a patient, pushing finalized encounters or pulling scheduled Bulk FHIR exports.
  • Agree the patient matching rules, identifier sources and what happens when two records do not match cleanly.

How we build

  • Configure Medplum CLI profiles so credentials are stored per environment and never copied into shared scripts or repositories.
  • Build the sync jobs and error handling, then test them against non-production copies of each partner server before any live data moves.
  • Verify that exported and imported resources validate, that duplicates are caught and that audit records show every transfer.

How we hand over

  • Deliver a written runbook covering each sync job, its schedule, its credentials, its owners and its failure procedures.
  • Document the matching rules, the field mappings and the known limits so your team can review them with the partner.
  • Walk your platform and integration engineers through monitoring, reruns and credential rotation before the handover is closed.

How we support

  • Offer ongoing support for sync jobs, Medplum upgrades and partner server changes as a retainer, if your organization wants it.
  • Retest affected syncs after each Medplum minor version and each change to a partner's FHIR server or Bulk FHIR settings.
  • Confirm with your team which support hours, response paths and access levels apply before the retainer starts.

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.