grammar: FHIRConnect/v0.0.1
type: model
metadata:
  name: "OBSERVATION.height.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.height.v2"
  fhirConfig:
    structureDefinition: http://hl7.org/fhir/StructureDefinition/Observation

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

  fhirCondition:
    targetRoot: "$resource"
    targetAttribute: "code.coding.code"
    operator: "one of"
    criteria: "8306-3"

mappings:

  - name: "height"
    with:
      fhir: "$resource.value"
      openehr: "$archetype/data[at0001]/events[at0002]/data[at0003]/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[at0001]/events[at0002]/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-length"

  - name: "code"
    unidirectional: "openehr->fhir"
    with:
      fhir: "$resource.code.coding"
      openehr: "$archetype"
    manual:
      - name: "code"
        fhir:
          - path: "code"
            value: "8306-3"
          - path: "system"
            value: "http://loinc.org"
          - path: "display"
            value: "Body height --lying"
