Patient.jq · fhir2omop
refs/refs/fhir-to-omop-demo/demo/translate/map/Patient.jq
114 lines · jq
2# Transforms FHIR Patients into OMOP person table records. 8def yob: .birthDate | split("-")[0] | tonumber; 9def mob: .birthDate | split("-")[1] | tonumber; 10def dob: .birthDate | split("-")[2] | tonumber; 16 | select(.url == "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex") 19 if ($gender | length) > 1 then 20 debug("Patient/\(.id) has multiple genders") | 22 elif ($gender | length) == 1 then 25 debug("Patient/\(.id) has no gender") | 32 if $gender.valueCode == "M" then 34 elif $gender.valueCode == "F" then 37 debug("Unable to determine gender for Patient/\(.id)") | 46 | select(.url == "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity") 48 | select(has("valueCoding")) 52 if ($ethnicity | length) > 1 then 53 debug("Multiple ethnicities in Patient/\(.id)") | 55 elif ($ethnicity | length) == 1 then 58 debug("Patient/\(.id) has no ethnicity") | 67 | select(.url == "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race") 69 | select(has("valueCoding")) 73 if ($races | length) > 1 then 74 debug("Multiple races in Patient/\(.id)") | 76 elif ($races | length) == 1 then 79 debug("Patient/\(.id) has no race") | 84# Creates a link that work in the local hapi server. 86 # Would be nicer if there was a module for accessing env variables for this. 87 "http://localhost:8080/Patient/\(.id)" 92 "person", # OMOP person table 94 gender_concept_id, # gender_concept_id 98 null, # birth_datetime 99 race.concept_id, # race_concept_id 100 ethnicity.concept_id, # ethnicity_concept_id 102 null, # provider_id - last seen general practitioner 103 null, # care_site_id - the location of their provider 104 hapi_url, # person_source_value 105 gender.valueCode, # gender_source_value 106 null, # gender_source_concept_id 107 race.concept_code, # race_source_value 108 race.source_concept_id, # race_source_concept_id 109 ethnicity.concept_code, # ethnicity_source_value 110 ethnicity.source_concept_id # ethnicity_source_concept_id