refs/refs/fhir-to-omop-demo/demo/translate/map/MedicationAdministration.jq

lines 39–39 59 lines · jq
2# Transforms FHIR MedicationAdministrations into OMOP table records.
5include "fhir";
6include "fhir/common";
9def drug:
10 if (.medicationCodeableConcept.coding | length) > 1 then
11 error("Multiple medicationCodeableConcept.codings in MedicationAdministration/\(.id)")
12 end
13 | .medicationCodeableConcept.coding[0].concept
17# See: https://ohdsi.github.io/CommonDataModel/drug_dose.html
18# TODO: include the 'has dose form' value in concept
19# TODO: include numerator in concept
20def quantity:
21 if (drug | has("drug") and drug.has_dose_form) then
22 drug.drug.numerator
23 else
24 null
25 end
28MedicationAdministration |
30 "drug_exposure", # TABLE COLUMNS
31 .id, # drug_exposure_id
32 .subject.id, # person_id
33 drug.concept_id, # drug_concept_id
34 .effectiveDateTime, # drug_exposure_start_date
35 .effectiveDateTime, # drug_exposure_start_datetime
36 .effectiveDateTime, # drug_exposure_end_date
37 .effectiveDateTime, # drug_exposure_end_datetime
38 null, # verbatim_end_date
39 32818, # drug_type_concept_id - EHR administration record
40 null, # stop_reason
41 null, # refills
42 quantity, # quantity
43 null, # days_supply
44 .note, # sig
45 null, # route_concept_id
46 null, # lot_number
47 null, # provider_id
48 .context.id, # visit_occurrence_id
49 null, # visit_detail_id
50 drug.concept_code, # drug_source_value
51 drug.source_concept_id, # drug_source_concept_id
52 null, # route_source_value
53 null # dose_unit_source_value
55| select(
56 ((.[0] == "drug_exposure") and length == 24)
59@tsv