Scope
Relationship Layers
MPI identity links, patient relationships, EHR context links, and composition context links.
Birth Links
Mother birth reports linked to each newborn EHR, with reverse links back to the mother.
Lookup APIs
Retrieval of patient, EHR, birth-event, transfer, and referral links without manual identifier copying.
Transfer And Referral
How source and destination EHRs stay connected after handover, transfer-out, and receiving assessment.
AQL Scenarios
Examples for mother-child reports, child-to-mother lookup, NICU babies, transfer destinations, and counts.
Reporting Rules
Use relationship APIs to resolve context, then use AQL against the returned EHR IDs and composition UIDs.
Where Relationships Are Created
Create relationships in the workflow where the connection is established. Registration, birth, demographics, and context-link APIs each manage the relevant type of link.
| Workflow or UI area | What is created | API boundary | Storage layer |
|---|---|---|---|
| Patient Registration, Step 4: Relationships | Formal patient-to-patient MPI link when an existing related patient is selected. | POST /mpi/internal/links |
party_link |
| Birth registration and newborn linking | Mother-child, child-mother, twin/sibling, birth-event, EHR, encounter, and composition links. | POST /patient-relationships, POST /birth-workflows/{id}/create-or-link-newborns, and birth EHR-link APIs. |
patient_relationship, ehr_context_link, composition_context_link |
| Demographic party management | Person or party relationship records, such as guardian, next of kin, household, or legal representative. | POST /demographic/party/{party_id}/relationships and POST /openehr/v1/demographic/party/{party_id}/relationships |
party_relationship and openEHR demographic party records |
| Coverage, guarantor, and subscriber workflows | Relationship-to-subscriber or guarantor metadata for billing and coverage operations. | Coverage and guarantor APIs used by registration and payer workflows. | patient_coverage.relationship_to_subscriber, guarantor.relationship_to_patient |
| External registry or interoperability links | Cross-system entity links for external MPI, HIE, FHIR, SHR, or partner-system references. | Interlinking and client-link APIs. | Entity-link and client-link records |
Entering next-of-kin, guarantor, or subscriber text alone does not automatically create a formal patient-to-patient link. A formal relationship is created when the workflow selects or creates the related person or patient and writes the link through the relevant relationship API.
Relationship Layers
AMCDR uses separate relationship layers because each one answers a different question.
| Layer | Question answered | Example | Storage |
|---|---|---|---|
| MPI / identity | Are these real-world people connected? | Mother person is biological mother of newborn person. | MPI candidates, identity links, party links. |
| Patient relationship | Are these clinical patient records connected? | Mother patient is biological mother of Baby A patient. | patient_relationship and party_link. |
| EHR context link | Which EHRs, encounters, and compositions are clinically connected? | Mother birth report composition links to Baby A and Baby B EHRs. | ehr_context_link. |
| Composition context link | Which workflow context does one composition belong to? | Newborn birth composition belongs to birth event, neonatal encounter, mother, and newborn. | composition_context_link. |
Design Rule
Clinical facts belong in openEHR compositions. System relationship links belong in AMCDR relationship tables.
openEHR template:
delivery mode
birth date and time
plurality
birth order
birth weight
Apgar
newborn condition
AMCDR EHR context link:
mother_ehr_id
maternal_birth_report_composition_uid
newborn_ehr_id
newborn_birth_composition_uid
birth_event_id
maternal_delivery_encounter_id
neonatal_encounter_id
This prevents silent rewriting of clinical history when identity reconciliation, merge review, EHR creation, or composition versioning happens later.
EHR Context Link Model
The foundational table is ehr_context_link. It is generic and supports birth, death, transfer, referral, household, donor-recipient, contact tracing, and other cross-record relationships.
| Field | Purpose |
|---|---|
context_type and context_id | The workflow or event that created the link, such as birth_event. |
relationship_type | Forward meaning from source EHR to target EHR. |
inverse_relationship_type | Reverse meaning from target EHR back to source EHR. |
source_ehr_id | The EHR where the link starts. |
source_composition_uid | The composition in the source EHR that anchors the link. |
target_ehr_id | The EHR being linked to. |
target_composition_uid | The target composition, if it already exists. |
source_encounter_id and target_encounter_id | Clinical or workflow encounters on each side. |
birth_order | Used for twins, triplets, and other multiple births. |
status | ACTIVE, PROVISIONAL, RECONCILED, or RETIRED. |
confidence | PROVISIONAL or CONFIRMED. |
Twin Birth Example
For twins, AMCDR creates two EHR context link rows with the same mother source composition and different target newborn EHRs.
Mother EHR
maternity admission
labour and delivery summary
birth report with twins
-> Baby A EHR
-> Baby B EHR
Baby A EHR
newborn admission
newborn examination
observations / immunisation / discharge
-> Mother EHR + birth report composition
Baby B EHR
newborn admission
NICU admission
incubator monitoring
abnormality / diagnosis notes
discharge / transfer summary
-> Mother EHR + birth report composition
Birth Workflow API
After the mother birth report composition is created, call the birth workflow endpoint to link it to the resolved newborn EHRs.
POST /birth-workflows/{birth_event_id}/maternal-birth-report-link
Authorization: Bearer <token>
Content-Type: application/json
{
"composition_uid": "mother-birth-report-composition::1",
"template_id": "twin_birth_report.v1",
"candidate_ids": ["nbc-baby-a", "nbc-baby-b"],
"confidence": "CONFIRMED"
}
The response contains one link per newborn EHR.
{
"birth_event_id": "birth-abc123",
"total": 2,
"items": [
{
"relationship_type": "mother_birth_report_to_newborn_ehr",
"inverse_relationship_type": "newborn_ehr_to_maternal_birth_report",
"source_ehr_id": "mother-ehr-id",
"source_composition_uid": "mother-birth-report-composition::1",
"target_ehr_id": "baby-a-ehr-id",
"target_composition_uid": "baby-a-newborn-admission::1",
"birth_order": 1
},
{
"relationship_type": "mother_birth_report_to_newborn_ehr",
"source_ehr_id": "mother-ehr-id",
"source_composition_uid": "mother-birth-report-composition::1",
"target_ehr_id": "baby-b-ehr-id",
"target_composition_uid": "baby-b-nicu-admission::1",
"birth_order": 2
}
]
}
Lookup Examples
Find every EHR context link for one EHR:
GET /ehrs/{ehr_id}/context-links
Find only links for a birth event:
GET /ehr-context-links?context_type=birth_event&context_id=birth-abc123
Find all relationship links touching one patient:
GET /patients/{patient_id}/ehr-context-links
Find links from a mother EHR to newborn EHRs:
GET /ehrs/{mother_ehr_id}/context-links?direction=source&relationship_type=mother_birth_report_to_newborn_ehr
Find the mother birth report from a newborn EHR:
GET /ehrs/{newborn_ehr_id}/context-links?direction=target&context_type=birth_event
Generic Link API
For non-birth use cases, create a generic link directly.
POST /ehr-context-links
Authorization: Bearer <token>
Content-Type: application/json
{
"context_type": "transfer",
"context_id": "transfer-2026-0001",
"relationship_type": "transfer_source_to_destination_ehr",
"inverse_relationship_type": "transfer_destination_to_source_ehr",
"source_patient_id": "source-patient-id",
"source_ehr_id": "source-ehr-id",
"source_composition_uid": "transfer-summary::1",
"target_patient_id": "destination-patient-id",
"target_ehr_id": "destination-ehr-id",
"target_composition_uid": "receiving-note::1",
"confidence": "CONFIRMED"
}
Use Cases
| Use case | Source | Target | Relationship type |
|---|---|---|---|
| Birth with twins | Mother EHR + birth report | Each newborn EHR | mother_birth_report_to_newborn_ehr |
| Transfer | Sending facility EHR + transfer summary | Receiving facility EHR + admission note | transfer_source_to_destination_ehr |
| Referral | Referring EHR + referral composition | Receiving EHR + specialist assessment | referral_source_to_destination_ehr |
| Death documentation | Prior admission EHR + discharge/death summary | Death event context or mortuary EHR if configured | death_context_ehr_link |
| Contact tracing | Index case EHR | Contact EHRs | index_case_to_contact_ehr |
| Donor-recipient | Donor EHR | Recipient EHR | donor_to_recipient_ehr |
AQL Scenarios
AQL does not directly query AMCDR relationship tables. The operational pattern is: first resolve relationship links, then run AQL against the EHR IDs or composition UIDs returned by those links.
Scenario 1: Mother Birth Report And All Children EHRs
Use the relationship API first.
GET /ehrs/{mother_ehr_id}/context-links?direction=source&context_type=birth_event&relationship_type=mother_birth_report_to_newborn_ehr
Then query the mother birth report composition.
SELECT
e/ehr_id/value AS mother_ehr_id,
c/uid/value AS birth_report_uid,
c/name/value AS report_name,
c/archetype_details/template_id/value AS template_id,
c/context/start_time/value AS delivery_time
FROM EHR e
CONTAINS COMPOSITION c
WHERE e/ehr_id/value = 'mother-ehr-id'
AND c/uid/value = 'mother-birth-report-composition::1'
Use the returned relationship rows to display Baby A and Baby B EHR IDs beside the mother report.
Scenario 2: Child Chart Showing Mother And Delivery Composition
Resolve the mother link from the newborn EHR.
GET /ehrs/{newborn_ehr_id}/context-links?direction=target&context_type=birth_event
Then query the mother's delivery/birth report composition.
SELECT
e/ehr_id/value AS mother_ehr_id,
c/uid/value AS delivery_composition_uid,
c/name/value AS document_name,
c/context/start_time/value AS delivery_time
FROM EHR e
CONTAINS COMPOSITION c
WHERE e/ehr_id/value = 'mother-ehr-id'
AND c/uid/value = 'mother-birth-report-composition::1'
Scenario 3: Baby A And Baby B Clinical Records After A Twin Birth
Resolve children from the mother or birth event, then use the returned newborn EHR IDs in AQL.
SELECT
e/ehr_id/value AS child_ehr_id,
c/uid/value AS composition_uid,
c/name/value AS document_name,
c/archetype_details/template_id/value AS template_id,
c/context/start_time/value AS recorded_at
FROM EHR e
CONTAINS COMPOSITION c
WHERE e/ehr_id/value MATCHES {
'baby-a-ehr-id',
'baby-b-ehr-id'
}
AND c/archetype_details/template_id/value MATCHES {
'newborn_admission.v1',
'newborn_examination.v1',
'nicu_admission.v1',
'immunisation_record.v1',
'discharge_summary.v1'
}
ORDER BY e/ehr_id/value, c/context/start_time/value
Scenario 4: Mother With Count Of Linked Children
Use the relationship API for the count. This is relationship metadata and must not be forced into pure AQL.
GET /ehrs/{mother_ehr_id}/context-links?direction=source&context_type=birth_event
The report counts relationship rows grouped by source_ehr_id and presents the result beside AQL facts from the mother's birth report.
SELECT
e/ehr_id/value AS mother_ehr_id,
c/uid/value AS birth_report_uid,
c/context/start_time/value AS delivery_time
FROM EHR e
CONTAINS COMPOSITION c
WHERE e/ehr_id/value = 'mother-ehr-id'
AND c/uid/value = 'mother-birth-report-composition::1'
Scenario 5: NICU Babies Linked To Maternal Delivery Reports
Resolve all birth links for the reporting period, filter linked children whose AQL results include NICU admission, then join the report rows in AMCDR reporting.
SELECT
e/ehr_id/value AS newborn_ehr_id,
c/uid/value AS nicu_composition_uid,
c/name/value AS nicu_document,
c/context/start_time/value AS nicu_admission_time
FROM EHR e
CONTAINS COMPOSITION c
WHERE e/ehr_id/value MATCHES {
'baby-a-ehr-id',
'baby-b-ehr-id',
'baby-c-ehr-id'
}
AND c/archetype_details/template_id/value = 'nicu_admission.v1'
ORDER BY c/context/start_time/value DESC
Scenario 6: Transfer Source And Receiving EHR
Use relationship links to find the destination EHR, then query transfer and admission compositions.
GET /ehrs/{source_ehr_id}/context-links?direction=source&context_type=transfer
SELECT
e/ehr_id/value AS destination_ehr_id,
c/uid/value AS receiving_composition_uid,
c/name/value AS receiving_document,
c/context/start_time/value AS received_at
FROM EHR e
CONTAINS COMPOSITION c
WHERE e/ehr_id/value = 'destination-ehr-id'
AND c/archetype_details/template_id/value MATCHES {
'admission_note.v1',
'transfer_receiving_note.v1'
}
AQL And Reporting
openEHR AQL queries clinical compositions. AMCDR relationship APIs resolve cross-EHR links. For reports, use AQL to select compositions, then join to AMCDR relationship tables through saved-query or reporting services when relationship context is required.
Clinical query:
find all birth report compositions
Relationship lookup:
find newborn EHRs linked to each birth report composition
Report output:
mother patient, mother EHR, birth report, Baby A EHR, Baby B EHR, neonatal composition status
In a report builder, let users choose the relationship type, source or target side, and clinical AQL template, then preview the combined report.
Operational Rules
- Do not create fake names to represent relationships.
- Do not rely only on MPI for clinical context. MPI identifies people; EHR context links identify record and composition relationships.
- Do not silently modify clinical compositions when a relationship is reconciled later.
- Use
RETIREDinstead of deleting relationship rows when a link is superseded. - Use
PROVISIONALconfidence for unresolved identity workflows andCONFIRMEDafter review. - Keep relationship metadata small and factual. Clinical facts belong in templates and compositions.