Integration

MPI, FHIR, and External CDRs

Reconcile patient identity when exchanging FHIR, PIX, shared records, and portable forms with external systems.

How connections work

The frontend calls AMCDR, which connects to external MPI, FHIR, terminology and CDR systems through backend connectors. This keeps external credentials and integration controls on the server.

Boundary model
FrontendNo external secrets
->
AMCDR backendPolicy, audit, adapters
->
External MPI
->
FHIR server
->
External openEHR CDR

Internal MPI

The internal service is the AMCDR Enterprise MPI. It handles cross-organisation identity, durable enterprise identifiers, verification history, duplicate detection, links, merge review, survivorship, unmerge, newborn matching, and relationship governance. See Enterprise Master Patient Index for the identity and NIN trust model, and Demographics, MPI, PIX/PDQ for Person/Patient/Party and exchange details.

GET /mpi/capability
POST /mpi/pdq/search
POST /mpi/pix/query
POST /mpi/pix/feed
POST /mpi/fhir/patient/search
GET /mpi/fhir/patient/{patient_id}
POST /mpi/fhir/patient
PUT /mpi/fhir/patient/{patient_id}
POST /mpi/internal/candidates
POST /mpi/internal/merge
POST /mpi/internal/unmerge
GET /mpi/internal/links/{patient_id}
GET /mpi/internal/policy
POST /mpi/internal/policy

Use /mpi as the identity service entry point. It supports internal, external, and auto mode. Auto mode uses a configured active external MPI when one is available and otherwise falls back to AMCDR internal MPI. Use /mpi/internal only for internal governance workflows such as candidate policy, merge review, unmerge, and patient links.

Strong identifiers include MRN, national ID, passport, refugee registration number, humanitarian agency reference, UNHCR identifier, and external MPI reference.

External MPI

External MPI profiles are configured in backend/connectors.yaml or AMCDR_CONNECTORS_CONFIG_PATH. Supported interaction styles include PDQ, PIX, and FHIR Patient/Party flows. This page focuses on connector boundaries; Demographics, MPI, PIX/PDQ covers how those queries are used in patient registration and reconciliation.

mpi_servers:
  - key: mpi-main
    name: Enterprise MPI
    base_url: https://mpi.example.org/fhir
    active: true
    protocols:
      - pdqm
      - pixm
      - fhir
    auth:
      auth_type: oauth2_client_credentials
      token_url: https://auth.example.org/realms/mpi/protocol/openid-connect/token
      client_id: amcdr
      client_secret_env: AMCDR_MPI_CLIENT_SECRET

External MPI APIs

GET /integrations/mpi/servers
GET /integrations/mpi/servers/{server_key}
POST /integrations/mpi/{server_key}/pdq/search
POST /integrations/mpi/{server_key}/pix/query
POST /integrations/mpi/{server_key}/pix/feed
POST /integrations/mpi/{server_key}/fhir/patient/search
GET /integrations/mpi/{server_key}/fhir/patient/{patient_id}
POST /integrations/mpi/{server_key}/fhir/patient
PUT /integrations/mpi/{server_key}/fhir/patient/{patient_id}
POST /integrations/mpi/{server_key}/fhir/party/import

FHIR Server Integration

AMCDR exposes a FHIR facade for standards exchange. FHIR is an interoperability boundary over the governed AMCDR record; openEHR templates remain the canonical clinical model.

GET /fhir/metadata
POST /fhir/Patient
PUT /fhir/Patient/{patient_id}
POST /fhir/Person
POST /fhir/Bundle
POST /fhir/ingest
GET /fhir/{ResourceType}
POST /fhir/project
Patient identity: FHIR Patient create/update, PIX feeds, SHR Patient ingestion, bundles, generic FHIR ingestion, client registration and portable-form subject writes all use the same MPI resolution/upsert service and then create a new openEHR PartyVersion.

A FHIR Person does not independently create a patient. Its Person.link.target must resolve to an existing Patient or a Patient in the same Bundle (including urn:uuid references). Conflicting or ambiguous identity evidence returns 409 Conflict; uncertain identities are never silently merged.

If another system pushes to AMCDR, give it a scoped AMCDR token or API key and use the authenticated /fhir/* endpoints. If AMCDR needs to call another FHIR system, configure an external connector and call it through the integration connector APIs.

For FHIR StructureDefinition import, FHIR profile management, FHIR-to-openEHR mapping, governed /fhir/ingest, direct /fhir/Bundle ingest, outbound /fhir/project, and validation results, use FHIR Mapping and SDs.

External openEHR CDRs

External openEHR CDRs are configured as RemoteCDR records in the AMCDR database. This is the configuration used by the template source manager and backend form runtime when it needs to list external templates or post openEHR FLAT/STRUCTURED compositions to another CDR.

backend/connectors.yaml configures external MPI, terminology connectivity, and generic outbound connectors. Do not put browser-side CDR URLs or credentials in frontend code. The browser asks AMCDR for template sources; AMCDR selects the backend adapter.

FieldPurpose
nameDisplay name for the external CDR.
base_urlExternal openEHR REST base URL.
vendorEHRBASE, HIP_CDR, or BETTER_CDR.
auth_configBearer token, username/password, and timeout settings. Store real secrets outside committed files.
insert into remote_cdr (
  id, name, base_url, vendor, auth_config, created_at, updated_at
) values (
  gen_random_uuid(),
  'EHRbase Production',
  'https://ehrbase.example.org/ehrbase/rest/openehr/v1',
  'EHRBASE',
  '{"bearer_token":"<secret-from-vault-or-provisioning>","timeout_seconds":20}'::jsonb,
  now(),
  now()
);

The external_cdr_connectors module must be enabled through platform module configuration or AMCDR_MODULE_EXTERNAL_CDR_CONNECTORS_ENABLED. In demo_training mode, external CDR sources are intentionally hidden.

Template Discovery

GET /template-sources
GET /template-sources/{source_id}/templates
GET /template-sources/{source_id}/templates/{template_id}/web-template

Adapter Calls

GET {base_url}/definition/template/adl1.4
GET {base_url}/definition/template/adl1.4/{template_id}/webtemplate
POST {base_url}/definition/template/adl1.4
POST {base_url}/ehr/{ehr_id}/composition?templateId={template_id}&format=FLAT
PUT {base_url}/ehr/{ehr_id}/composition/{composition_uid}?format=FLAT
POST {base_url}/query/aql

Forms Creating Compositions In External CDRs

In Form Designer, choose the External integrations runtime workspace to make a form available to external openEHR CDR connector workflows. Configure its target CDR separately. The configured target must have the referenced template available, accept the selected composition format, use compatible terminology bindings, and provide endpoint, authentication, patient/EHR context, and submission policy through AMCDR backend configuration.

  1. Resolve identity and patient/EHR context through internal MPI, external MPI, or both.
  2. Select the target CDR connection and external ehr_id.
  3. Render the template-anchored form.
  4. Submit captured data to AMCDR backend runtime.
  5. Backend selects the adapter and composition format.
  6. Backend posts FLAT or STRUCTURED composition JSON to the external CDR.
  7. Backend records provenance and remote composition identifiers where available.

Operational Checks

For external systems subscribing to AMCDR lifecycle events and then pulling FHIR resources or saved-query extracts, use Subscriptions and Outbound Delivery.