Edit mappings

Note

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

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
GET http://localhost:8080/fc HTTP/1.1

This will provide you with all available mappings. There should be 4 based on our state preparation. Find the one that handles mapping of the weight Observation (i.e. fhirConfig.condition.criteria=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: "$fhirResource.note.text"
    openehr: "$openEhrArchetype.body_weight.any_event.comment"
    type: "STRING"

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

Final model mapper after editing should look like this:

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"

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 payload 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 and "growth_chart/body_weight/any_event:2/comment": "body_weightLorem ipsum0" is populated when mapping Observations to openEHR.

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