Inline terminology

Note

A whole tutorial referenced here is available in the following Postman collection: https://documenter.getpostman.com/view/1515623/2sAXqqbhKp

An important aspect to successful mappings between FHIR and openEHR is a service able to translate codings, enums, terminologies from one to the other.

In this specific example, within openEHR template, growth_chart/body_weight/any_event:0/state_of_dress` is coded in a local` terminology with values at0013` (Naked) and others. Something unknown to FHIR. An implementation guide in FHIR may restrict you to snomed or loinc coding, which is why you need a mapping from one to the other.

A simple terminology mapping is to provide the mapping inline, within a specific model.yaml.

Adding mapping of this data point & inline terminology

Mapping of the state_of_dress data point wasn’t included in the original mappings. Let’s add it, following a similar approach as in the previous step when we added Observation.note.text.

Get an ID and trigger a PUT of the body weight mapper. You need to add the following mapping within mappings:

- name: "state of dress"
  with:
    fhir: "$fhirResource.component.value"
    openehr: "$openEhrArchetype.body_weight.any_event.state_of_dress"
    type: "CODEABLECONCEPT"
  condition:
    targetRoot: "$fhirResource.component"
    targetAttribute: "code.coding.code"
    operator: "one of"
    criteria: "[$loinc.9999-9]"
  terminology:
      type: "inline"
      mappings:
          - openehr:
              code: "at0013"
              system: "local"
            fhir:
              code: "fhirNakedIsh"

This will add value from growth_chart/body_weight/any_event/state_of_dress to an Observation.component.value and code that component with component.coding.code=9999-9, and vice-versa.

Additionally, with the inline terminology, anything in openEHR coded as at0013 in system local will be mapped to fhirNakedIsh when creating a FHIR Resource.

In the other direction, something in FHIR Coded as fhirNakedIsh will result in openEHR code of at0013.

Full payload you need to use when updating this specific model mapper should look like:

PUT http://localhost:8080/fc/model/(id of the model mapper)
PUT http://localhost:8080/fc/model/(id) HTTP/1.1
Body: <yaml below>
format: "0.2.0"
version: "0.0.2"

fhirConfig:
  # For this Resource: https://www.hl7.org/fhir/observation-example.json.html
  resource: "Observation"
  condition:
    - targetRoot: "$fhirResource"
      targetAttribute: "category.coding.code"
      operator: "one of"
      criteria: "[weight]"
openEhrConfig:
  # For this Archetype: https://ckm.openehr.org/ckm/archetypes/1013.1.2960
  archetype: "openEHR-EHR-OBSERVATION.body_weight.v2"

mappings:
  - name: "weight"
    with:
      fhir: "$fhirResource.value"
      openehr: "$openEhrArchetype.body_weight.any_event.weight"
      type: "QUANTITY"
    condition:
      targetRoot: "$fhirResource"
      targetAttribute: "code.coding.code"
      operator: "one of"
      criteria: "[$loinc.29463-7, $snomed.27113001]"
  - name: "time"
    with:
      fhir: "$fhirResource.effective"
      openehr: "$openEhrArchetype.body_weight.any_event.time"
      type: "DATETIME"
  - name: "comment"
    with:
      fhir: "$fhirResource.note.text"
      openehr: "$openEhrArchetype.body_weight.any_event.comment"
      type: "STRING"
  - name: "state of dress"
    with:
      fhir: "$fhirResource.component.value"
      openehr: "$openEhrArchetype.body_weight.any_event.state_of_dress"
      type: "CODEABLECONCEPT"
    condition:
      targetRoot: "$fhirResource.component"
      targetAttribute: "code.coding.code"
      operator: "one of"
      criteria: "[$loinc.9999-9]"
    terminology:
        type: "inline"
        mappings:
            - openehr:
                code: "at0013"
                system: "local"
              fhir:
                code: "fhirNakedIsh"

Validating behavior of the inline terminology

Use the same example of openEHR as in previous steps:

POST http://localhost:8080/openfhir/tofhir?templateId=Growth chart
POST http://localhost:8080/openfhir/tofhir?templateId=Growth%2Cchart HTTP/1.1
Content-Type: application/json
Body: <json below>

growth_chart_flat.json

Within the result, you should see a new FHIR element mapped from openEHR:

 "component": [
    {
        "code": {
            "coding": [
                {
                    "code": "9999-9"
                }
            ]
        },
        "valueCodeableConcept": {
            "coding": [
                {
                    "code": "fhirNakedIsh"
                }
            ]
        }
    }
]

Going in the other direction, you should see a properly openEHR coded at0013 in the resulting Composition.

"growth_chart/body_weight/any_event:0/state_of_dress|code": "at0013",
"growth_chart/body_weight/any_event:0/state_of_dress|terminology": "local",