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 Condition resource to Condition Occurrence OMOP Domain V4

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

This mapping maps FHIR Condition instances to OMOP Condition Occurence Table objects.

Language: en

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

uses "http://hl7.org/fhir/StructureDefinition/Condition|4.0.1" alias Condition as source
uses "http://hl7.org/fhir/uv/omop/StructureDefinition/ConditionOccurrence" alias ConOccTable as target

group ConditionOccurrence(source src : Condition, target tgt : ConOccTable) {
  src where (src.onset.empty().not() | src.recordedDate.empty().not()) then {
    // OMOP Condition 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.condition_occurrence_id = cast(id, 'integer');
      } "conditionIdFromIdentifier";
    } "conditionId";
    // OMOP Person ID would be a map from the FHIR Condition subject reference to an external key
    src.subject as subject -> tgt then {
      subject.reference as s -> tgt.person_id = (%s.substring(%s.indexOf('/') + 1));
    };
    src.code as s -> tgt then {
      s.coding as sc -> tgt then {
        sc.code as a -> tgt.condition_concept_id = translate(a, 'http://hl7.org/fhir/uv/omop/ConceptMap/ConditionConcepts', 'code');
        sc.display as d -> tgt.condition_source_value = cast(d, 'string');
      };
    };
    src.onset : dateTime as osd ->  tgt.condition_start_datetime = cast(osd, 'dateTime'),  tgt.condition_start_date = cast(osd, 'date');
    src.abatement : dateTime as abdt ->  tgt.condition_end_datetime = cast(abdt, 'dateTime'),  tgt.condition_end_date = cast(abdt, 'date');
    src.recordedDate as rd ->  tgt.condition_start_datetime = cast(rd, 'dateTime'),  tgt.condition_start_date = cast(rd, 'date');
    src.clinicalStatus as s -> tgt then {
      s.coding as sc -> tgt then {
        sc.code as a ->  tgt.condition_status_concept_id = translate(a, 'http://hl7.org/fhir/uv/omop/ConceptMap/ConditionStatusConcepts', 'code'),  tgt.condition_status_source_value = cast(a, 'string');
      };
    };
    src.encounter as encounter -> tgt then {
      encounter.reference as e -> tgt.visit_occurrence_id = (%e.substring(%e.indexOf('/') + 1));
    };
    src.category -> tgt.condition_type_concept_id = 32817 "default";
  } "conditionMapping";
}