Why the Medplum migration load order decides whether references resolve
A team moving FHIR or structured clinical data into Medplum needs every reference to point at a resource that already exists, or the load fails or leaves dangling links that surface later in search, access checks and clinical review. The load order is the sequence in which resource types are written so that each reference target is in place before anything refers to it. The default sequence runs organizations and locations first, then practitioners, then patients and coverage, then encounters, then current clinical state such as active conditions, medications and allergies, and finally historical records. That sequence is a starting point, not a fixed rule. How much effort the ordering costs depends mostly on the source data model: a source that stores practitioners inside encounters, or that links coverage to patients through a shared identifier, needs a different plan for resolving those links before the target rows exist.
The order is a property of your data, so the first decision is to inventory every reference your mapping produces and record which resource must exist before it. Each reference type in the mapping register should name its target resource, the identifier used to find it, and what the loader does when the target is missing: hold the dependent record, create a placeholder, or stop the batch. Confirm the reference syntax and conditional create or update behavior you intend to use against the Medplum version your environment runs, because the loader's behavior with conditional writes determines whether a re-run can safely recreate a target. Check the current release notes and the Medplum versions and release policy before you fix the plan, since the version you target sets the rules you can rely on.
Self-hosting and upgrade facts do not change the load order itself. Whether Medplum runs on AWS, Kubernetes or another target, and whether the server is upgraded through each minor version in sequence, the references in your data still have to resolve in dependency order. Those operational questions affect when you run the load and how long post-deploy work takes, so plan them separately, using the Medplum upgrading the server guide for the upgrade path. Treat the dependency order as a design artifact that the pipeline, validation and cutover sections all reuse, and record any deviation from the default order as a reviewed decision with its reason.
Which resource types load first and which references they depend on
This table maps each FHIR resource family in a Medplum load to the references it must resolve before it can load, and notes how to look up each one. Read it top to bottom as the load sequence, and use the migration note column to plan identifier and conditional lookups where the source lacks stable keys.
| Resource family | References it needs first | Migration note on lookup and identifiers |
|---|---|---|
| Organization | None, or parent Organization only if the source has a hierarchy | Load first. Key each record on a stable source identifier so later loads can find it. Confirm conditional create or update behavior in the Medplum docs for your version. |
| Location | Organization (managingOrganization), parent Location if present | Use the same source identifier pattern as Organization. Where sites are free text in the source, create a reference table before loading so Encounter and Schedule lookups resolve. |
| Practitioner and PractitionerRole | Organization for role assignments, Location for site assignments | Source staff IDs often differ across systems such as credentialing and scheduling. Agree one identifier per person before loading, and record the mapping as a crosswalk. |
| Patient | Organization (managingOrganization), general practitioner and linked Patient records where the source has them | Patient matching is the highest-risk lookup. Confirm your match rules before load. Where a source MRN is not unique across facilities, add the issuing system to the identifier. |
| Coverage | Patient (beneficiary), Organization (payor), RelatedPerson or subscriber where used | Policy numbers are often reused or reissued. Key on payor plus member ID plus group where possible, and flag records that lack all three for review. |
| Encounter | Patient, Practitioner, Location, Organization, and Coverage or ServiceRequest where linked | Encounters often lack a stable visit ID in older systems. Build a composite key from patient, start time and facility, and test that key for duplicates on a sample. |
| Observation, Condition and AllergyIntolerance | Patient, Encounter (encounter), Practitioner (performer or recorder) | Clinical items frequently reference encounters by local visit number. Resolve encounter references through your crosswalk, and load orphans to an exception list rather than dropping them. |
| MedicationRequest, ServiceRequest and similar orders | Patient, Encounter, Practitioner (requester), Medication or code references | Medication codes may need terminology mapping before load. Confirm how your Medplum version handles medication references and profile validation. |
| Provenance and history (AuditEvent, prior versions) | The target resources it describes, plus Practitioner or Organization as agent | Load last so every target exists. If the source keeps history, decide whether earlier versions load as history or as a single current state, and confirm version behavior in the Medplum docs. |
How FHIR references and identifiers decide the order
A FHIR reference points from one resource to another, either by logical ID (for example Patient/123) or by a relative or absolute URL. When a loader creates an Encounter that names a Patient the server has not yet stored, the load either fails on that reference or, if the loader stubs the target to keep going, leaves a placeholder that someone must later find and correct. The practical rule is that every target must exist, or have a known ID, before any resource that points at it is written. That rule is what the load order in this section enforces, and it is why the order should be derived from your reference graph rather than copied from a generic checklist.
The reference graph only works if every source record has a stable identifier that survives reruns. Decide, before the first load, whether each Medplum resource ID will be assigned by the server or set by your pipeline. Pre-assigned IDs, usually a deterministic UUID derived from the source system name and the source primary key, let a loader write a reference to an organization or patient that has not been loaded yet, and they make the same source row map to the same Medplum resource every time. Confirm in your own environment how the Medplum server handles client-supplied IDs and conditional updates for each resource type you load. The mechanics of building those IDs belong to the mapping and pipeline work, so check the mapping register and the restartable loader design before fixing the key scheme here.
Idempotency is what makes a failed or partial load safe to repeat. If the loader uses conditional updates keyed on the source identifier, a rerun after a timeout updates the existing resource instead of creating a second Patient for the same person, and references written in an earlier pass still resolve. Test this on a sample before the full run: load a small set of organizations, patients and encounters, rerun the same batch, and confirm the resource counts and reference targets do not change. If your reruns create duplicates, fix the identifier scheme before any dependent resource is loaded, because duplicates discovered after encounters, observations and history reference them are costly to unwind.
When to change the order for your data model
Some legacy systems store everything under the patient and the encounter, with practitioners and facilities held as free text or local codes instead of separate master records. In that case the organization and location layer is thin, so the team can often load the patient and encounter chain earlier, once the minimal organization and location resources exist. The practitioner layer is the part most likely to move, because encounter participants may only be resolvable after a directory has been built from the source.
- Patient and encounter first: Patients can load before practitioners when the encounter participant is stored as text and resolved in a later pass.
- Placeholder practitioners: Where a clinician cannot be matched, teams sometimes create a placeholder resource and update it later. Confirm your acceptance criteria allow this.
- Location minimalism: A single facility location may be enough for early loads. Add finer locations later only if encounters reference them.
- Deferred participant references: Store the unresolved participant in a reconciliation list so the encounter can be updated without a full reload.
- Coverage timing: Coverage can still follow the patient, but confirm whether payer data is needed before encounters are reviewed.
Before changing the order, check how often the source leaves practitioner and location identifiers unresolved, and whether your validation rules reject placeholders.
When several organizations, sites or departments share one practitioner directory or location hierarchy, the organization and location layer becomes a shared dependency rather than a simple prerequisite. The default order still applies within each target tenant, but the team must decide which copy of a practitioner or location is authoritative before any patient data references it. Loading duplicates from each source system is a common reason references fail to reconcile later.
- Master directory first: Build and load the authoritative practitioner and location set before any patient resource is written.
- Identifier crosswalk: Keep a table mapping each source identifier to the Medplum resource ID so later loads resolve the same record.
- Hierarchy order: Load parent locations before child locations, since
partOfreferences must resolve. - Conditional updates: Use conditional create or update keys on shared identifiers so reruns do not create duplicates.
- Ownership rules: Record which source is allowed to change a shared record after cutover.
Before changing the order, confirm the authority matrix for directories, check for duplicate practitioner identifiers across sources, and test that a rerun of the directory load creates no new records.
Some sources embed clinical content inside a parent record, such as allergies, problems, vitals or medications stored as columns or repeating groups on the encounter row. The default order assumes these items are separate resources that reference their parents. When the source does not separate them, the team must extract child resources from the parent row, and this extraction usually has to run after the parent it describes exists. The sequence then follows the extracted resource's dependencies, not the source table layout.
- Parent before extraction: Load the encounter or patient that owns the embedded data first, then extract and load the child observations or conditions.
- One-to-many splitting: A single row may produce several resources. Confirm the mapping register defines which rows yield which resources before the load begins.
- Current state versus history: Inline fields often hold only the latest value. Load them as current state and treat earlier values as history only if the source supplies them.
- Reference integrity checks: Count extracted children against the parent references after each batch.
- Unsupported fields: Some embedded fields may have no clean FHIR target, so route them to documented exception handling.
Before changing the order, check whether the embedded fields carry dates and authors, since missing dates often force a different sequence for history.
Some sources record clinical changes as an append-only event log rather than as current records. Loading the current state first and then replaying the log can produce a patient record that looks correct but has an incorrect history, or that fails when an event refers to a resource that has not yet been created. In these cases the team may need to rebuild the current state from the log, which changes the load order from current first to history first for some resource types.
- Log replay order: Replay events in the sequence the source recorded them so later events update resources created by earlier events.
- Creation events: Load the creating event for each resource before any update event that references it.
- Derived current state: Compute the final state from the log and compare it with the source's current table before accepting the load.
- Event timestamps: Preserve source timestamps in meta or authored fields so the history is visible after migration.
- Idempotent replay: Replay must be restartable, because a partial replay can leave resources in an intermediate state.
Before changing the order, confirm that the event log is complete for the date range in scope, and that the current-state table agrees with the replayed result for a sample of patients.
How to run the load in sequence with a parallel run and cutover
The sequence turns a dependency-ordered load into a checked, repeatable process: each phase is reconciled before the next begins, and a parallel run against a production copy proves the cutover before the source is retired.
Inventory resource types and the dependency graph
The data team lists every FHIR resource type in scope, the source table or export that feeds it, and each reference it carries (for example, Encounter to Patient, Location and Practitioner, or Observation to Encounter). The output is a dependency graph and a load-phase assignment for each type, reviewed by the clinical data owner and the integration lead. The step is done when every reference field in the mapping register points to a resource type loaded in an earlier phase, or is explicitly deferred to a later reconciliation pass.
Load reference data in a rehearsal environment
Stand up a non-production Medplum server, sized and configured the way the planned production deployment is, and load Organization, Location and Practitioner data first. Confirm that the Medplum deployment and version match what production will run, because self-hosted Medplum upgrades must follow the documented minor-version sequence. Check the Medplum upgrading guide before any version change mid-project and confirm the steps against your own environment. The step is done when reference resources load without unresolved references and the rehearsal server's counts match the source extract.
Run the default order in batches per phase
Load each phase in the order set by the dependency graph: organizations and locations, practitioners, patients and coverage, encounters, current clinical state, then history. Each phase runs in batches using the pipeline's conditional-update and retry logic, so a failed batch can be rerun without duplicating resources. The loader logs the batch identifiers and the source keys it has processed. The phase is done when every batch has completed or been logged as an exception with a reason.
Reconcile reference counts after each phase
Before the next phase starts, the team counts resources of each type loaded, checks that every reference in the phase resolves to a resource that exists in Medplum, and compares the totals with the source manifest. Dangling references and count gaps are recorded as exceptions with an owner and a fix. The phase gate is passed only when the exception list has no unresolved reference that a later phase depends on. This gate is what prevents a missing Patient from surfacing months later as a broken Encounter.
Run a parallel load against a production copy
Take a recent copy of production source data and run the full sequence end to end against a Medplum environment configured like production. Compare the resulting counts, reference checks and sampled whole-chart reviews with the source. Time each phase and record the throughput, which becomes the input to the cutover timeline. Confirm that any Bot or Subscription side effects triggered during the load are suppressed or accounted for in the rehearsal. The parallel run is complete when two consecutive runs produce the same reconciled results and the open exception list is accepted by the business owner.
Cut over and decommission the source
At the agreed cutover window, freeze writes to the source, run the delta load for changes since the last extract, repeat the reconciliation gate, and switch the users and integrations to Medplum. Keep the source read-only for a defined rollback period so the team can revert if a reconciliation or clinical check fails. The cutover is confirmed when the post-switch reconciliation passes and the business owner signs the cutover record. Decommissioning follows only after that record exists and the rollback period has closed.
Each load phase must reconcile before the next one starts
The load starts with reference data, Organization and Location, because every later resource points back to them. Practitioners, Patients and Coverage come next, then Encounters, then current clinical state, and history last. A reconciliation gate sits after each phase, and the next phase does not begin until its gate passes. At each gate, check that resource counts match the manifest and that every reference from the loaded phase resolves to a stored resource. Failed references stop the load before they spread into later phases.
Each phase depends on the reconciliation gate before it.
What drives the effort and duration of the load order
This table compares the factors that change how much work a Medplum load order takes, who usually carries each piece, and what to ask for in a quote. Read each row as a question to settle in discovery, because the answers set the reference-resolution workload before any loader is written.
| Driver | Why it changes effort | Who does the work and what to ask for |
|---|---|---|
| Source systems feeding shared reference data | Each system that holds its own organizations, locations or practitioners adds a matching step and a second source of truth to reconcile before dependent resources can load. | Client supplies system owners and extracts. Partner maps each source to one reference set. Ask the quote to list each source and who signs off its reference data. |
| Quality of source identifiers | Missing or unstable identifiers force fallback matching on name, date of birth or NPI-style fields, which slows loads and raises the exception queue. | Both. Client confirms identifier rules and authority per source. Partner writes matching logic and logs exceptions. Ask for the matching rules to be documented before pipeline work starts. |
| Share of records with unresolved or duplicate practitioners and locations | Encounters, coverage and clinical resources reference these entities, so every unresolved reference blocks or delays a dependent batch until someone decides the match. | Client clinical or operations staff make match decisions. Partner builds the review queue and reruns affected loads. Ask how unresolved references are held, reported and released. |
| Volume of history | Historical encounters and clinical records multiply the number of references to check and the time each load run takes, so the order must still hold across large batches. | Partner sizes batches and measures throughput on a sample. Client confirms retention scope and which years are in the cutover. Ask the quote to state the history window and the throughput test it assumes. |
| Number of custom profiles | Custom StructureDefinitions or required extensions change which fields must be populated before a resource is accepted, so load order may change when a profile requires a parent resource first. | Both. Client defines the profile rules and their owners. Partner validates resources against them and adjusts sequencing. Ask whether profile changes are in scope and how many profiles are covered. |
| Reconciliation and sign-off workload | Each load stage needs reference count checks and dependency checks before the next stage starts, and each stage needs a named approver. | Partner runs reconciliation and prepares evidence. Client approves each stage and the final load. Ask for the reconciliation checks, the approver list and the sign-off points in writing. |
What usually goes wrong when the load order is wrong
Most failed Medplum loads trace back to a small set of sequencing and rerun mistakes. The risks below share one root cause: a resource reached Medplum before the resources it points to, or a run was repeated without a guard against duplicates. Each card names the check that catches it before it reaches production.
Orphaned references from early encounters
Encounters, observations and claims loaded before their Patient, Practitioner or Location exist store references that point at nothing. The load may report success while the chart shows clinical events with no patient attached. Before each phase, query for references that do not resolve and hold the next phase until the count is zero. Use a manifest that records each source ID and its Medplum ID so a missing parent is visible at once, not during clinician review.
Duplicate practitioners on rerun
A loader that calls create instead of a conditional update will generate a second Practitioner each time a batch is retried after a timeout. Downstream encounters then split across two identities, and access policies and reporting follow the wrong one. Prevent this with conditional updates keyed on a stable source identifier, so a repeated run updates the existing resource. Confirm the identifier system is unique per source and that the loader logs every create.
History overwriting current state
If historical versions load after current clinical state, older values can become the latest version of a resource, and medications or problem lists quietly revert. The fix is a phase gate: load current state first, then append history in an order that never replaces the newest version. Check that the current version of each sampled resource matches the source's most recent record after every history batch.
Placeholder resources left in production
Teams often create stub Patients, Organizations or Locations so references resolve during a partial load. If those stubs are never replaced or removed, they appear in search, billing and clinician lists as real records. Tag every placeholder with a meta tag that marks it temporary, and make the cutover checklist include a query that finds and resolves each tagged resource. Treat any remaining placeholder as a failed gate.
Reconciliation skipped after partial loads
A load that stops midway and is resumed later can look complete because the job exited cleanly. Counts by resource type may differ from the source only in the phase that failed, and nobody compares them. Run count and reference reconciliation at the end of every phase, not only at cutover, and record the result against the phase's acceptance criteria. A phase that does not reconcile should block the next phase from starting.
Questions teams ask before loading FHIR data into Medplum
How much does a load order review cost, and what drives the price?
A load order review is priced from a written scope, so there is no fixed figure to quote here. The cost follows the number of source systems, the resource types in play, how many reference chains cross systems, and whether the review includes a test load. Work is one-time for the review itself, while any ongoing support after cutover is a separate retainer. DeployOpen does not publish a price list. Ask for a quote that lists the source systems covered, the resource types in the load sequence, the deliverable (a written order with dependency rules), and whether a sample load against a non-production Medplum project is included.
How long does load order work take, and what sets the timeline?
The timeline depends on how many resource types reference each other and how clean the source identifiers are. Teams with one source system and stable patient identifiers finish faster than teams merging several systems with duplicate patients. The main inputs are the source inventory, the agreed mapping of references, the number of dependency loops that need a workaround, and the time to run test loads and check results. Ask for a schedule that names each milestone and the client dependencies behind it, and confirm how many test loads are included before cutover.
What must our team provide before a load order review starts?
Three inputs decide how quickly the review can produce a usable order. First, read access to source data or a representative export, including the tables or files that hold the links between patients, encounters and clinical records. Second, written identifier rules: which source identifiers become Medplum identifiers, which system owns them, and how duplicate patients are resolved. Third, clinical sign-off on which historical records are in scope and which statuses, such as active medications or open problems, must load first. Without the third input, the order can be technically valid but load the wrong current state.
Can our internal team run the load order work without a partner?
Yes, a capable internal team can define the load order, provided it has FHIR R4 experience, access to Medplum's documentation, and someone who understands the source data model. The work involves mapping each source relationship to a Medplum reference, deciding how to handle references that point forward, and testing the sequence on a non-production project. Teams without a FHIR specialist usually spend the most time on reference cycles and on the clinical decisions about current state versus history. Confirm internal skills against those tasks before deciding, and check whether a partner review of the finished order is more useful than running the whole project.
Does the load order change depending on our source system?
Yes. The core sequence of organizations and locations, then practitioners, patients and coverage, then encounters and clinical state, stays broadly the same, but the details shift with the source. A source that stores locations inside encounter records needs a different extraction step. A source that keeps patient identity in a master index needs matching rules before patients load. A source that sends HL7 v2 messages, such as ADT feeds, may need a different ordering for historical and live data. Ask the reviewer to show which dependencies come from your source and which come from the FHIR model.
How does load order relate to acceptance testing after the load?
Load order decides whether references resolve when each resource is written, while acceptance testing checks whether the loaded data is complete and correct afterward. The two depend on each other. If the order is right, reference counts should match the source, and any unresolved reference is a finding that points back to the load sequence or to the source data. Define acceptance criteria before the first load, including reference reconciliation checks, so that a failed check can be traced to a step in the order. Confirm with the team that will run acceptance testing which reports they need from each load run.
Which Medplum version should we target when planning the load?
Plan against the Medplum version you will run in production, and confirm it before writing the load order, because version changes can affect validation and search behavior. The latest release at research time was version 5.2.5, published on October 15, 2026. Check the current release notes on the GitHub releases page before you finalize the plan, and confirm with your own environment how the server, database and load tooling were tested together.
How DeployOpen scopes and delivers the Medplum load
DeployOpen plans, implements and documents self-hosted open-source platforms inside the client's own infrastructure, and the Medplum load order is handled the same way. We agree the resource sequence, reference rules and exception handling in writing before build work starts, then test and hand over the load with its runbook.
How we scope
- Engagements are fixed-scope, with the resource sequence, source systems and deliverables agreed in writing before work starts.
- The scope names which resource types load in each stage, and which references must resolve before a stage can close.
- Your data model decides where the default order changes, so we record each deviation and the reason in the scope document.
How we build
- We build the stage-by-stage loaders against your own Medplum project, with a dry run that checks reference resolution before any real data moves.
- Each stage runs in a fixed order, so organizations and locations exist before practitioners, and patients exist before coverage and encounters.
- Test loads on a copy of your data show where unresolved references, duplicate patients or missing practitioners appear, and we fix them before the production run.
How we hand over
- You receive the load order document, the mapping of source fields to references, and the loader code in a repository you control.
- The runbook covers each stage's entry and exit checks, rerun steps and the log output that confirms every reference resolved.
- Your team walks through a rehearsal of the full load with us, so the people who will run the production load have done it once.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, including reruns when your source data changes.
- Because Medplum upgrades must pass through each minor version in sequence, we can plan load steps against the version you run.
- Ask any partner for the written scope, the named deliverables and the retainer terms, and confirm which of them your team will own after go-live.

