Edit mappings

Note

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

Note

If running against a public sandbox.open-fhir.com, don’t forget to include Authorization header of type Basic.

In this step, we’ll be adding mapping of a new data point to the body weight model mapper.

First, we need to get an ID of the body weight model mapper we’ve persisted in the state preparation step.

GET http://localhost:8080/fc/model
GET http://localhost:8080/fc/model HTTP/1.1

This will provide you with all available mappings. There should be 5 based on our state preparation. Find the one that handles mapping of the body weight Observation (i.e. preprocessor.fhirCondition.criteria = 29463-7, the LOINC code for Body weight).

Adding an Observation.note.text to the mapping

Now that you have a specific model mapper, add this entry under mappings

- name: "comment"
  with:
    fhir: "$resource.note.text"
    openehr: "$archetype/data[at0002]/events[at0003]/data[at0001]/items[at0024]"

This will map from/to Observation.note.text <> body_weight.any_event[n].comment

Final model mapper after editing should look like this:

grammar: FHIRConnect/v0.0.1
type: model
metadata:
  name: "OBSERVATION.body_weight.v2"
  version: 0.0.1a # version of this particular mapping
spec: # schema specific to the FHIRConnect v0.0.1 engine
  system: FHIR
  version: R4
  openEhrConfig:
    archetype: "openEHR-EHR-OBSERVATION.body_weight.v2"
  fhirConfig:
    structureDefinition: http://hl7.org/fhir/StructureDefinition/Observation

preprocessor:
  hierarchy:
    with:
      fhir: "$resource"
      openehr: "$archetype/data[at0002]/events[at0003]"
    split:
      fhir:
        create: "resource"

  fhirCondition:
    targetRoot: "$resource"
    targetAttribute: "code.coding.code"
    operator: "one of"
    criteria: "29463-7"

mappings:

  - name: "weight"
    with:
      fhir: "$resource.value"
      openehr: "$archetype/data[at0002]/events[at0003]/data[at0001]/items[at0004]"

  - name: "category"
    with:
      fhir: "$resource.category.coding"
      openehr: "$archetype"
    manual:
      - name: "vitalSignsCategory"
        fhir:
          - path: "code"
            value: "vital-signs"
          - path: "system"
            value: "http://terminology.hl7.org/CodeSystem/observation-category"
          - path: "display"
            value: "Vital Signs"

  - name: "time"
    with:
      fhir: "$resource.effective"
      openehr: "$archetype/data[at0002]/events[at0003]/time"

  - name: "status"
    unidirectional: "openehr->fhir"
    with:
      fhir: "$resource"
      openehr: "$archetype"
    manual:
      - name: "status"
        fhir:
          - path: "status"
            value: "final"

  - name: "profile"
    unidirectional: "openehr->fhir"
    with:
      fhir: "$resource"
      openehr: "$archetype"
    manual:
      - name: "profile"
        fhir:
          - path: "meta.profile"
            value: "http://hl7.org/fhir/us/vitals/StructureDefinition/body-weight"

  - name: "code"
    unidirectional: "openehr->fhir"
    with:
      fhir: "$resource.code.coding"
      openehr: "$archetype"
    manual:
      - name: "code"
        fhir:
          - path: "code"
            value: "29463-7"
          - path: "system"
            value: "http://loinc.org"
          - path: "display"
            value: "Body weight"

  - name: "comment"
    with:
      fhir: "$resource.note.text"
      openehr: "$archetype/data[at0002]/events[at0003]/data[at0001]/items[at0024]"

Trigger a PUT transaction with the payload above. This will edit the state of the engine.

PUT http://localhost:8080/fc/model/(id obtained from step above)
PUT http://localhost:8080/fc/model/(id) HTTP/1.1
Content-Type: plain/text
Body: <full yaml text above>

Testing a new mapping

With the PUT above, we’ve edited a state of the engine. You can use the same body payloads as in the previous step Run mappings to test them out (run $tofhir and $toopenehr).

Apart from what’s been mapped before, you should now also see that Observation.note.text is populated when mapping to FHIR (e.g. "text": "Measured before morning feed") and "growth_chart/body_weight/any_event:0/comment": "Measured before morning feed" is populated when mapping Observations to openEHR.

Note: this should only be the case for Observations that are coded as body weight (LOINC 29463-7), as we’ve only edited that specific mapping.