Extension methods

An extension always inherits all the mappings contained in the model mapping. It can interact with these existing mappings by starting a mapping method and adding the extends key. Depending on the key different logic is executed.

types Description

add

adds a mapping to the model mapping, always added to the bottom of the file

append

appends mapping logic to a path inside the model mapping

overwrite

overwrites the mapping method with the same name

Add

This extension method adds a mapping method to the model mapping. It is always added at the bottom of the model mapping file. Add methods can also overwrite prior methods to the same path.

Example:

  - name: problemQualifier
    extension: add
    with:
      fhir: $resource
      openehr: $archetype/data[at0001]/items[openEHR-EHR-CLUSTER.problem_qualifier.v2]
    slotArchetype: CLUSTER.problem_qualifier.v2

This impacts the model mapping file at runtime in the following way:

mappings:

  - name: contextStartTime
    with:
      fhir: $resource.recordedDate
      openehr: $composition/context/start_time
#------ added --------
  - name: problemQualifier
    with:
      fhir: $resource
      openehr: $archetype/data[at0001]/items[openEHR-EHR-CLUSTER.problem_qualifier.v2]
    slotArchetype: CLUSTER.problem_qualifier.v2

Append

The append extension method appends a followedBy to a method. The method where it is to be appended to is referenced with the key appendTo. The value used is the name of the mapping method. This can be also the child method. The path then would be appendTo: parent.child

Example of an append extension method:

  - name: wirkstofftyp
    extension: append
    appendTo: ingredients
    followedBy:
      mappings:
        - name: wirkstofftypExtended
          with:
            fhir: $fhirRoot.ingredients.extension.value
            openehr: $archetype/items[at0142]

This would impact a model mapping file at runtime in the following way:

mappings:
  - name: name
    with:
      fhir: $resource.code
      openehr: $archetype/items[at0132]

  - name: ingredients
    with:
      fhir: $resource.ingredient
      openehr: $archetype/items[openEHR-EHR-CLUSTER.medication.v2] # cluster in cluster
    followedBy:
      mappings:
        - name: ingredient
          with:
            fhir: item.ofType(CodeableConcept)
            openehr: items[at0142]
  #----------- Append -----------------------------------
        - name: wirkstofftypExtended
          with:
            fhir: $fhirRoot.ingredients.extension.value
            openehr: $archetype/items[at0142]

To maintain readability the append is transformed into a followedBy. If more logic needs to be altered, the overwrite method must be used instead.

Overwrite

This method allows to overwrite an existing method contained in the model mapping. The name of the mapping method is the name of the method in the model mapping that will be overwritten.

Example:

  - name: dateTime
    extension: overwrite
    with:
      fhir: $resource
      openehr: $archetype
      type: NONE
    followedBy:
      mappings:
        - name: period
          with:
            fhir: onset.ofType(Period)
            openehr: $archetype
            type: DATETIME
          followedBy:
            mappings:
              - name: start
                with:
                  fhir: $fhirRoot.start
                  openehr: data[at0001]/items[at0077]
                  type: DATETIME

              - name: lebensphaseCluster
                with:
                  fhir: $fhirRoot
                  openehr: data[at0001]/items[openEHR-EHR-CLUSTER.lebensphase.v0]
                slotArchetype: CLUSTER.lebensphase.v0

        - name: dateTime
          with:
            fhir: onset.ofType(DateTime)
            openehr: data[at0001]/items[at0077]

Prior to extension use:

mappings:
  - name: contextStartTime
    with:
      fhir: $resource.recordedDate
      openehr: $composition/context/start_time

  - name: dateTime
    with:
      fhir: $resource.onset
      openehr: $archetype/data[at0001]/items[at0077]

After the extension, the model mapping would look like this at runtime:

mappings:
  - name: contextStartTime
    with:
      fhir: $resource.recordedDate
      openehr: $composition/context/start_time

# ---------- Overwrite ---------------------------
  - name: dateTime
    with:
      fhir: $resource
      openehr: $archetype
      type: NONE
    followedBy:
      mappings:
        - name: period
          with:
            fhir: onset.ofType(Period)
            openehr: $archetype
          followedBy:
            mappings:
              - name: start
                with:
                  fhir: $fhirRoot.start
                  openehr: data[at0001]/items[at0077]

              - name: lebensphaseCluster
                with:
                  fhir: $fhirRoot
                  openehr: data[at0001]/items[openEHR-EHR-CLUSTER.lebensphase.v0]
                slotArchetype: CLUSTER.lebensphase.v0

        - name: dateTime
          with:
            fhir: onset.ofType(DateTime)
            openehr: data[at0001]/items[at0077]