Implementation Summary
| 1.1.0 area | AMCDR implementation |
|---|---|
| SMART on openEHR | Full runtime with discovery, governed app registry, one-time clinical launches, user/patient/system grants, template/query scope enforcement, audit, readiness and Applications UI. See SMART on openEHR. |
| Demographic REST API | AGENT, GROUP, ORGANISATION, PERSON and ROLE create/read/update/delete; VERSIONED_PARTY history and versions; demographic CONTRIBUTION and ITEM_TAG operations. |
| Admin API | Super-admin-only physical EHR deletion at DELETE /openehr/v1/admin/ehr/{ehr_id} and selected/all deletion at DELETE /openehr/v1/admin/ehr/all. |
| ITEM_TAG | EHR-wide filters plus COMPOSITION, EHR_STATUS and Demographic resource/version tag reads, replacement and key deletion. |
| Template examples | /definition/template/adl1.4/{template_id}/example and the ADL2 equivalent. |
| CONTRIBUTION formats | The envelope remains canonical JSON; the selected simplified format applies to each versions[].data. |
| Simplified formats | application/openehr.wt.flat+json, application/openehr.wt.structured+json and application/openehr.wt+json, including |preferred_term and |other. |
| EHR composition collection | GET /openehr/v1/ehr/{ehr_id}/composition returns the paginated current compositions in canonical, FLAT, STRUCTURED, TDD, template-data-definition, or summary representation. The route is identified as a product extension. |
| Template-derived artifacts | The standard template /example sub-resource negotiates sample representations with Accept; /schema?format=tds returns the TDS XSD as a product extension. |
| REST/HTTP behavior | Default minimal responses, identifier/representation preferences, consistent creation codes, create-only Location, standard preconditions and weak ETags. |
| Templates and ADL | template_id and version filters, ADL 1.4/ADL2 endpoints, examples and deprecated get-at-version compatibility. |
| Query | Stored query definition/execution by qualified name and version, including correct resolution of a query named aql. |
| RM alignment | UPDATE_AUDIT.change_type and UPDATE_VERSION.lifecycle_state use DV_CODED_TEXT; optional system_id is accepted. |
Standard API behavior
The standard APIs use /openehr/v1. Canonical resources and specification-defined arrays are returned directly; AMCDR does not wrap them in vendor REST resource/collection envelopes. The generated contract includes all 96 operations published in the 1.1.0 EHR, Definition, Query, Demographic and Admin OpenAPI specifications.
The retired /openehr adapter is not registered. Older AMCDR composition-write compatibility handlers are excluded from the published contract and are not used by first-party clients wherever the standard defines the operation.
PERSON Writes and MPI Authority
The internal MPI is the only authority for patient identity matching, duplicates, merges and national identifiers. An inbound openEHR PERSON is an interface to that identity, not a second demographic source of truth.
- Translate PERSON identities, external identities, MRN, names, birth details, addresses and telecoms into MPI fields.
- Resolve exact identifier and MRN evidence and follow any merge chain to the surviving patient.
- Reject ambiguous evidence or an update pointing to another patient with
409 Conflict. - Create or update MPI Person, Patient, national identifiers and contacts in one transaction.
- Generate a new openEHR
PartyVersionfrom the resolved MPI record.
Identifiers and contacts reconcile additively. Omission does not erase identity history, verified identifiers are not downgraded, retired identifiers are not reactivated, and MRNs cannot be silently replaced. AGENT, GROUP, ORGANISATION and ROLE remain native Demographic resources and do not enter patient matching.
Standard Header Names
openehr-version: lifecycle_state.code_string="532"
openehr-audit-details: change_type.code_string="251",description.value="Corrected observation",committer.name="Jane Doe",system_id="hospital.example"
openehr-template-id: vital-signs.v1
openehr-item-tag: key="record-class";value="primary"
Prefer: return=representation
If-Match: W/"87284370-2d4b-4e3d-a3f3-f303d2f4f34b::repository.example::1"
AMCDR documents the openEHR names openehr-version, openehr-audit-details, openehr-template-id, openehr-item-tag, openehr-version-item-tag and openehr-ehr-id. HTTP header matching remains case-insensitive.
Composition Representation Negotiation
| Representation | Media type |
|---|---|
| Canonical JSON | application/openehr+json |
| Canonical XML | application/openehr+xml |
| FLAT JSON | application/openehr.wt.flat+json |
| STRUCTURED JSON | application/openehr.wt.structured+json |
| TDD XML | application/xml; format=tdd |
| Template-data-definition JSON | application/json; format=template_data_definition_json |
Use Content-Type for create and update operations and Accept for retrieval and template examples. Template-derived submissions also identify the template with openehr-template-id. TDS is the XML Schema for TDD and is retrieved from /openehr/v1/definition/template/adl1.4/{template_id}/schema?format=tds; it is not submitted as a composition.
SMART Configuration
Production deployments configure AMCDR_SMART_AUTHORIZATION_ENDPOINT, AMCDR_SMART_TOKEN_ENDPOINT, AMCDR_SMART_JWKS_URI, optional registration/introspection/revocation endpoints, and AMCDR_OIDC_ISSUER_URL. Keycloak remains the OAuth/OIDC authority; AMCDR governs app approval, patient/EHR context, grants and openEHR resource enforcement. Use GET /smart/readiness?probe_oidc=true before activating clients.
Destructive Operations
DELETE /openehr/v1/admin/ehr/all?ehr_id={id} deletes the selected EHR identifiers. Omitting all ehr_id parameters deletes every EHR visible to the deployment. For safer selection and preview of multiple compositions, use the AQL-driven batch hard-delete API. Swagger places single and batch composition hard deletion under openEHR Admin; both are clearly marked AMCDR product extensions rather than normative ITS-REST operations.
DELETE /openehr/v1/admin/template/all is tenant-scoped and defaults to a dry-run. Execution requires an exact confirmation phrase, an approved reason and an expected count matching the current preview. Logical deletion refuses the full operation if any selected template is referenced by clinical data; hard deletion is disabled in production.
Governed EHR Merge
EHR merge is an explicitly marked AMCDR Admin extension because ITS-REST 1.1.0 does not define an EHR-merge operation. The MPI remains authoritative for duplicate resolution and survivorship. A request creates a governance task and does not move data until an authorized reviewer approves it.
| Operation | Endpoint |
|---|---|
| Request merge into an existing EHR | POST /openehr/v1/admin/ehr/{target_ehr_id}/merge |
| Get merge status | GET /openehr/v1/admin/ehr/{ehr_id}/merge-status |
| Resolve the surviving EHR ID and chain | GET /openehr/v1/admin/ehr/{ehr_id}/merged-into |
| Get review or merge operation details | GET /openehr/v1/admin/ehr/merge/{operation_id} |
| Approve / reject | POST /openehr/v1/admin/ehr/merge/{review_task_id}/approve or /reject |
| Reverse | POST /openehr/v1/admin/ehr/merge/{merge_event_id}/reverse |
Approval preserves the source EHR and provenance, moves governed clinical references to the survivor, incorporates the source DIRECTORY through a new survivor DIRECTORY version, and makes the source EHR read-only. Subject lookup follows merge chains. Reversal uses the recorded change manifest and fails closed if the survivor DIRECTORY has changed since the merge.
System and DIRECTORY Operations
OPTIONS /openehr/v1 returns solution and conformance information. The dependency-free GET /openehr/v1/system/heartbeat extension supports uptime monitoring; use /readyz for dependency readiness. The canonical DIRECTORY resource is available through GET, POST, PUT and DELETE /openehr/v1/ehr/{ehr_id}/directory, including version and time retrieval.
Swagger and compatibility testing
The generated schema identifies the standard as openEHR ITS-REST 1.1.0. Standard headers, media types, query parameters, weak ETags, SMART, Admin, Demographic, Definition and Query routes are visible in the authenticated frontend Swagger UI at /api-docs/swagger or its /doc alias. Direct API clients can retrieve /openapi.json or use the backend Swagger endpoint at /docs with the required credentials.
Each operation appears in exactly one openEHR Swagger group and includes a concrete cURL example. Write operations also include representative request bodies and the relevant headers. Composition projections and reversible lifecycle extensions are grouped under openEHR EHR; irreversible composition hard deletion is grouped under openEHR Admin.
Automated tests check the API contract and integrations. Deployments that require independent certification must arrange it separately. The upstream Demographic, Admin and SMART specifications are published by openEHR at DEVELOPMENT maturity; AMCDR therefore pins the supported revision and requires deployment-specific interoperability testing before production activation.