Migrating clinical documents and binary files into Medplum

A planning guide for moving scanned documents, PDFs and images into Medplum Binary and DocumentReference resources, with the checks that prove each file is complete, linked and protected.

On this page

How a clinical document migration into Medplum changes the work

A clinical document migration into Medplum is less about copying files than about proving that each file can still be opened, found and read by the right people after the move. Legacy systems often hold years of scanned consent forms, referral letters, lab PDFs and image captures, and each one has to land as a Binary with a linked DocumentReference that points to the correct encounter and carries access controls that match the source. The work changes because Medplum stores the file and its metadata as separate resources, so a load can report success while the document itself is wrong. A DocumentReference can look complete while its file is truncated, unreadable, attached to the wrong encounter or inaccessible, and the acceptance guide recommends opening sampled files and verifying content type, size and hash rather than trusting record counts.

The effort is driven by three things you can measure before any code is written: the number of files, the storage format of the source system, and how much linkage cleanup the legacy data needs. A file count alone says little if many documents are multi-page scans that must be reassembled, or if the source stores pages as separate images with no reliable order. Source storage also matters. Files held as database blobs, on a network share, or in a vendor document store each need a different extraction path and a different way to confirm the bytes survived. Linkage is often the largest unknown, because encounter identifiers may be missing, duplicated or only present in free text. Ask your team to profile these three factors on a representative extract, and confirm with your own compliance and records staff how the source system records the link between a document and its visit.

Which document capabilities map cleanly to Medplum and which need design

This table compares common capabilities of a document management source with Medplum Binary and DocumentReference resources. Rows marked as direct map cleanly, while rows that need design call for decisions you make before the load, not after it. The main takeaway is that per-document access rules and folder-based permissions must be rebuilt as securityContext and access policy design rather than copied.

Source capabilityMedplum equivalentWhat to decide
Document index record (ID, type, date, patient)DocumentReference with identifier, type, date and subjectKeep the source document ID as an identifier so the record can be traced back to the source index.
File storage path or blob locationBinary resource holding the file content, referenced by DocumentReference.content.attachmentThe path itself does not carry over. Store the original path as an identifier or extension if audits need it.
Multi-page scan (one file per page or one PDF)One Binary per file, with pages either merged into one PDF or linked as separate DocumentReference content entriesDecide whether a page set is one document or many before loading, and keep the page order explicit.
Document type or class codeDocumentReference.type and category using agreed terminologyMap local codes to a standard code set in the mapping register. Unmapped codes need a documented fallback.
Encounter or visit linkDocumentReference.context.encounter pointing to a loaded EncounterLoad Encounters before documents. Confirm the link is correct because a wrong encounter is a common silent error.
Author and document date fieldsDocumentReference.author and date fieldsConfirm whether the source date is document date, scan date or upload date, since they are often mixed up.
Content type and file sizeBinary.contentType and attachment size metadataConfirm the source content type is accurate for every file, not just what the extension suggests.
Hash or checksum of the fileAttachment hash field, computed from the source bytes before loadCompute hashes from the original file so the loaded copy can be verified against them later.
Folder-based permissionsNo direct equivalent. Access comes from projects, access policies and the Binary securityContextDesign the access model from the rules in use, not from folder names. Folder structure alone is not an access rule.
Per-document access rules (confidential, sensitive, restricted)Binary securityContext linked to the related patient or encounter, plus access policiesBinary resources cannot use compartment-based access policies. Without a securityContext they fall back to project-level access, so each category needs a designed rule.
Document-level audit trailMedplum audit events for reads and writes, plus any source history you keepConfirm which source history must be preserved as provenance and which is retired with the source.

How Binary and DocumentReference resources hold a migrated file

A migrated document lives in Medplum as two linked resources: a Binary that carries the file bytes and a DocumentReference that describes the file and says where it belongs in the record. The DocumentReference is what clinicians and applications search for, while the Binary is only retrieved through the reference it points to. Your mapping register should therefore carry two sets of values for every file: the bytes and their metadata (content type, size, hash), and the clinical context (subject patient, author, date, status, type code, and any encounter or context link). Confirm the exact field names and which fields are required for your Medplum version against the Medplum docs before you write the loader, because the resource model is the contract your acceptance checks will test against.

The DocumentReference carries the descriptive fields: subject for the patient, content entries that point to the Binary through attachment.url and declare attachment.contentType, attachment.size and attachment.hash, and context.encounter for the encounter the document belongs to. Record the hash as computed from the source file at extraction time, so a later check can detect a truncated or altered copy. Keep the DocumentReference pointing at the correct Binary identifier, since a mismatch produces a record that looks complete while showing the wrong document. Your migration manifest should keep the source document ID, the Binary ID and the DocumentReference ID together so each pair can be reconciled.

Multi-page scans force a design decision: store one PDF per document containing all pages, or one file per page linked from a single DocumentReference. A single multi-page PDF keeps the document intact, gives one hash to verify and one content type, and is usually simpler to review in the chart. One file per page suits sources where pages were captured or signed separately, but it multiplies Binary and reference counts and makes page order a field you must map and test. Whichever you choose, document the rule in the mapping register and apply it to every source, and confirm with the Medplum docs how your version handles large or multiple attachments before you commit to it.

Documented import paths for binary files and their metadata

Scanned documents and PDFs that sit on a file share usually have no reliable metadata of their own, so the loader must derive the patient, encounter and document type from a manifest or a folder convention. Each file is read from disk, uploaded as a Binary resource through the FHIR API, and then referenced by a DocumentReference that carries the metadata. Batch or transaction bundles can group several files for one patient, and conditional creates keep a rerun from duplicating a document that already loaded.

  • Manifest first: Build a manifest that maps each file path to a patient identifier, encounter identifier, document type and date before any upload starts.
  • Binary then DocumentReference: Create the Binary with the file's content type, then a DocumentReference that points to it through its attachment URL.
  • Conditional creates: Use a conditional create keyed on the source file identifier so a second run does not duplicate the document.
  • Bundles by patient: Group related uploads into batch or transaction bundles, and confirm which bundle type fits your error handling.
  • Share access: Confirm the service account can read the share and that paths with unusual characters are handled before the run.

Confirm the current bulk or file import tooling in the Medplum migration docs before assuming a file importer exists for your share layout.

Sequence for moving documents with a sampled acceptance gate

This sequence moves scanned documents, PDFs and images into Medplum without trusting DocumentReference records at face value. Each stage produces evidence that the files open, match their recorded hashes, attach to the right patient and encounter, and stay behind the right access controls before the legacy store is retired.

  1. Inventory document classes and file formats

    The migration lead and the records or HIM team list every document class in the legacy store, such as consent forms, scanned referrals, lab PDFs and intake images, along with the file formats, page counts, size ranges and the encounter or patient each class attaches to. Each class gets an owner who can answer questions about its content. The step is done when every class has a format list, a volume estimate pulled from the source system, and a named owner, and when classes with unknown formats are flagged for investigation before any load.

  2. Define content checks and capture hashes at extraction

    The data engineering team writes the extraction routine so that each file is read from the legacy store, its content type is detected from the bytes rather than the file extension, its size is recorded, and a cryptographic hash is calculated before anything is uploaded. The source hash, size and detected type go into the migration manifest with the legacy document identifier. The step is done when a test run over a small sample produces a manifest row for every file and any file that fails detection is routed to an exception list rather than silently loaded.

  3. Pilot one document class

    The team loads a single, low-risk document class, such as scanned consent forms, through the Binary upload and DocumentReference creation path in a non-production Medplum project. The pilot checks that uploads succeed, that multi-page files stay as one document rather than being split, and that the DocumentReference carries the expected status, type and date. The step is done when the pilot run completes with a reconciled count of loaded files against the manifest and the exception list is reviewed and explained.

  4. Open sampled files and verify content

    Reviewers draw a sample of loaded files from the pilot, stratified by document class and file size, and open each one in the Medplum client. For every sampled file they confirm the file opens, the page count matches the source, the content type matches the detected type, the size matches the manifest and the stored hash matches the source hash. Medplum's acceptance guidance warns that a DocumentReference can look correct while its file is truncated or unreadable, so the sample must open the file itself. The step is done when every sampled file passes or has a documented defect with a fix and a retest.

  5. Check encounter and patient links

    The team runs a script against the loaded DocumentReferences that compares each subject and context reference with the patient and encounter identifiers in the source manifest, then samples charts to confirm documents appear under the correct encounter. Records with missing, duplicate or mismatched links are held for review and corrected in the mapping, not patched by hand in production. The step is done when reference counts reconcile, every mismatch has a disposition, and a reviewer has confirmed the sampled charts show the right documents against the right visits.

  6. Set securityContext and test access

    The security and platform team sets the securityContext on each Binary and DocumentReference so access follows the compartment of the patient or encounter, since Binary resources cannot use compartment-based access policies and otherwise fall back to project-level access. Testers then sign in as users from each role and attempt to read documents they should and should not see, including from outside their care team. The step is done when every role's access matches the written access matrix, and the test results are kept as evidence for the access review.

  7. Run a parallel check against the legacy viewer

    For a defined period agreed in the cutover plan, clinicians and HIM staff open the same documents in the legacy viewer and in Medplum, and reviewers record any document that differs in content, page count, date or visibility. New documents are loaded to both stores during this window so that the comparison stays current. The step is done when the parallel run has no unresolved differences, each recorded defect has been fixed and retested, and the business owners sign off on the cutover.

  8. Cut over and retire the legacy file store

    The team switches document reads to Medplum, keeps the legacy store read-only for rollback, and confirms that document access logs and audit records in Medplum reflect real use. The legacy file store is decommissioned only after the retention rules for each document class have been met and the records team has approved disposal, with a final hash check and a recorded disposition for each archive. The step is done when the legacy store has been removed or archived under the approved retention schedule, and the decommissioning record is kept with the migration evidence.

How a document moves from source store to verified DocumentReference

The flow starts at the legacy file store and its index export, then passes through hash and content checks in a staging area outside the Medplum project. Files that pass become Binary resources, followed by DocumentReferences that link the subject and encounter and carry a securityContext. A sampling gate opens each batch: a failed sample routes the batch to a rework queue instead of acceptance, so a DocumentReference that looks correct is never accepted on metadata alone.

Trust boundary separates the staging checks from the Medplum project that stores verified documents.

Why binary files need a securityContext before go-live

Medplum's access model for clinical documents is different from the one for structured resources, so a migrated file can be reachable by more people than its DocumentReference suggests. The cards below cover the access gap, the fallback behavior, how to scope the securityContext, the test you should run and the audit question to settle before cutover.

Compartment policies do not apply to binaries

Binary resources in Medplum cannot use compartment-based access policies, which is how many teams restrict patient records to the right users. A rule that works for Patient, Encounter and Observation data does not protect the file itself. Plan access for each binary separately, and do not assume that a restrictive policy on the related DocumentReference covers the file content.

Binary security context docs

Missing context falls back to project access

A binary loaded without a securityContext falls back to project-level access, so anyone with access to the project can potentially open the file. This is the most common gap in a document migration because the load succeeds and the DocumentReference looks correct. Make a check for a securityContext on every binary part of the load acceptance, and treat any file without one as a blocker.

Context must match the document's scope

The securityContext should reference the same patient or encounter the DocumentReference is scoped to. A scanned discharge summary for one patient tagged to another patient's record would expose clinical content to the wrong people. Before go-live, compare each file's securityContext with its DocumentReference subject and encounter in a sample, and in a full scripted check where the volume allows.

Test access with non-admin users

Admin accounts and project owners can usually open everything, so a test run with them proves little. Sign in as clinicians, front-desk staff, patients and external clients who should be blocked, then request sampled binaries from each role. Record which requests succeed and which are denied, and compare the results with the access matrix agreed during planning.

Confirm audit of file access

Ask whether your target deployment records which user opened which binary, and when, before you accept migrated documents. Medplum's compliance documentation places part of the control set on the customer in a shared responsibility model, so the audit trail for file access is a question for your own environment. Confirm it with Medplum and your compliance team, then include a test read in the acceptance script.

Medplum compliance docs

What drives the effort of a document migration

This table lists the factors that change how much work a clinical document migration into Medplum takes, what raises or lowers each one, and what to request in a written quote. Read each row as a question to answer about your archive before you ask for a fixed-scope proposal.

DriverWhat raises it or lowers itWhat to ask for in a written quote
Total file count and total bytesLarge archives mean more upload, hashing and verification runs. Consolidated or de-duplicated source sets reduce both.Load plan with file count and byte totals per batch, and the upload window assumed for the Binary writes.
Distinct formats and scan qualitiesEach extra format (TIFF, multi-page PDF, JPEG, faxed images) or low-resolution scan adds conversion, content-type checks and exception handling.A format inventory with counts per type, and the rule for files that cannot be opened or rendered.
Multi-page filesDocuments split across pages or stored as one file per page need different grouping rules before a single DocumentReference is created.Written grouping rules and a sample showing how page sets map to one document.
Encounter linkage the source does not recordFiles with no encounter key require matching by date, patient and note text, which adds manual review and an exception queue.The matching rules, the expected share of unlinked files, and who makes the final decision on ambiguous links.
Hashes at sourceExisting checksums let the team compare stored bytes against the source. Without them, the team must compute hashes during extraction, which adds a step and a baseline to record.Confirmation of which hash algorithm is recorded and whether it is computed before or after any file conversion.
Access rules to re-create as securityContextEach distinct access rule in the source needs a securityContext on the Binary and an equivalent reference on the DocumentReference. Compartment-based rules do not apply to Binary resources, so more rules mean more mapping and testing.A rule-by-rule mapping table and a test plan showing that a user without access cannot read a sampled file.
Retention and legal hold rulesRetention periods, legal holds and deletion rules that differ by document type add handling logic and may require files to be kept out of the normal load.Written retention schedule by document type, the legal hold list, and how held files are flagged and excluded from deletion.
Sample size for acceptanceA larger sample gives more confidence but adds reviewer time. Stratifying the sample by format, source system and encounter type adds effort but catches defects that a random sample can miss.The sampling method, the content checks per sampled file (type, size, hash, readability), the reviewer roles, and the pass criteria written before the load.

Questions teams ask before moving documents into Medplum

How much does it cost to move scanned documents into Medplum?

Cost depends mostly on how many file formats, how many documents, and how many links to encounters you need to rebuild, because those drive the mapping, loader and checking work. The cost has two parts: one-time work to build and run the transfer and checks, and recurring costs for the hosting you choose. Medplum's hosted plans are listed on its pricing page, and self-hosting is free as a Community option or custom-priced as Enterprise Self-Hosted, so the platform fee differs by deployment model. Ask any partner for a quote built from a written scope that lists file types, volumes, encounter links and the acceptance sample size.

How long does a document migration into Medplum take?

Duration is set by the number of files, the state of the source archive, and how much of the work is manual review. Large archives with inconsistent naming, mixed scan quality or unclear patient matching take longer, because each exception needs a decision before the file can load. Scanned images also need time for content checks and sampling, which happen before cutover. No duration is fixed by the platform itself. Ask for a timeline that separates discovery, the loader build, test loads, sampled acceptance and the final load, and confirm which of those steps your team will own.

What does our team need to provide for a document migration?

Your team needs to supply access to the source document store, the rules for which patient and encounter each file belongs to, and people who can decide on unclear files. Someone must also confirm the document types, retention rules and access groups that should apply to each binary. On the Medplum side, you need a running environment, a project structure, and a defined access model for the securityContext on each Binary. Without clear ownership of these inputs, the loader will stall on exceptions that nobody is authorized to resolve.

Can our internal team migrate documents into Medplum without a partner?

Yes, an internal team can do this if it has engineers who can write loaders and clinical staff who can judge file correctness. The work that is easiest to underestimate is verification: opening sampled files, checking content type, size and hash, and confirming that each DocumentReference points to the right encounter and is readable by the right users. Teams that have not handled this before often find the access setup and exception handling take the most time. A partner can take on any part of the scope, including the checks, under a written agreement.

How many files should we open when sampling migrated documents?

The sample size should be set in your acceptance criteria before the load runs, and it should cover each document type, source system and file age range in the archive. Medplum's testing and acceptance guide recommends opening sampled files and verifying content type, size and hash, because a DocumentReference can look correct while its file is truncated, unreadable, linked to the wrong encounter or inaccessible. Random samples alone can miss rare formats, so add targeted samples for multi-page files and any category with known problems. Agree the number and selection method in writing with your compliance and clinical owners.

What happens to scans that cannot be read after migration?

Unreadable scans should be recorded in an exception log rather than loaded silently, with the source identifier, the failure reason and a named owner who decides the next step. Common outcomes are re-scanning from paper, re-export from the source system, or keeping the original file in archive storage with a note in the record. The acceptance guide's warning about truncated or unreadable files applies here, so a successful load does not prove the file is usable. Your reconciliation report should show the count of exceptions and their disposition before cutover.

Does choosing Medplum Cloud or self-hosting change the document work?

The file-level checks stay the same, but the access and infrastructure work changes. Binary resources cannot use compartment-based access policies and need a securityContext, and without one they fall back to project-level access, so this setup must be designed and tested whichever hosting model you pick. On self-hosting, your team also owns storage configuration, backups and the compliance controls for stored files, while Medplum's compliance documentation describes compliance as a shared responsibility between Medplum and its customers. Confirm the storage location, encryption and backup approach with your platform and compliance teams before the load starts.

What usually goes wrong with migrated clinical documents

Document migrations usually fail quietly. The metadata looks right, the load reports success, and the problem surfaces only when a clinician opens a chart. The cards below cover the failure points we see most often and the check that prevents each one.

Truncated files that look correct

A DocumentReference can carry a plausible title, date and content type while the binary behind it is cut short or unreadable. Counts and metadata checks will not catch this. Prevent it by opening a sample of migrated files from each source system and comparing size and hash against the source copy before the load is accepted. Confirm that your sample covers scanned faxes, large PDFs and image formats separately.

Acceptance guide

Documents linked to the wrong encounter

Encounter links are often built from legacy visit numbers, and a mismatch between identifier systems can attach a document to a neighboring visit or to none. A clinician then finds a discharge summary under the wrong admission. Prevent it by reconciling the encounter reference for every document against the source visit key, and by reporting any document whose encounter could not be resolved as an exception rather than loading it unlinked.

Binaries left under project-level access

Binary resources cannot use compartment-based access policies. Without a securityContext, a binary falls back to project-level access, which can expose clinical files to users who can read nothing else about the patient. Prevent it by setting securityContext on every migrated binary according to the access model you designed, then testing reads as a restricted user who should not see the chart.

Binary security context docs

Lost page order in multi-page files

A multi-page scan is only useful if pages arrive in their original sequence. Splitting or re-merging files during transfer can reorder pages or drop the last sheet, and the resulting document looks complete at a glance. Prevent it by recording page count and page sequence in the manifest for each source file, then checking the loaded document page by page against the source in your sample review.

Hash mismatches after transfer

Files can change between export and load when a copy step re-encodes, compresses or truncates them, or when a retry writes a partial object. Without a stored source hash, nobody can tell whether the file in Medplum is the file the source held. Prevent it by computing hashes at export, carrying them in the manifest, and treating any mismatch after load as a failed record to reload, not a warning to note.

Acceptance that only counts records

Matching record counts prove that the loader ran, not that documents are usable. A migration can reach a 100 percent count match and still hold unreadable files, wrong links and open access. Prevent it by writing acceptance criteria that include content type, size, hash, encounter linkage and access checks, and by requiring a whole-chart review on a sample before cutover is approved.

What the client provides and what DeployOpen handles

The client's team supplies the source material and the rules that decide what each file means. That means read access to the document store or export (scanned images, PDFs, faxes, and their index tables), a written list of document types with the codes that classify them, and the rules that tie each file to a patient and, where it applies, an encounter. Your clinical informatics or HIM lead owns those rules, because a wrong encounter link is hard to spot later. The client also decides retention for each document class, including which documents move at all, which stay in the legacy archive, and how long superseded or duplicate copies are kept. Sign-off on the sampled files is the last input, and it has to come from a named person with authority over the records, not only from the migration team.

DeployOpen plans and builds the transfer, then documents it so your compliance and security reviewers can follow each step. The work covers the extraction and upload scripts, the hash and content-type checks run before and after upload, the handling of multi-page files as single Binary resources, the DocumentReference mapping and encounter links, and the securityContext set on every Binary so access follows the source record rather than falling back to project-level access. DeployOpen also produces the sampling plan, the acceptance worksheet and the exception log, and runs the sample reviews with your reviewers. DeployOpen does not issue an audit report, attestation or certification for the result. Where your program needs an outside assessment of the records, confirm with your auditor or certification body what evidence they will accept before the work begins.

Confirm these items in the written scope before work starts: who owns each sign-off, how many sampled files each reviewer will open, which systems keep the originals after cutover, and what the retention period is for each document class. These choices set the cost and duration of the engagement more than the file count does. Ask any partner, DeployOpen included, to state in the quote which of these items it covers and which remain with your team, and to list the artifacts you will receive at the end.

How DeployOpen scopes and delivers a document migration

DeployOpen plans, builds, tests and hands over document migrations into Medplum inside the client's own infrastructure. The work starts with a written scope that names the source repositories, file types and access rules, then moves through a tested loader, sampled acceptance checks and documented operations for the team that will run it.

How we scope

  • Inventory the source document stores, file formats, page counts and encounter links that the migration must carry across.
  • Agree in writing which content checks, hash rules and sample sizes define acceptance for documents in Medplum.
  • Define the securityContext rules for each document class so binaries do not fall back to project-level access.

How we build

  • Build the loader that writes Binary and DocumentReference resources, including multi-page handling and encounter references.
  • Record content type, size and hash for every file so each load can be checked against its source.
  • Test the pipeline on a representative copy of the data before any production run, with restartable batches.

How we hand over

  • Deliver the mapping register, loader code and acceptance report with the sampled files and their verification results.
  • Document the securityContext configuration and the access tests that confirm restricted documents stay restricted.
  • Train your team to rerun sampling, investigate exceptions and extend the loader for later document batches.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer after the migration closes.
  • Confirm with your compliance team which records of acceptance and access testing they need to keep for review.

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.