Visit_Encounter.wstl · fhir2omop
refs/refs/mends-on-fhir/whistle-mappings/synthea/whistle-functions/Visit_Encounter.wstl
108 lines · wstl
1// See comments/note at end, below the funtion 3def Visit_Encounter(Visit, required context) { 5 resourceType: "Encounter" 7 // ESP .id -> Encounter.natural_key (varchar 128) 8 id: Visit.visit_occurrence_id 11 identifier[]: Identifier(Identifier_System("omop-id"), Visit.visit_occurrence_id) 17 class: CodingMapDefault(Visit.visit_concept_id, "VisitOccurrence.visit-concept-id--Encounter.class") 19 var classHistory: CodingMapNull(Visit.visit_concept_id, "VisitOccurrence.visit-concept-id--Encounter.classHistory") 20 if ( $IsNotNil(classHistory)) { 21 var ch.class: classHistory 22 var ch.period.id: "classHistory.period.hack.to.force.an.object.creation.TODO" 27 // R4 # Specific type of encounter (e.g. e-mail consultation, surgical day-care, skilled nursing, rehabilitation). 29 // USC VS http://hl7.org/fhir/us/core/ValueSet-us-core-encounter-type.html#expansion 30 // USC VS # The type of encounter: a specific code indicating type of service provided. This value set includes codes from SNOMED CT decending from the concept 308335008 (Patient encounter procedure (procedure)) and codes from the Current Procedure and Terminology (CPT) found in the following CPT sections: 31 // OMOP Visit: https://ohdsi.github.io/CommonDataModel/cdm53.html#visit_occurrence 32 // OMOP visit_concept_id: This field contains a concept id representing the kind of visit, like inpatient or outpatient. All concepts in this field should be standard and belong to the Visit domain. 33 // M # Denote Appointment Information (i.e APPT, LAB, RADIOLOGY, NO SHOW, HISTORY, APPT CANCELLED, etc.) 34 // M .text -> Encounter.raw_encounter_type (varchar 100) 36 type[]: Encounter_Type(Visit) 40 // M .identifier.value -> Encounter.patient_id (varchar 128) 41 // M? Encounter.mrn (varchar 50) 42 subject: Reference("Patient", Visit.person_id) 48 // M .start -> Encounter.hosp_admit_dt (date) 49 // M .end -> Encounter.hosp_dschrg_dt (date) 50 // Make sure that there are datetimes for both start and end, else only use dates for both 51 if context.config.output.phi = "yes" { 52 if $And($IsNotNil(Visit.visit_start_datetime), $IsNotNil(Visit.visit_end_datetime)) { 53 period.start: ReformatDatetime(Visit.visit_start_datetime) 54 period.end: ReformatDatetime(Visit.visit_end_datetime) 56 // TODO: Changed by mgk to not do ReformatDatetime() 57 // TODO: Discuss with Andrey 58 period.start: Visit.visit_start_date 59 period.end: Visit.visit_end_date 62 if $And($IsNotNil(Visit.visit_start_datetime), $IsNotNil(Visit.visit_end_datetime)) { 63 period.start: ReformatDatetime("2030-01-01") 64 period.end: ReformatDatetime("2030-01-01") 66 period.start: "2030-01-01" 67 period.end: "2030-01-01" 92// # To search for an encounter diagnosis, query for Condition resources that reference the Encounter of interest and have a category of encounter-diagnosis. An example search is shown in the Condition Quick Start section. 94// ************************************************************************* 96// * All Encounter-specific function calls here. 97// * Function calls useful accross resources are in DataTypes.wstl 99// ************************************************************************* 101def Encounter_Type(Visit) { 102 $this: CodeableConceptMapNull(Visit.visit_concept_id, "VisitOccurrence.visit-concept-id--Encounter.type", Visit.visit_source_value) 103 if Visit.visit_concept_id ~= Visit.visit_source_concept_id { 104 coding[]: Coding(Code_System(Visit.visit_source_vocabulary_id), "", Visit.visit_source_concept_code, Visit.visit_source_concept_name)