Purpose
Use this guide to build and check mappings in Semantic Studio. It covers FHIR imports, openEHR-to-FHIR exports, rules for both directions, and the reviews required before a mapping is used in production.
Mappings connect the clinical record to forms, workflows and exchange formats. The openEHR composition remains the source clinical record.
Mapping Surfaces
| Mapping surface | Direction | Expected use |
|---|---|---|
| Template to form | openEHR template -> form fields | Creates user-facing capture surfaces from approved clinical templates. |
| Template to foundation projection | openEHR template -> operational foundation | Updates rebuildable operational state such as encounter, movement, relationship, queue, visibility, reporting, or safety facts. |
| FHIR inbound mapping | FHIR -> openEHR | Validates an incoming FHIR payload and creates one or more template-governed openEHR compositions. |
| FHIR outbound projection | openEHR -> FHIR | Projects canonical AMCDR content into a governed FHIR resource or Bundle for external systems. |
| Bidirectional mapping | FHIR <-> openEHR | Declares that both inbound and outbound directions are intentionally governed, versioned, tested, and audited. |
| Terminology mapping | Code system -> code system | Translates or normalizes codes while preserving system, code, display, version, and provenance. |
Direction Terms
AMCDR uses direction labels in two related places. Template FHIR bindings use runtime FHIR direction names. Universal mapping governance may also use source/target direction labels when a mapping is not limited to FHIR.
| Label | Meaning | Runtime implication |
|---|---|---|
fhir_to_openehr | Inbound FHIR mapping. | FHIR payload is validated, transformed through targets, and committed as canonical openEHR content when all required context is present. |
openehr_to_fhir | Outbound FHIR projection. | Canonical AMCDR/openEHR content is transformed through projections into FHIR output. |
bidirectional | Both directions are governed. | The mapping can be selected for inbound or outbound operations, but inverse logic is not assumed unless explicit rules exist for both directions. |
SOURCE_TO_TARGET | Universal mapping source is transformed into target. | Used by the broader mapping registry for non-FHIR or multi-model transformations. |
TARGET_TO_SOURCE | Universal mapping target is transformed back to source. | Used when the declared target model is the operational write or return shape. |
BIDIRECTIONAL | Universal mapping is governed in both directions. | Requires direction-specific fixtures, validation, provenance, and conflict handling. |
What Bidirectional Mapping Means
A bidirectional mapping contains approved rules for importing and exporting data. Define and validate each direction explicitly; AMCDR cannot safely infer an inverse from a one-way rule.
Inbound rule set
Defines how FHIR paths or source model fields become openEHR template fields, context values, coded values, and operational references.
Outbound rule set
Defines how canonical composition fields, context, identifiers, and projections become a FHIR resource, Bundle, or partner payload.
Round-trip checks
Representative fixtures must prove that inbound and outbound transforms preserve the required clinical meaning, even when the wire format differs.
Conflict policy
The mapping must state which side owns updates, how external changes are accepted, and how conflicts are rejected, queued, or reconciled.
Bidirectional Mapping Rules
- Define inbound and outbound rules explicitly. Do not rely on automatic inversion for production use.
- Use one canonical clinical owner for each data element. In AMCDR clinical persistence, that owner is normally the openEHR composition.
- Map patient, EHR, encounter, composition, version, and external resource identifiers so repeated exchanges update or reference the correct records.
- Preserve terminology details: system, code, display, version, and translation provenance.
- Declare any lossy fields. If FHIR cannot represent an openEHR value fully, the mapping must record the omission or extension strategy.
- Validate representative fixtures in both directions before publishing.
- Record audit and provenance for every ingest, projection, validation failure, replay, and external delivery.
- Do not allow an external FHIR payload to overwrite canonical clinical content unless the route, user, policy, and mapping explicitly permit that update.
Design-Time Workflow
- Import or publish the openEHR template that owns the clinical data.
- Import the FHIR StructureDefinition or select a supported FHIR resource profile.
- Create a mapping artifact in Semantic Studio or through the mapping API.
- Select the direction:
fhir_to_openehr,openehr_to_fhir, orbidirectional. - Bind each required source path to a target path. Use explicit leaf paths for composite openEHR values such as
DV_CODED_TEXT,DV_QUANTITY, andDV_IDENTIFIER. - Configure terminology translation where the FHIR profile and openEHR template use different code systems.
- Add fixtures for inbound payloads, outbound composition examples, and expected results.
- Validate, preview, publish, and record the mapping version before production use.
Choose the full field path
Bind the full source path to the full target path. A node label alone may appear in several places and is not enough to identify a field. The source side shows FHIR or source-model paths such as Procedure.code.coding[].code. The target side shows openEHR template or AQL value paths where available.
| Binding type | Use | Example |
|---|---|---|
DIRECT | Map a value path to a value path. | Procedure.code.coding[].code -> target code value path |
LOOP | Map a repeatable source group to a repeatable target group. | Procedure.code.coding[] -> repeated openEHR coding group |
Structural parent paths such as Procedure.code, Procedure.code.coding, or an openEHR cluster should not be bound directly to scalar values. Use the parent only as a loop group when both sides are repeatable containers, then map child values such as system, code, and display inside the loop.
The source pane can be resized to review longer FHIR paths or to give the openEHR target paths more space. This keeps mappings readable for complex resources with repeated arrays, extensions, and nested coding structures.
Repeating Data Rules
Map repeating structures explicitly. Common examples are CodeableConcept.coding[], Patient.name[], FHIR extension[], and repeated openEHR clusters or ELEMENT groups.
- Create a loop binding between the repeatable source container and the repeatable target container.
- Map child value paths inside the loop using direct bindings.
- Do not map an array directly into a single scalar target unless the mapping defines an explicit selection or aggregation rule.
- Validate loop mappings with payloads that contain zero, one, and multiple repetitions.
FHIR Extensions And Modifier Extensions
FHIR extensions are selected by canonical url, never by array position. A mapping may select a scalar extension value with valueString, valueCode, or the polymorphic value[x] selector. A repeating complex extension is represented as a loop whose child URL mappings write to fields in the same repeatable openEHR cluster. AMCDR preserves the child values at the same occurrence index so identifier, code, display, quantity, and other sibling values cannot be paired with a different repetition.
{
"fhir_extension_bindings": [
{
"url": "https://example.org/fhir/StructureDefinition/fetus",
"loop": true,
"fields": [
{
"url": "https://example.org/fhir/StructureDefinition/fetus-identifier",
"target": "fetus_identifier",
"value": "valueString"
},
{
"url": "https://example.org/fhir/StructureDefinition/fetal-presentation",
"target": "fetal_presentation",
"value": "valueCode"
}
]
}
],
"modifier_extension_policy": {
"mode": "reject_unmapped",
"approved_ignored": []
}
}
This contract is configured in the template version's FHIR binding editor. Each target must also resolve through field_bindings to a published template node. A loop target must be repeatable in the openEHR template. Inbound execution creates correlated repeated RM structures; outbound execution reconstructs the FHIR extension array and canonical URLs.
modifierExtension. A mapped modifier URL is handled by its governed mapping. An intentionally ignored modifier requires an explicit URL and a recorded clinical-governance reason. reject_all may be selected for a contract that does not permit modifier extensions.The original validated FHIR payload remains available for provenance and audit, but raw-payload retention is not a substitute for canonical mapping. Analytics, AQL, SHR, and outbound clinical projections use the explicitly mapped openEHR content.
Runtime APIs
| Operation | API | Purpose |
|---|---|---|
| List FHIR mappings | GET /fhir/mappings | Returns FHIR profile mapping definitions. |
| Create FHIR mapping | POST /fhir/mappings | Creates an inbound/outbound mapping definition using targets and/or projections. |
| FHIR to openEHR ingest | POST /fhir/ingest | Validates and transforms FHIR into canonical openEHR compositions. |
| openEHR to FHIR projection | POST /fhir/project | Projects AMCDR/openEHR content into FHIR using a selected mapping. |
| Universal mapping registry | GET /mappings, POST /mappings | Manages broader cross-model mapping artifacts used by Semantic Studio and integration governance. |
| Validate mapping | POST /mappings/{mapping_id}/validate | Checks mapping completeness, direction compatibility, fixtures, and target coverage. |
| Preview mapping | POST /mappings/{mapping_id}/preview | Runs a non-committing transform preview against a supplied payload. |
| Publish mapping | POST /mappings/{mapping_id}/publish | Makes the validated mapping available for controlled runtime use. |
Inbound FHIR Mapping Example
Inbound mappings use targets. Each target describes the openEHR template to create and the rules that copy or transform values from the incoming FHIR payload.
{
"key": "observation-vitals-to-openehr",
"direction": "fhir_to_openehr",
"source_profile_keys": ["vital-signs-observation"],
"target_template_keys": ["vital_signs.v1"],
"mapping_definition": {
"targets": [
{
"template_key": "vital_signs.v1",
"name": "Vital signs",
"category": "event",
"rules": [
{
"from": { "resourceType": "Observation", "path": "effectiveDateTime" },
"to": { "kind": "context", "key": "start_time" }
},
{
"from": { "resourceType": "Observation", "path": "valueQuantity.value" },
"to": { "kind": "field", "key": "body_temperature|magnitude" }
},
{
"from": { "resourceType": "Observation", "path": "valueQuantity.unit" },
"to": { "kind": "field", "key": "body_temperature|unit" }
}
]
}
]
}
}
Outbound FHIR Projection Example
Outbound mappings use projections. Each projection describes the FHIR resource to produce and the rules that copy values from canonical composition detail into FHIR paths.
{
"key": "vital-signs-openehr-to-observation",
"direction": "openehr_to_fhir",
"source_template_keys": ["vital_signs.v1"],
"target_profile_keys": ["vital-signs-observation"],
"mapping_definition": {
"projections": [
{
"resourceType": "Observation",
"defaults": {
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8310-5",
"display": "Body temperature"
}
]
}
},
"rules": [
{
"from": { "kind": "context", "key": "start_time" },
"to": "effectiveDateTime"
},
{
"from": { "kind": "field", "key": "body_temperature|magnitude" },
"to": "valueQuantity.value"
},
{
"from": { "kind": "field", "key": "body_temperature|unit" },
"to": "valueQuantity.unit"
}
]
}
]
}
}
Bidirectional Artifact Example
A bidirectional artifact includes both targets and projections. The two rule sets may share field keys, but each direction remains explicit.
{
"key": "vital-signs-bidirectional",
"direction": "bidirectional",
"source_profile_keys": ["vital-signs-observation"],
"target_template_keys": ["vital_signs.v1"],
"mapping_definition": {
"targets": [
{
"template_key": "vital_signs.v1",
"rules": [
{
"from": { "resourceType": "Observation", "path": "valueQuantity.value" },
"to": { "kind": "field", "key": "body_temperature|magnitude" }
}
]
}
],
"projections": [
{
"resourceType": "Observation",
"rules": [
{
"from": { "kind": "field", "key": "body_temperature|magnitude" },
"to": "valueQuantity.value"
}
]
}
],
"round_trip": {
"required": true,
"clinical_meaning_must_match": true,
"lossy_fields": []
},
"conflict_policy": {
"canonical_owner": "openehr_composition",
"external_update_mode": "review_before_commit"
}
}
}
Composite openEHR Values
openEHR RM datatypes often contain several semantic parts. Semantic Studio exposes mappable leaf paths so these values can be aligned with FHIR elements without losing meaning.
| openEHR datatype | Common leaves | FHIR target examples |
|---|---|---|
DV_CODED_TEXT | |code_string, |value, |terminology_id, |version | CodeableConcept.coding.code, display, system, version |
DV_QUANTITY | |magnitude, |unit, |units_system, |unit_version | Quantity.value, unit, system, code |
DV_IDENTIFIER | |id, |issuer, |assigner, |type, |namespace, |scheme | Identifier.value, system, type, assigner |
Production Checklist
- The source model, target model, direction, version, and owner are recorded.
- The mapping references published openEHR templates and imported FHIR profiles where applicable.
- Every required source and target path has an explicit binding or documented default.
- Terminology translation rules are configured and tested.
- Patient, encounter, EHR, composition, and external identifiers are mapped or resolved before commit.
- Validation fixtures cover normal, missing-field, coded-field, quantity, identifier, and error scenarios.
- Bidirectional mappings include fixtures for both inbound and outbound execution.
- Lossy fields, extensions, unsupported paths, and conflict policies are documented.
- The mapping is published only after validation and preview succeed.
- Runtime ingest and projection are audited with mapping key, mapping version, actor, source system, patient, EHR, and validation result.
Common Problems
| Problem | Cause | Action |
|---|---|---|
| Bidirectional selected but only one direction works. | The artifact has only targets or only projections. | Add the missing direction-specific rules and fixtures before publishing. |
| FHIR output misses code system or display. | Only the code value was mapped. | Map the full coded-text leaves: code, display, system, and version. |
| FHIR ingest creates a composition without encounter context. | Subject was resolved, but encounter or visit context was not provided or mapped. | Pass encounter context or map it through a foundation projection when clinically required. |
| Quantity values are wrong after projection. | Magnitude and unit were not mapped separately. | Map |magnitude, |unit, and unit system where available. |
| External update would overwrite clinical truth. | No conflict policy or external update review route exists. | Use review-before-commit or reject external updates for that mapping. |
Related Guides
- FHIR Mapping and StructureDefinitions for FHIR profile import,
/fhir/ingest,/fhir/project, and FHIR validation behavior. - Workflow Foundation Bindings for template-to-foundation projections used by operational workflows.
- End-to-End Clinical Workflow Guide for how mappings fit into registration, medication, clinical persistence, and external exchange.
- Terminology and Coding for coding systems, terminology servers, and coded field governance.