FHIR to OMOP FHIR IG
2.0.0-ballot - STU 1 Ballot International flag

FHIR to OMOP FHIR IG, published by HL7 International / Biomedical Research and Regulation. This guide is not an authorized publication; it is the continuous build for version 2.0.0-ballot built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/fhir-omop-ig/ and changes regularly. See the Directory of published versions

StructureMap: Mapping Observation resource to Observation OMOP Domain V4

Official URL: http://hl7.org/fhir/uv/omop/StructureMap/ObservationMapV4 Version: 2.0.0-ballot
Standards status: Trial-use Maturity Level: 2 Computable Name: ObservationMapV4
Other Identifiers: OID:2.16.840.1.113883.4.642.40.80.43.19

This mapping maps FHIR Observation instances that are NOT considered measurements to OMOP Observation Table objects. Currently, this is done by considering the category code and mapping 'social-history', 'imaging', 'survey', 'exam', 'therapy', 'activity', and 'procedure' Observations.

Language: en

/// url = 'http://hl7.org/fhir/uv/omop/StructureMap/ObservationMapV4'
/// version = '2.0.0-ballot'
/// name = 'ObservationMapV4'
/// title = 'Mapping Observation resource to  Observation OMOP Domain V4'
/// status = 'active'
/// description = 'This mapping maps FHIR Observation instances that are NOT considered measurements to OMOP Observation Table objects.  Currently, this is done by considering the category code and mapping \'social-history\', \'imaging\', \'survey\', \'exam\', \'therapy\', \'activity\', and \'procedure\' Observations.'

uses "http://hl7.org/fhir/StructureDefinition/Observation|4.0.1" alias Observation as source
uses "http://hl7.org/fhir/uv/omop/StructureDefinition/Observation" alias ObsTable as target

group Observe(source src : Observation, target tgt : ObsTable) {
  src where (src.category.coding.code contains ('social-history' | 'imaging' | 'survey' | 'exam' | 'therapy' | 'activity' | 'procedure')) then {
    src where (src.effective.empty().not()) then {
      src as s -> tgt then {
        s.identifier as i -> tgt then {
          i.value as id -> tgt.observation_id = cast(id, 'integer');
        } "observationIdFromIdentifier";
      } "observationId";
      src.code as s -> tgt then {
        s.coding as sc -> tgt then {
          sc.code as a -> tgt.observation_concept_id = cast(a, 'code');
        };
      };
      src.subject as subject -> tgt then {
        subject.reference as s -> tgt.person_id = (%s.substring(%s.indexOf('/') + 1));
      };
      src.encounter as encounter -> tgt then {
        encounter.reference as e -> tgt.visit_occurrence_id = (%e.substring(%e.indexOf('/') + 1));
      };
      src.effective : dateTime as a ->  tgt.observation_datetime = cast(a, 'dateTime'),  tgt.observation_date = cast(a, 'date');
      src.effective : instant as einst ->  tgt.observation_datetime = cast(einst, 'dateTime'),  tgt.observation_date = cast(einst, 'date');
      src.effective : Period as s -> tgt then {
        s.start as ss ->  tgt.observation_datetime = cast(ss, 'dateTime'),  tgt.observation_date = cast(ss, 'date');
      };
      // src.issued as s where (src.issued.toDate()  != src.effective) -> tgt.observation_source_value = (s.toString());
      src.category -> tgt.observation_type_concept_id = 32817;
      src.value : Quantity as s -> tgt then {
        s.value as a -> tgt.value_as_number = cast(a, 'decimal');
        s.unit as b -> tgt.unit_concept_id = cast(b, 'string');
      };
      src.value : CodeableConcept as s -> tgt then {
        s.coding as sc -> tgt then {
          sc.code as a -> tgt.value_as_concept_id = cast(a, 'string');
        };
      };
      src.value : string as b -> tgt.value_as_string = cast(b, 'string');
    } "observationMap";
  } "OnlyObs";
}