How the CDM is filled

Code standardization, what is converted, how changes are kept, limits.

How codes are standardized

StepRule
VocabularyThe FHIR® code system URI is mapped to an OMOP vocabulary (SNOMED, LOINC®, RxNorm, CVX, ICD10, ICD10CM, NDC, UCUM, ATC, CPT4, HCPCS and more; the list can be extended through the API, PUT /dictionaries/api/omop/<id>/systems).
Standard conceptThe code is looked up in that vocabulary. A standard concept is used as it is; a non-standard concept goes through its Maps to relationship.
Several codingsA CodeableConcept may carry several codings: the first one that maps to a standard concept is used, otherwise the first one.
TableThe domain of the standard concept decides the table: a Condition resource with a Procedure concept becomes a procedure_occurrence. Without a concept the resource type decides (Condition: condition, Procedure: procedure, MedicationRequest and Immunization: drug, Observation with a number: measurement, otherwise observation). Device, Specimen, Visit and Episode concepts go to device_exposure, specimen, visit_occurrence and episode. A change of mapping moves the row.
Units and valuesUnits are mapped through UCUM; value concepts of coded values the same way.
Not mappedThe row is written with concept 0, the code as source value and the source concept. It appears in the unmapped codes worklist, most used first. Map it by hand with a concept search; the rows that carry it are written again at the next run. A manual mapping stays when the vocabulary is replaced.

What is converted

FHIROMOP
Organizationcare_site (+ location)
Practitionerprovider
Patientperson (gender, birth date, US Core race and ethnicity, location, general practitioner, managing organization) and death
Encountervisit_occurrence (class: IMP, ACUTE, NONAC inpatient; AMB, SS, FLD outpatient; EMER emergency; HH home; VR telehealth)
Condition, Procedure, Immunization, MedicationRequest, MedicationStatement, AllergyIntolerance, Observation (and each Observation.component)condition_occurrence, procedure_occurrence, drug_exposure, measurement, observation by the domain of the concept. An allergy is written to observation with the substance as concept.
Device, DeviceUseStatement (R5: DeviceUsage)device_exposure: the device type is the concept, the UDI and serial number are kept; a Device needs a patient and a manufactureDate
Specimenspecimen: type, body site (anatomic site concept), quantity and unit, accession number
DocumentReferencenote: the type is the note class, a text attachment is decoded into the note text (other attachments keep the title or description), language and encounter
Coveragepayer_plan_period: payer (type, for example a SOPT code), plan, policy holder, period (open end becomes 2099-12-31)
ExplanationOfBenefit (or Claim when there is no EOB)cost: total charge, amount paid by the payer, currency, linked to the visit of its first item
Route of a medication, body site of a specimenroute_concept_id and anatomic_site_concept_id
Encounter.locationvisit_detail: one row per location with its own period (the visit concept of the encounter)
Observation.hasMemberfact_relationship: Panel contains and Contained in panel between the panel and its members
EpisodeOfCareepisode, and episode_event for its diagnoses and for the visits that name it (the concepts for the relationship and the fields come from the vocabulary)
(derived)observation_period (first to last event of each person), condition_era (30 day persistence window), drug_era (by ingredient, needs CONCEPT_ANCESTOR), dose_era (needs DRUG_STRENGTH; only forms with an amount per unit, such as tablets) and cdm_source

Keeping it correct

Records are compared by their hashdiff: new and changed records are written, records that were deleted or disappeared from the raw vault are removed, and deleting a patient removes the patient's rows. The OMOP id of a record never changes (table omop_key_map). Records without a patient in the CDM, without a date or without a code cannot be written; they are counted and tried again at every run.

Careful

Limits: a claim is only used when its resource type is the only cost source (with an ExplanationOfBenefit present the Claim is skipped, otherwise the money would be counted twice); a cost needs a visit; a person without any event gets no observation_period; dose_era covers only forms with an amount per unit (tablets, capsules); drug_gap_days is approximate when exposures overlap; the tables cohort, cohort_definition, metadata and note_nlp content are not filled (note_nlp is created empty for NLP tools). Check the result with the OHDSI tools (Data Quality Dashboard, Achilles) before you use it for studies.

In the background

Everything runs in the database in batches of 20,000 records per resource type (OMOP_BATCH). Each batch is one transaction. The ETL reads resource_json with paths that work for R4, R4B and R5 (for example Encounter.class and actualPeriod, MedicationRequest.medication.concept).