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 Immunization resource to Drug Exposure OMOP Domain V4

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

This mapping maps FHIR Immunization instances to OMOP Drug Exposure Table objects.

Language: en

/// url = 'http://hl7.org/fhir/uv/omop/StructureMap/ImmunizationMapV4'
/// version = '2.0.0-ballot'
/// name = 'ImmunizationMapV4'
/// title = 'Mapping Immunization resource to Drug Exposure OMOP Domain V4'
/// status = 'active'
/// description = 'This mapping maps FHIR Immunization instances to OMOP Drug Exposure Table objects.'

uses "http://hl7.org/fhir/StructureDefinition/Immunization|4.0.1" alias Immunization as source
uses "http://hl7.org/fhir/uv/omop/StructureDefinition/DrugExposure" alias DrugExposureTable as target

group DrugExposure(source src : Immunization, target tgt : DrugExposureTable) {
  src where (src.occurrence.empty().not()) then {
    // OMOP Drug Exposure ID would be a map from FHIR ID to an external key
    src as s -> tgt then {
      s.identifier as i -> tgt then {
        i.value as id -> tgt.drug_exposure_id = cast(id, 'integer');
      } "immunizationIdFromIdentifier";
    } "immunizationId";
    // OMOP Person ID would be a map from the FHIR Immunization Patient reference to an external key
    src.patient as subject -> tgt then {
      subject.reference as s -> tgt.person_id = (%s.substring(%s.indexOf('/') + 1));
    };
    // OMOP Visit Occurrence ID would be a map from the FHIR Immunization Encounter reference to an external key
    src.encounter as encounter -> tgt then {
      encounter.reference as e -> tgt.visit_occurrence_id = (%e.substring(%e.indexOf('/') + 1));
    };
    src.vaccineCode as s -> tgt then {
      s.coding first as sc -> tgt then {
        sc.code as c ->  tgt.drug_concept_id = translate(c, 'http://hl7.org/fhir/uv/omop/ConceptMap/ImmunizationVaccine', 'code'),  tgt.drug_source_value = cast(c, 'string');
      };
    };
    src.doseQuantity as s -> tgt then {
      s.value as s -> tgt.quantity = cast(s, 'decimal');
    };
    src.route as s -> tgt then {
      s.coding as sc -> tgt then {
        sc.code as c ->  tgt.route_concept_id = translate(c, 'http://hl7.org/fhir/uv/omop/ConceptMap/ImmunizationRoute', 'code'),  tgt.route_source_value = cast(c, 'string');
      };
    };
    src where (src.reportOrigin.empty()) -> tgt.drug_type_concept_id = 32818 "emptysource";
    src.reportOrigin as s -> tgt then {
      s.coding as c -> tgt then {
        c.code as c -> tgt.drug_type_concept_id = translate(c, 'http://hl7.org/fhir/uv/omop/ConceptMap/ImmunizationSource', 'code');
      };
    };
    src.occurrence : dateTime as odt ->  tgt.drug_exposure_start_date = (src.occurrence.toString().substring(0, 10)),  tgt.drug_exposure_start_datetime = cast(odt, 'dateTime'),  tgt.drug_exposure_end_date = (src.occurrence.toString().substring(0, 10)),  tgt.drug_exposure_end_datetime = cast(odt, 'dateTime');
    src.lotNumber as s -> tgt.lot_number;
  } "drugExposureMapping";
}