Migration principle
Before importing legacy clinical data, match patient identities, map terminology and templates, and validate the records. Create compositions through the clinical lifecycle so each imported record has the same checks and history as a record captured in AMCDR.
Scope
Assessment
Inventory source systems, files, identifiers, clinical domains, code systems, date ranges, and ownership.
Target Design
Choose patient, visit, encounter, EHR, template, FHIR profile, and terminology targets before loading.
Mapping
Map legacy fields to openEHR templates, FHIR StructureDefinitions, internal MPI, and catalogue types.
Validation
Run dry-runs, profile validation, terminology validation, duplicate detection, and mandatory-field checks.
Loading
Load in batches, retain provenance, record validation results, and reconcile counts before cutover.
Cutover
Plan freeze windows, rollback, rejected-record handling, post-load reporting, and support after go-live.
Migration Operating Model
Plan the migration with named owners, reviewed mappings and a clear cutover process. Every imported record needs its source, mapping version, validation result, patient/EHR context and reconciliation result. Follow the same order as clinical data capture: establish patient identity, resolve the encounter, then create the composition.
Phase 1: Source Assessment
List the records to migrate and any exclusions. Review old, duplicate, inactive and legally restricted records before including them in the import.
| Assessment item | Questions to answer |
|---|---|
| Source systems | Which EMR, LIS, pharmacy, registry, paper-scanned, FHIR, HL7v2, CSV, XML, or NDJSON source produced the data? |
| Clinical scope | Which domains are included: demographics, encounters, diagnoses, lab results, medications, immunisations, procedures, documents, deaths, births, or referrals? |
| Patient identifiers | Which identifiers are reliable: MRN, national ID, refugee number, passport, phone, family links, facility birth number, or old system id? |
| Code systems | Which terminology systems exist: SNOMED CT, LOINC, ICD-10, ATC, EDQM, local lab codes, local drug codes, or free text? |
| Date quality | Are timestamps exact, date-only, partial, missing timezone, or copied from registration dates? |
| Data ownership | Who approves mappings, validation rules, patient merge decisions, and final go-live sign-off? |
Phase 2: Target Model Design
Define where every source data class lands in AMCDR. Demographics belong in client/patient/MPI structures. Clinical facts belong in template-governed openEHR compositions. Operational state belongs in visit, encounter, movement, workflow, or relationship records. FHIR resources may be retained as exchange provenance, but they must not replace canonical openEHR clinical storage when a template target exists.
| Source data | AMCDR target | Notes |
|---|---|---|
| Demographic CSV | Client registry, patient, identity party, MPI links | Run duplicate checks before patient/EHR creation. |
| FHIR Patient | FHIR facade plus AMCDR patient identity | Use POST /fhir/Patient for direct create or MPI import workflows for duplicate-sensitive projects. |
| FHIR Observation | Mapped openEHR composition or direct FHIR resource | Use /fhir/ingest when it must become canonical clinical data. |
| FHIR Bundle | Linked FHIR resources, then mapped compositions where configured | Use /fhir/Bundle for reference resolution; use profile mappings for canonical composition creation. |
| Lab CSV/HL7v2 | Laboratory result template composition | Map local test codes to LOINC or configured terminology before import. |
| Medication list | Medication statement/request/administration template or FHIR medication resources | Map product codes and active ingredients through the medication product source and terminology maps. |
| Documents/media | DocumentReference and media/document storage | Keep source file reference, checksum, and patient/encounter link. |
Phase 3: FHIR StructureDefinitions And Mapping
For FHIR sources, including data converted to FHIR, import the relevant StructureDefinitions first. These define the expected exchange format. Then map the FHIR profile paths to openEHR template fields. See FHIR Mapping and SDs for examples and API details.
1. Import FHIR StructureDefinition
POST /fhir/profiles/import-file
2. Create transformation map
POST /fhir/mappings
3. Run governed ingest
POST /fhir/ingest
4. Review failures
GET /fhir/validation-results
Use direct FHIR APIs only when direct FHIR facade storage is the intended outcome. Use mapping-based ingest when the intended outcome is a canonical openEHR composition.
Phase 3b: TDS/TDD Template-Based Imports
When a source system is not FHIR-native but maps records to an openEHR template, export the target template's TDS XSD, import that schema into the mapping tool, map source values into the TDD XML structure, then submit the mapped XML through the governed template composition endpoint.
| Step | Endpoint | Purpose |
|---|---|---|
| Export target schema | GET /templates/{template_key}/exports/tds | Generates on demand when needed and gives migration tooling the schema contract for Talend, Mirth, ALUR, or XML validation. |
| Export sample document | GET /templates/{template_key}/examples/tdd | Gives migration tooling a template-specific TDD Example XML with namespace, schema-location, context, and data elements. |
| Load one mapped record | POST /records/ingest | Use the governed TDD transformation envelope; TDD is not exposed as an alternative composition CRUD representation. |
| Verify loaded record | GET /openehr/v1/ehr/{ehr_id}/composition/{uid_based_id} | Returns the canonical or simplified representation selected by Accept. |
| Batch safely | same endpoint, batched by migration worker | Keep source row id, batch id, mapping version, and validation result in provenance or migration logs. |
{
"template_key": "vitals",
"format": "tdd_example",
"patient_id": "00000000-0000-0000-0000-000000000000",
"payload": {
"xml": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Vital_Signs xmlns=\"http://schemas.oceanehr.com/templates\" xmlns:oe=\"http://schemas.openehr.org/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" template_id=\"vitals.v1\"><context><language><terminology_id><value>ISO_639-1</value></terminology_id><code_string>en</code_string></language><time><value>2026-03-13T10:15:00Z</value></time></context><data><systolic><value xsi:type=\"oe:DV_QUANTITY\"><oe:magnitude>120</oe:magnitude><oe:units>mm[Hg]</oe:units></value></systolic><diastolic><value xsi:type=\"oe:DV_QUANTITY\"><oe:magnitude>80</oe:magnitude><oe:units>mm[Hg]</oe:units></value></diastolic></data></Vital_Signs>"
}
}
TDS/TDD is preferred for template-first migration where the source produces template-specific XML. Flat JSON and structured JSON remain available for direct AMCDR integrations. FHIR mapping remains preferred when the source is already FHIR-profiled. XDS-style document sharing is intentionally separate from this path because it requires registry/repository policy, document metadata, and retrieval workflows rather than a single composition payload format.
Phase 4: Identity And MPI Reconciliation
Do not create a new patient for every source row. Match identity first, then create or link the patient record. Refugees, foreign nationals, newborns, undocumented persons, unknown emergency patients, and unknown deceased persons need identity workflows that preserve uncertainty instead of creating fake names or duplicate records.
- Use strong identifiers when available: national ID, MRN, passport, refugee/UNHCR number, facility birth number, or external MPI id.
- Use contextual signals: facility, mother id, birth datetime, phone, household, address, encounter id, or source system id.
- Create review tasks for uncertain matches. Do not auto-merge uncertain people.
- Keep source-system identifiers as identifiers or provenance, not as clinical names.
- Record every merge, link, unmerge, or identity correction as an auditable event.
Phase 5: Terminology Normalisation
Clinical imports often fail because old systems used local codes or free text. Prepare terminology mapping before the first dry run. Preserve the original source code and display, but map to the target system required by the template, FHIR profile, or report.
| Domain | Typical source | Preferred target |
|---|---|---|
| Lab tests | Local LIS test codes | LOINC or configured national lab code system. |
| Diagnoses | Free text, ICD-10, local codes | ICD-10, SNOMED CT, or configured national diagnosis terminology. |
| Medicines | Product names, stock codes | MediServe / Medication Tracker product source, ATC/RxNorm where relevant, active ingredient, route, form, strength. |
| Routes | Free text routes | EDQM or configured route code system. |
| FHIR administrative codes | Gender, encounter status, observation status | FHIR code systems and value sets. |
Phase 6: Dry Run And Validation
Run at least one dry run before loading production data. Save the validation results and reject unmapped or invalid clinical data. Separate technical failures from issues that need clinical review, and assign each to the responsible team.
| Validation class | Examples | Action |
|---|---|---|
| File-level | Bad encoding, duplicate file, wrong delimiter, corrupt JSON, invalid NDJSON line. | Reject file and fix extract. |
| Record-level | Missing patient id, invalid date, impossible age, missing subject reference. | Reject row/resource and send to correction queue. |
| Profile-level | FHIR SD cardinality or required field failure. | Review /fhir/validation-results and fix profile/source/mapping. |
| Template-level | Required openEHR field missing, wrong datatype, invalid composition category. | Fix mapping or source transformation. |
| Terminology-level | Unknown code, inactive code, wrong system, untranslatable local code. | Add ConceptMap/local mapping or mark for clinical review. |
| Identity-level | Duplicate patient, uncertain newborn match, unknown deceased person, refugee identity conflict. | Create MPI reconciliation task. |
Phase 7: Batch Loading
Load production data in batches small enough to retry, roll back and reconcile. Each batch must have a manifest, checksum, source system, date range, mapping version, profile version, operator and expected counts.
Recommended batch metadata:
batch_id
source_system
source_extract_datetime
source_file_name
source_file_checksum
source_record_count
expected_patient_count
expected_composition_count
profile_key
mapping_key
template_key
terminology_map_version
operator
approval_reference
For FHIR NDJSON, process one resource per line, retain the line number, and include it in provenance or validation errors. For XML, store the original file reference and the parsed resource id. For CSV, keep source row number and primary key.
Phase 7b: Shared Health Record And IPS Readiness
After loading, open patient records and check that the imported information is useful to the care team. Confirm that migrated compositions appear in current summaries, timelines, annual snapshots, FHIR output and IPS-style summaries before treating the migration as complete.
| Readiness check | Why it matters | Example check |
|---|---|---|
| Current summary | Confirms key migrated facts are visible for care, not only stored. | GET /records/patient/{patient_id}/summary/current |
| Timeline query | Confirms migrated records have usable dates, entry types, template keys, and pagination. | GET /records/patient/{patient_id}/timeline/query?page=1&page_size=25 |
| FHIR patient bundle | Confirms exchange consumers are able to pull patient-wide FHIR output. | GET /fhir/Patient/{patient_id}/$everything |
| Population SHR or IPS | Confirms cohorts, facilities, locations, or date ranges return the expected migrated patients without opening each chart. | GET /records/patients/summary?profile=ips&include=index&date_from=2026-01-01&date_to=2026-06-30 |
| IPS-style summary | Confirms problems, allergies, medications, results, procedures, immunisations, and care context are projected into a continuity summary. | Run the approved IPS saved query or projection for representative patients. |
| Relationship-aware views | Confirms mother-newborn, transfer, referral, and guardian links survived migration. | GET /patients/{patient_id}/ehr-context-links |
If the shared record is empty after migration, check template keys, composition dates, patient/EHR links, FHIR bindings, summary projection settings and protected-record filters.
Phase 8: Reconciliation Reports
After each batch, compare source and AMCDR counts. Document the reconciliation and obtain sign-off; a visual check in the application is not enough.
| Report | Purpose |
|---|---|
| Patient count by source system | Confirm expected number of unique people created, linked, merged, or rejected. |
| Composition count by template | Confirm the expected number of clinical records by template and facility. |
| Validation failures by type | Show missing fields, invalid dates, invalid codes, duplicate identities, and mapping errors. |
| Terminology exceptions | List unmapped local codes and free-text values requiring clinical review. |
| FHIR exchange records | Show processed/rejected profile and mapping results from FHIR ingest/projection. |
| Protected records | Confirm VIP/protected records were not exposed in standard migration review outputs. |
Phase 9: Cutover And Rollback
At cutover, users begin relying on AMCDR for the records being migrated. Freeze writes in the old system, take the final extract, load the changes and reconcile counts before approving go-live. Keep a rollback or read-only fallback available until sign-off.
- Announce source-system freeze and final extraction window.
- Run final identity reconciliation and duplicate review.
- Load delta batches using the same mapping versions approved during dress rehearsal.
- Run reconciliation reports and compare with signed expected counts.
- Keep rejected records in a controlled correction queue; do not hide them.
- Switch users to AMCDR once clinical leads, data migration lead, and operational owner approve.
- Keep old system read-only for an agreed period if legally and operationally required.
Migration Artifacts To Retain
- source file checksums and import manifests
- source-to-target data dictionary
- FHIR StructureDefinitions and profile versions
- mapping definitions and mapping versions
- openEHR template versions used during import
- terminology mapping tables and ConceptMaps
- validation result exports
- audit events, lifecycle events, and FHIR exchange records
- patient/MPI reconciliation decisions
- batch reconciliation reports and sign-off evidence
- rollback, suppression, or correction plan for rejected records
Production Rule
If a source field cannot be mapped, validated or explained, hold it for review. Retain it as source provenance, add a reviewed mapping, or send it to the correction queue before including it in the clinical record.