From 7f2e57eda6e053014a1753aaaae5d2f6048e050c Mon Sep 17 00:00:00 2001 From: Stephen Nielson Date: Thu, 9 Nov 2023 15:24:11 -0500 Subject: [PATCH] Fixes #7002 FHIR api warnings missing keys (#7005) Allergy intollerance was failing when the unassigned reaction was given since there are no codes and that threw a warning. social history was relying on columns that didn't exist that also threw warnings. Vitals services temp_method was not being set properly and threw a warning. Procedure service had a number of columns it attempted to populate but the actual data values did not match with the array keys. --- .../FHIR/FhirAllergyIntoleranceService.php | 3 +- .../FhirObservationSocialHistoryService.php | 2 - .../FhirObservationVitalsService.php | 10 ++-- src/Services/ProcedureService.php | 50 +++++++++---------- src/Services/SocialHistoryService.php | 2 +- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/Services/FHIR/FhirAllergyIntoleranceService.php b/src/Services/FHIR/FhirAllergyIntoleranceService.php index 0f53a9019d3..3fdc04ad0ff 100644 --- a/src/Services/FHIR/FhirAllergyIntoleranceService.php +++ b/src/Services/FHIR/FhirAllergyIntoleranceService.php @@ -171,7 +171,8 @@ public function parseOpenEMRRecord($dataRecord = array(), $encode = false) // cardinality is 0..* // however in OpenEMR we currently only track a single reaction, we will populate it if we have it. - if (!empty($dataRecord['reaction'])) { + // if a reaction is unassigned, it has no codes and so we will skip over this as it has no meaning in FHIR. + if (!empty($dataRecord['reaction']) && $dataRecord['reaction'] !== 'unassigned') { $reaction = new FHIRAllergyIntoleranceReaction(); $reactionConcept = new FHIRCodeableConcept(); $conceptText = $dataRecord['reaction_title'] ?? ""; diff --git a/src/Services/FHIR/Observation/FhirObservationSocialHistoryService.php b/src/Services/FHIR/Observation/FhirObservationSocialHistoryService.php index 9dca59a9b19..fc64062dfc4 100644 --- a/src/Services/FHIR/Observation/FhirObservationSocialHistoryService.php +++ b/src/Services/FHIR/Observation/FhirObservationSocialHistoryService.php @@ -212,8 +212,6 @@ private function parseSocialHistoryIntoObservationRecords(ProcessingResult $proc ,"description" => $this->getDescriptionForCode($code) ,"category" => "social-history" , "puuid" => $record['puuid'] - , "euuid" => $record['euuid'] - , "user_uuid" => $record['user_uuid'] ,"uuid" => UuidRegistry::uuidToString($uuidMappings[$code]) ,"date" => $record['date'] ]; diff --git a/src/Services/FHIR/Observation/FhirObservationVitalsService.php b/src/Services/FHIR/Observation/FhirObservationVitalsService.php index a500d1f20d1..0c59793ac4d 100644 --- a/src/Services/FHIR/Observation/FhirObservationVitalsService.php +++ b/src/Services/FHIR/Observation/FhirObservationVitalsService.php @@ -105,7 +105,7 @@ class FhirObservationVitalsService extends FhirServiceBase implements IPatientCo 'fullcode' => 'LOINC:8327-9', 'code' => '8327-9', 'description' => 'Temperature Location', - 'column' => 'temp_method', + 'column' => ['temp_method'], 'in_vitals_panel' => true ] ,'8302-2' => [ @@ -696,8 +696,12 @@ private function populateComponentColumn(FHIRObservation $observation, $dataReco private function populateBodyTemperatureLocation(FHIRObservation $observation, $record) { - // no guidance on how to pass this on, so we are using the value string to pass this on. - $observation->setValueString($record['temp_method']); + if (empty($record['temp_method'])) { + $observation->setDataAbsentReason(UtilsService::createDataAbsentUnknownCodeableConcept()); + } else { + // no guidance on how to pass this on, so we are using the value string to pass this on. + $observation->setValueString($record['temp_method']); + } } /** diff --git a/src/Services/ProcedureService.php b/src/Services/ProcedureService.php index e88e6adc276..f5c98d1f6fd 100644 --- a/src/Services/ProcedureService.php +++ b/src/Services/ProcedureService.php @@ -62,14 +62,14 @@ public function search($search, $isAndCondition = true) ,porder.order_diagnosis ,porder.order_encounter_id ,porder.order_lab_id - + ,preport.report_date ,preport.procedure_report_id ,preport.report_uuid ,preport.report_notes - + ,presult.procedure_result_id - ,presult.result_uuid + ,presult.result_uuid ,presult.result_code ,presult.result_text ,presult.result_units @@ -78,18 +78,18 @@ public function search($search, $isAndCondition = true) ,presult.result_abnormal ,presult.result_comments ,presult.result_status - + ,order_codes.procedure_name ,order_codes.procedure_code ,order_codes.procedure_type - + ,pcode_types.standard_code ,labs.lab_id ,labs.lab_uuid ,labs.lab_npi ,labs.lab_name - + ,patients.puuid ,patients.pid @@ -99,7 +99,7 @@ public function search($search, $isAndCondition = true) ,docs.doc_id ,docs.doc_uuid - + ,provider.provider_uuid ,provider.provider_id ,provider.provider_fname @@ -118,7 +118,7 @@ public function search($search, $isAndCondition = true) procedure_report ) preport LEFT JOIN ( - SELECT + SELECT procedure_result_id ,procedure_report_id ,uuid AS result_uuid @@ -137,10 +137,10 @@ public function search($search, $isAndCondition = true) FROM `procedure_result` ) presult - ON + ON preport.procedure_report_id = presult.procedure_report_id LEFT JOIN ( - SELECT + SELECT procedure_order_id ,uuid AS order_uuid ,provider_id AS order_provider_id @@ -154,7 +154,7 @@ public function search($search, $isAndCondition = true) FROM procedure_order ) porder - ON + ON porder.procedure_order_id = preport.procedure_order_id LEFT JOIN ( @@ -173,12 +173,12 @@ public function search($search, $isAndCondition = true) ,npi AS lab_npi ,`name` AS lab_name ,`active` AS lab_active - FROM + FROM procedure_providers ) labs - ON + ON labs.lab_id = porder.order_lab_id - LEFT JOIN + LEFT JOIN ( select procedure_order_id @@ -190,7 +190,7 @@ public function search($search, $isAndCondition = true) FROM procedure_order_code ) order_codes - ON + ON order_codes.procedure_order_id = porder.procedure_order_id AND order_codes.procedure_order_seq = preport.procedure_order_seq LEFT JOIN ( select @@ -199,17 +199,17 @@ public function search($search, $isAndCondition = true) FROM procedure_type ) pcode_types ON order_codes.procedure_code = pcode_types.proc_code LEFT JOIN ( - select + select pid ,uuid AS puuid FROM patient_data ) patients - ON - patients.pid = porder.order_patient_id - + ON + patients.pid = porder.order_patient_id + LEFT JOIN ( - select + select id AS doc_id ,uuid AS doc_uuid FROM @@ -298,10 +298,10 @@ private function hydrateSearchResultsFromQueryResource($queryResource) $procedure['provider'] = [ 'id' => $record['provider_id'] ,'uuid' => $record['provider_uuid'] - ,'fname' => $record['fname'] - ,'mname' => $record['mname'] - ,'lname' => $record['lname'] - ,'npi' => $record['npi'] + ,'fname' => $record['provider_fname'] + ,'mname' => $record['provider_mname'] + ,'lname' => $record['provider_lname'] + ,'npi' => $record['provider_npi'] ]; } if (!empty($record['lab_id'])) { @@ -366,7 +366,7 @@ private function hydrateSearchResultsFromQueryResource($queryResource) , 'range' => $record['result_range'] , 'abnormal' => $record['result_abnormal'] , 'comments' => $record['result_comments'] - , 'document_id' => $record['result_document_id'] + , 'document_id' => $record['doc_id'] , 'status' => $record['result_status'] ]; $report['results'][] = $result; diff --git a/src/Services/SocialHistoryService.php b/src/Services/SocialHistoryService.php index 8aceca324c5..2f4f2703bd6 100644 --- a/src/Services/SocialHistoryService.php +++ b/src/Services/SocialHistoryService.php @@ -188,7 +188,7 @@ function getUuidFields(): array { // note the uuid here is the uuid_mapping table's uuid since each column in the table has its own distinct uuid // in the system. - return ['puuid', 'euuid', 'uuid', 'user_uuid']; + return ['puuid', 'uuid']; }