Skip to content

Commit

Permalink
Fixes openemr#7002 FHIR api warnings missing keys (openemr#7005)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adunsulag authored Nov 9, 2023
1 parent 82028bb commit 7f2e57e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/Services/FHIR/FhirAllergyIntoleranceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
];
Expand Down
10 changes: 7 additions & 3 deletions src/Services/FHIR/Observation/FhirObservationVitalsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -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']);
}
}

/**
Expand Down
50 changes: 25 additions & 25 deletions src/Services/ProcedureService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
(
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Services/SocialHistoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}


Expand Down

0 comments on commit 7f2e57e

Please sign in to comment.