From 4c77e4d5588bd247b4597a6851985de1ef9218c2 Mon Sep 17 00:00:00 2001 From: Stephen Nielson Date: Tue, 8 Nov 2022 09:07:30 -0500 Subject: [PATCH] Fixes #5932 don't fail on empty group export (#5935) Makes it so we don't die w/ a 500 when there are no patients in a group to export. It just returns on the request. --- .../FHIR/Traits/FhirBulkExportDomainResourceTrait.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Services/FHIR/Traits/FhirBulkExportDomainResourceTrait.php b/src/Services/FHIR/Traits/FhirBulkExportDomainResourceTrait.php index cf495e0cc..4629fd882 100644 --- a/src/Services/FHIR/Traits/FhirBulkExportDomainResourceTrait.php +++ b/src/Services/FHIR/Traits/FhirBulkExportDomainResourceTrait.php @@ -13,6 +13,7 @@ namespace OpenEMR\Services\FHIR\Traits; +use OpenEMR\Common\Logging\SystemLogger; use OpenEMR\FHIR\Export\ExportCannotEncodeException; use OpenEMR\FHIR\Export\ExportException; use OpenEMR\FHIR\Export\ExportJob; @@ -50,16 +51,19 @@ trait FhirBulkExportDomainResourceTrait $type = $job->getExportType(); - - // we would need to grab all of the patient ids that belong to this group - // TODO: @adunsulag if we fully implement groups of patient populations we would set our patient ids into $searchParams - // or filter the results here. Right now we treat all patients as belonging to the same '1' group. $searchParams = []; if ($type == ExportJob::EXPORT_OPERATION_GROUP) { - $group = $job->getGroupId(); - - $patientUuids = $job->getPatientUuidsToExport(); if ($this instanceof IPatientCompartmentResourceService) { + $patientUuids = $job->getPatientUuidsToExport(); + if (empty($patientUuids)) { + // TODO: @adunsulag do we want to handle this higher up the chain instead of creating a bunch of + // empty files with no data? + return; // nothing to export here as we have no patients + } + (new SystemLogger())->debug( + "FhirBulkExportDomainResourceTrait->export() filtering by patient uuids", + ['export-type' => 'group', 'patients' => $patientUuids, 'resource-class' => get_class($this)] + ); $searchField = $this->getPatientContextSearchField(); $searchParams[$searchField->getName()] = implode(",", $patientUuids); } -- 2.11.4.GIT