How NDJSON bulk exports load into HAPI FHIR and what drives the effort
Loading exported FHIR data into a self-hosted HAPI FHIR JPA server is a conversion and verification job. The effort depends on data volume, the mix of resource types, whether references between resources resolve, and the FHIR version the source server used. Those four factors decide how much of the work is scripted, how long the load runs, and how much manual reconciliation follows.
A FHIR bulk export writes one JSON resource per line, with files grouped by resource type, so a Patient file, an Observation file and an Encounter file each hold a different kind of record. HAPI FHIR does not read that layout directly. It accepts resources through its REST API, one resource at a time, or through transaction bundles that carry many resources in one request. The loader therefore has to read each line, wrap resources in bundles, decide whether each entry is a create or an update, and submit the bundles in an order the server can accept. Each of those choices affects both correctness and throughput.
The sections that follow cover the decisions in that order: how IDs and references are preserved, how load order is set, how throughput is tuned, and how completeness is checked after the load. Start by confirming which FHIR release your source server exported and which HAPI FHIR version you plan to run, since the HAPI FHIR versions page lists the Java and release requirements you must match before any loading starts.
What maps cleanly from an NDJSON export and what does not
This table compares the elements of a FHIR bulk export with how a HAPI FHIR JPA server stores and handles them after loading. Read each row as a check to run before loading, since the rows marked as needing confirmation depend on your target configuration. The main takeaway is that resource content and IDs usually carry over, while search behavior, custom operations, partitioning and validation need explicit decisions.
| Element | Source export | HAPI FHIR JPA equivalent and migration note |
|---|---|---|
| Resource files by type | One NDJSON file per resource type, each line a complete resource | Each line becomes one resource through a transaction bundle or create call. Split large files into batches and load in dependency order. |
| Resource IDs | Logical IDs as exported by the source server | Preserved only when the load uses PUT or a bundle that keeps the ID. Confirm that the server accepts client-assigned IDs before loading. |
| Logical references | References such as Patient/123 that point to other exported resources | Resolve if the target resource exists. Load referenced types first, or the reference points to nothing until the target arrives. |
| FHIR version | Version recorded by the source server, such as R4 or R5 | The JPA server supports DSTU2, DSTU3, R4, R4B and R5. Align source and target versions before loading, because resources do not convert between versions on load. |
| Extensions and profiles | Extensions and meta.profile claims carried in each resource | Extensions are stored as content. Profile validation on write is a separate setting, so decide whether to enforce it, validate after load or skip it. |
| Search parameters | Source server search behavior and custom parameters | Standard parameters are indexed on load, but custom and non-standard parameters need explicit configuration. Confirm parity against the target configuration rather than assuming it. |
| History and versions | Exports usually contain current versions only | Version history from the source is generally not in the export. Confirm what your source export includes and what your audit requirements expect. |
| Deleted resources and attachments | Deleted resources may be absent; attachments may be external URLs or inline data | Deleted resources usually do not reload. Inline attachment data is stored with the resource, while external binaries need a separate storage plan. Confirm both with the source export. |
| Partition placement | No partition information in standard exports | If partitioning is enabled, each resource needs a partition decision before load. Set this in the plan, not during the run. |
Documented import paths for loading bulk files into HAPI FHIR
The HAPI FHIR JPA server accepts resources through its standard REST interface, through bundles, and through its batch job framework. Each path suits a different volume and a different amount of custom code, and none of them reads NDJSON files on its own. The choice shapes how you convert the exports, preserve IDs and order the load.
Single resource create and update
Each resource is sent as its own HTTP request, using create for new resources and update for resources that already exist. This path is simple to reason about and easy to retry for one record, but it sends one network round trip per resource. For a large export, the number of requests and the time they take become the main constraint. Check whether your loader can set explicit IDs on create, since the export IDs must survive the move so that references still resolve.
JPA server docsTransaction bundles
A transaction bundle carries many resources in one request, and the server processes them as a unit, so either all entries commit or none do. References between entries use urn:uuid or resolve against IDs already on the server, so the order and reference handling in your converter decide whether the bundle succeeds. Keep bundles at a size your server and database handle comfortably, and test a sample before you run the full export. Transaction semantics are the main reason teams choose this path for linked clinical data.
Batch bundles
A batch bundle also groups requests, but each entry is processed independently, so one failed entry does not roll back the others. This suits loads where partial success is acceptable and failures are logged for a rerun. Because entries are not atomic, you must check the response for each entry, and you must plan how references to a failed resource are handled in later loads. Confirm this behavior against the version you deploy before you rely on it.
The batch job framework
HAPI FHIR includes a batch job framework that runs server-side work as jobs, separate from requests made by clients. It is the route that the performance and scaling section covers in detail for large volumes. It is a server capability, not an NDJSON importer, so you still need to confirm which jobs your version provides and how they handle your input format. Treat it as a tuning option to evaluate after a small pilot, not as a packaged import tool.
JPA server docsCustom loader code
Every path above needs a loader that reads the NDJSON files, converts each line into a resource or bundle entry, and submits it. HAPI FHIR does not ship a packaged importer for these files, so the converter, retry logic, error capture and reconciliation reports are code your team or your partner writes and owns. Budget for that code, its tests and its maintenance, and document it as part of the migration evidence.
How the conversion from NDJSON to transaction bundles works
The conversion starts with what the source server actually produced. Bulk export output differs by vendor in file layout, resource coverage, and how IDs are assigned, so the loader should be designed against the files you have, not against an assumed format. Before writing any code, inventory the export manifest, the resource types present, and whether any resource appears in more than one file. Confirm with the source platform's documentation how it names files, whether it splits large resource types into multiple parts, and whether it includes deleted or historical versions.
- Export manifest: Record each output file, its resource type, and its line count so you can reconcile counts after the load.
- Resource coverage: Note which resource types were requested and which the source silently omitted.
- Split files: Confirm how multi-part files for one resource type are numbered and whether any part can be partially written.
- Vendor-specific fields: Identify extensions or metadata the source adds that the target server may reject during validation.
- Compression and storage: Check whether files are gzip compressed and where they sit, since this affects how the loader reads them.
Check that the manifest, the file set, and the source server's resource counts agree before any conversion runs.
The loader reads each NDJSON file one line at a time. Each line is a complete FHIR resource in JSON, so a streaming parser can process files that are too large to hold in memory. Every resource is grouped by its resourceType, because the target server's ordering and reference checks depend on which types exist before others reference them. Parsing errors should be captured per line with the file name and line number, so a single malformed record does not stop the whole run.
- Streaming reads: Process each file as a stream and keep only the current chunk of resources in memory.
- Type grouping: Route each resource into a per-type queue so the load order can be controlled later.
- Line-level errors: Log the file, line number, and parser message for every record that fails to parse.
- Schema sanity checks: Confirm that each line has a resourceType and an id before it is queued.
- Idempotent reruns: Record which file and line ranges completed so a restarted run can skip them.
Review the error log before loading. Any record that failed to parse is missing data in the target, and that gap must be explained before the completeness check.
Most loss in a migration comes from references, not from the resources themselves. When the loader keeps each resource's original logical ID, every reference such as Patient/123 in an observation still points to the right record without rewriting. Preserving IDs is the default for a like-for-like migration. It works when the target server accepts a client-supplied ID for the resource type and when no other resource already uses that ID.
A conditional or identifier-based approach is needed when IDs cannot be kept. This happens when the target already holds data, when two sources share ID ranges, or when the target server assigns its own IDs. In those cases the loader must build a map from source ID to target ID, rewrite references as the bundle is built, and load referenced resources first. Matching on identifiers with conditional create or update operations gives idempotent loads, but it is slower and needs a unique identifier system that the source actually populates.
- Preserve by default: Keep original IDs and keep references unchanged whenever the target is empty for that resource type.
- Build an ID map: Store source-to-target ID pairs in a durable table when rewriting is required.
- Conditional creates: Use identifier-based conditional operations for resources that must merge with existing data.
- Reference targets: Confirm that every referenced resource exists in the target before a dependent resource is posted.
- Unresolved references: Quarantine resources whose references point to records that were never exported.
Confirm with the target server's configuration how client-assigned IDs are handled before you commit to a preservation strategy.
Once grouped and reference-checked, resources are wrapped into transaction bundles. A transaction bundle is processed by the server as a single unit, so one failing entry rolls back the whole bundle. This makes error handling a design decision: small bundles isolate failures, while larger bundles reduce request overhead. Each bundle entry carries a request method and URL, and the loader should choose between create, update, and conditional operations per entry based on the ID strategy.
The loader should send bundles in order, record each response, and capture per-entry errors from the returned OperationOutcome. Retries should only resend bundles that failed for transient reasons, since a retry of a validation failure will fail again. Test the chunk size against your own server and database before choosing a production value.
- Transaction semantics: Expect a failed entry to roll back its whole bundle and plan reprocessing for that chunk.
- Entry methods: Use PUT with a known ID for preserved IDs and conditional operations where identifiers are the key.
- Response capture: Store the status and OperationOutcome for each bundle alongside the source line range.
- Retry rules: Retry on timeouts and connection failures, and send validation errors to a review queue.
- Chunk tuning: Measure chunk size on a representative load rather than copying a value from another project.
Check that every bundle has a recorded outcome before the run is called complete.
Sequence for loading exports, running in parallel and cutting over
This sequence takes NDJSON bulk exports from inventory through a verified full load, a parallel run and cutover, so that the HAPI FHIR server holds every resource the source system held before anyone relies on it. Each step closes with a check the team can record and repeat.
Inventory resource types and counts
Read the export manifest and list every resource type, the number of files and the record count per type. The source team confirms the manifest reflects what they intended to export, and the migration lead records the counts as the baseline for every later check. Ask the source vendor how the export was scoped, including whether deleted resources, history and reference-only resources are included. The step is done when the baseline table is signed off by both teams.
Check schema and profiles against the target version
Confirm the FHIR version of the export matches the FHIR version the HAPI FHIR JPA server is configured to accept, and identify any custom profiles, extensions or search parameters the source used. Validate a sample of each resource type against the target profiles using the validator your team chooses, and log every failure with its resource type and cause. Confirm the server's Java and JPA starter version requirements against the HAPI FHIR documentation before the target environment is built. The step closes when every failure class has either a fix or an agreed exception.
Run a pilot load of one resource type and its dependencies
Choose one resource type with clear dependencies, such as Patient with the Organization and Practitioner resources it references, and convert those files into transaction bundles that preserve IDs and references. Load them into a non-production HAPI FHIR server and check that references resolve, that the counts match the manifest and that a sample of records reads back identically. Record the load time and the errors per bundle so the full load can be sized. The pilot is complete when the referenced data resolves without unexplained gaps.
Load all resources in dependency order
Run the full load so that referenced resources exist before the resources that point to them, for example Patient and Organization before Encounter, and Encounter before Observation and other clinical resources. Use the throughput settings chosen during the pilot and log progress per resource type. Each bundle failure should be retried or quarantined with the file and line reference, not silently skipped. The step is done when each resource type's loaded count matches its baseline count or every difference is explained.
Reconcile completeness per resource type
Compare the server's count for each resource type with the baseline from the manifest, using search counts with the summary total for each type. Sample records across the file set, not only the first files, and check that references point to existing resources. Record any missing or extra resources by ID and trace each one to a load error, a deletion or a source-side difference. The reconciliation is complete when the report lists zero unexplained differences for every type.
Run a parallel period and compare reads
Keep the source system and the HAPI FHIR server running side by side, and send the same read requests to both, such as patient lookups, encounter histories and common search parameters. Compare the returned resources and the search results, and investigate every mismatch in ordering, extensions or reference resolution. Plan who approves the comparison results and how long the parallel period runs, and confirm both with the business owners before it starts. The parallel run ends when the agreed read comparisons show no open defects.
Freeze the source or delta load before cutover
Before cutover, either freeze writes on the source system or run a delta export of resources changed since the full export and load them with the same bundle process. Repeat the per-type count reconciliation on the final data set, because counts from the first export will no longer match once changes occur. Record the export timestamp and the reconciliation result as the cutover record. The step is done when the final counts match the source at the freeze point.
Cut over and decommission the source
Switch client applications to the HAPI FHIR endpoint according to the cutover runbook, and keep the source available in read-only mode for a period the team agrees in writing. Monitor errors, latency and authorization failures during the first working period after the switch. Decommission the source only after the owners sign off, the retention obligations for the export files are met and the archived manifest, reconciliation reports and load logs are stored. The sequence is complete when the cutover record and decommissioning sign-off are filed together.
Flow from export files to a verified HAPI FHIR server
The flow starts with NDJSON files in object storage, which a conversion step reads one resource type at a time and wraps into transaction bundles. The bundles are posted to the HAPI FHIR JPA server, which writes to its relational database, while rejected resources go to an error queue for review and re-submission. The final step reconciles per-type counts and a sample of references against the source manifest, so the load is confirmed before cutover rather than assumed from a successful HTTP status.
Export files move through conversion and load into HAPI FHIR, then get reconciled against the manifest.
What drives the cost and duration of an NDJSON load
This table compares the factors that change the effort of loading bulk export files into a HAPI FHIR JPA server, and marks whether each cost is paid once or recurs. Read it before asking for a quote, so the written scope states the volume, the reference rewriting and the validation depth the price depends on.
| Driver | Why it changes cost or effort | One-time or recurring, and what to ask for in a quote |
|---|---|---|
| Data volume and resource types | More files, larger files and more resource types mean longer parsing, more transaction bundles and longer load windows. Confirm the file count and total size per resource type from the export. | One-time. Ask the quote to state the resource types in scope and the export size used for planning. |
| Reference density | Every Reference must be rewritten when IDs change or when resources are loaded in a new order. Dense graphs, such as Patient to Encounter to Observation chains, raise the work. | One-time. Ask how references are mapped, whether IDs are preserved, and how unresolved references are reported. |
| FHIR version and profile differences | Source servers may export R4, STU3 or a vendor variant, and profiles may differ from the target. Each mismatch needs conversion rules or profile changes. | One-time. Ask which FHIR version and profiles the source and target use, and who decides the mapping rules. |
| Extensions and custom search needs | Custom extensions, custom search parameters and nonstandard code systems require mapping, configuration and retesting of search results. | One-time for mapping, recurring if new extensions appear. Ask for an inventory of extensions and search parameters in use. |
| Database sizing and partition mode | Storage, indexing and partition choices affect load speed and must be set before loading. Changing partition mode after loading usually means reloading. | One-time for setup, recurring for storage growth. Ask which database engine, sizing assumptions and partition mode the quote assumes. |
| Validation rigor | Validating every resource against the core specification and implementation guides takes more time than loading without validation, and failures add review cycles. | One-time for the initial run, recurring if validation runs on each refresh. Ask which validation profiles and error thresholds are included. |
| Reconciliation rounds | Each count comparison, failed reference or rejected bundle usually triggers a fix, a reload of part of the data and a new comparison. | One-time, but the number of rounds is hard to predict. Ask how many rounds are included and how extra rounds are priced. |
| Internal team FHIR skills | Teams familiar with FHIR resources, search and bundles need less guidance, while teams new to FHIR need more review and knowledge transfer. | One-time for knowledge transfer, recurring if you own ongoing loads. Ask what handover and training the scope includes. |
Common questions about loading NDJSON exports into HAPI FHIR
What does it cost to load NDJSON bulk exports into HAPI FHIR?
Cost depends on the number of resource types, the total data volume, how much transformation the files need, and how many validation rounds the sign-off criteria require. The main cost components are the engineering time to build the bundle conversion and load tooling, the test loads against a staging environment, the reconciliation reports, and the cutover rehearsal. Ask for a quote that separates one-time work (tooling, load runs, verification) from recurring work (retainers for upgrades or support), and that lists which environments are included. DeployOpen does not publish a price list; a quote follows from the written scope.
How long does an NDJSON load into HAPI FHIR usually take?
Duration is driven less by the number of files than by data volume, the number of resource types with cross-references, the chosen load order, and how many dry runs the team needs before cutover. Large exports with heavy reference graphs take longer to load and to reconcile, and each failed batch adds a rerun. Database sizing and the throughput settings you choose also affect load time. Confirm the expected duration against your own export size and a timed test load in a staging environment, rather than relying on a general figure.
What must our team provide before a load can start?
Plan to provide the complete export files with their manifest, read access to the source system's export configuration so the scope can be checked, the list of resource types and profiles in scope, and agreed sign-off criteria such as expected resource counts and reference integrity checks. You also need a target environment: a HAPI FHIR JPA server running on a supported JDK, backed by PostgreSQL or Microsoft SQL Server, with storage sized for the data and network access from the loading host. Agree in writing who owns the target environment and who approves the cutover.
Can our internal team load the NDJSON files without an outside partner?
Yes, if your team has engineers who can read FHIR resource structures, write bundle conversion code, operate the JPA server and its database, and reconcile counts. The work is well defined, but it has many edge cases: references that point to resources in other files, resources that fail validation, and identifiers that must be preserved. Assess your team's capacity against the length of the cutover window and whether anyone has run a bulk load before. A fixed-scope engagement can cover part of the work, such as tooling or verification, while your team keeps ownership.
How do we confirm the load is complete and correct?
Start by comparing resource counts per type between the export manifest and the HAPI FHIR server, then check that every reference resolves to a loaded resource and that original IDs were preserved. Keep a record of every bundle that was rejected, with its reason, and rerun those batches until the rejected set is empty or explicitly accepted. Spot-check representative records against the source, and confirm that search parameters return the expected results. Agree these checks as sign-off criteria before the first load, so the result is measured against a fixed standard.
How does the NDJSON load fit into a parallel run with the old platform?
A parallel run needs a defined sync point. The bulk load establishes a baseline at the export time, so changes made in the source system after that point must be captured through a delta export or a re-run for the affected resource types. Decide which system is authoritative for each resource type during the overlap, and test that reconciliation reports can show drift between the two. Confirm with your vendor how the source system's export behaves during active writes, and plan the cutover window around the time needed for the final delta.
Which parts of the load depend on the HAPI FHIR version we run?
The JDK requirement, the database schema, and the supported FHIR versions differ between HAPI FHIR releases, so the target version should be chosen before the conversion tooling is written. For example, HAPI FHIR 8.2.0 requires JDK 17, and the JPA server documentation lists which FHIR versions are covered. Confirm the target release notes, the required JDK, and the database versions with the HAPI FHIR documentation and your own environment before setting the load plan.
What usually goes wrong when loading bulk exports and how to prevent it
Most failed NDJSON loads trace back to a short list of decisions made too late: how IDs are mapped, what order resources are posted in, and whether the source stayed still during export. Each card below names one failure, the symptom it produces, and the step that prevents it.
Broken references from changed IDs
Bulk export files carry source resource IDs, and every Reference points at them. If the target server assigns new IDs on create, every reference to a patient, encounter or practitioner breaks silently. Decide the ID strategy before the first load: either preserve source IDs with PUT-style updates in the transaction bundle, or build an explicit old-to-new ID map and rewrite references in a staging step. Then query a sample of references after load and confirm they resolve.
Load-order failures across resource types
A bundle that posts an Observation before its Patient fails or creates dangling references, depending on how the server validates. Group resources by dependency, posting organizations and locations first, then practitioners, patients, encounters, and clinical resources last. Keep each transaction bundle small enough to retry alone. Record which file and line range each bundle covered so a failed segment can be replayed without reloading the whole set.
Silent rejects from profile validation
Resources that conform to the source system may violate the target's profiles, required extensions or terminology bindings. Some failures appear as per-entry errors inside a transaction response, and others are easy to miss if the loader only checks the HTTP status. Validate a representative sample against the profiles you plan to enforce, route every rejected entry to an error queue with its original line, and review the queue by resource type before retrying.
Count mismatches after a source change
If the source system keeps writing while the export runs, the NDJSON set can contain a partial view of related records, and counts taken later from the live source will not match. Freeze a snapshot before export by blocking writes or taking a database snapshot, record the export start time, and store the file manifest with checksums. Compare resource counts per type against that manifest, not against the source's current totals.
Database and memory limits during large posts
Large transaction bundles hold many resources in memory and generate heavy write load on the relational database, which can exhaust heap, connection pools or transaction log space. Set bundle size and concurrency deliberately, watch database write latency and memory during a pilot load, and size the JVM and database for the peak batch rather than the steady state. The server's own configuration documentation and the PostgreSQL or SQL Server settings in your environment should be reviewed together before the production run.
Misjudged search behavior after load
A load can succeed and still leave search slow or incomplete, because search parameters are indexed on write and indexes built for a small test set may not suit the full volume. Compare the search parameters your applications use against what the target supports, run the queries that clinical and reporting workflows depend on, and check their response times and result counts against the source. Treat a missing or slow search as a load defect until the indexes and parameter support are confirmed.
What the load must keep under access control and audit
This sequence sets up credentials, network paths, audit logging and staging-file handling before any patient data reaches the target server, so the load can be reviewed and explained afterward. It produces a load record that names who moved which files, when and into which server.
Confirm the compliance obligations first
The compliance or privacy lead, with the security team, lists the obligations that apply to the export files and the target server, such as access logging, retention limits and breach handling, and records which controls each one requires. HAPI FHIR does not decide these for you, so the owner of the data confirms them before any real patient data is staged. The output is a short written control list that later steps are checked against.
Build the load identity and its permissions
The platform team creates a dedicated client identity for the loader, separate from clinical users and from administrators, and grants it only the write operations the load needs. HAPI FHIR provides building blocks for authentication and authorization, including the AuthorizationInterceptor, and the team configures the rules in the target server's security layer. Done means the loader can post the test bundles and is refused on every resource type or operation outside that scope.
Configure the target server's audit logging
The platform team enables BALP audit logging on the target server and confirms that the log records the load identity's writes before the first real file is loaded. The security engineer checks the log destination, retention and access to the log itself, since the audit trail is only useful if it is protected. Done means a test write from the loader appears in the audit log with the identity, time and resource.
Set the network path and encrypt staging storage
The network engineer restricts the loader to a private path to the target server and blocks direct access from user networks to the staging bucket or volume. The storage owner applies encryption at rest and restricts read access to the loader identity and named administrators. Done means a scan of the network rules and storage access policy matches the approved design, with no open path from outside the agreed network.
Control export files in storage
The data engineer transfers the NDJSON exports from the source system's storage into the approved staging location using the loader identity, and records a checksum for each file. Access is limited to the people named in the load plan, and file listings are logged where the storage platform allows it. Done means every file in staging has a matching checksum in the load record and no one outside the named group can read it.
Set retention and deletion for staging copies
The compliance lead and data owner set how long the staging copies and transformed transaction bundles may exist, and who approves deletion. After the load is verified, the platform team removes the staging copies and any intermediate bundles, then records the deletion with its date and approver. Done means the deletion record exists and the storage listing shows no remaining copies, with the retention rule confirmed against the obligations listed at the start.
Document who loaded what
The load lead writes a load record that names each file, its checksum, the load identity, the start and end times, the target server version, and the people who approved and ran the load. The record is kept with the audit log entries for the same period so the two can be matched. Done means an independent reviewer can trace any resource in the target server back to a specific file and load run.
How DeployOpen scopes and delivers an NDJSON load
DeployOpen plans, builds, tests and documents NDJSON bulk loads into a self-hosted HAPI FHIR JPA server inside your own infrastructure. The work starts with a written scope that fixes which exports, resource types and reference rules are in play, so the load can be checked against the source files.
How we scope
- Inventory the export files, resource types, counts and source FHIR version before any load design begins
- Agree in writing how references, logical IDs and extensions will be preserved when bundles are generated
- Confirm the target HAPI FHIR version, JDK 17 runtime, and PostgreSQL or Microsoft SQL Server database for the load
- Define the completeness checks and acceptance criteria that the final load report must demonstrate
How we build
- Write the transformation that turns export files into transaction bundles, with load order set by reference dependencies
- Run test loads against a non-production HAPI FHIR server and tune batch size and concurrency from observed results
- Test reference resolution, duplicate handling and failed-bundle retries using a representative sample of your data
- Record each configuration change so the production run can be repeated with the same settings
How we hand over
- Deliver the loader scripts, bundle templates and configuration files in a repository your team controls
- Provide a runbook covering the load sequence, rollback steps and how to rerun a failed segment
- Hand over a completeness report comparing source counts with server counts for each resource type
- Walk your engineers through the run so they can repeat or adapt the load without us
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after the load is complete
- Retainers can cover later reloads, HAPI FHIR version upgrades and changes to export formats from your source platform
- Confirm with us during scoping which post-load support, if any, your timeline and compliance team require
- Fixed-scope engagements mean changes to the load scope are agreed in writing before additional work starts

