diff --git a/app/Exports/DutyReportExport.php b/app/Exports/DutyReportExport.php index 87b3425..04b39ba 100644 --- a/app/Exports/DutyReportExport.php +++ b/app/Exports/DutyReportExport.php @@ -49,8 +49,9 @@ class DutyReportExport private function urgencyGroup(Collection $patients, string $flag): array { + // Поступившие именно в этот отчётный период (сутки), а не все, кто вообще сейчас в отделении $filtered = $patients - ->where('period_flags.current_at_end', true) + ->where('period_flags.recipient', true) ->where("period_flags.{$flag}", true) ->values(); @@ -62,8 +63,12 @@ class DutyReportExport private function operationsGroup(Collection $patients, array $urgentStatuses): array { + // latest_migration.operations уже ограничены периодом (start_date в рамках суток), + // в отличие от верхнеуровневого operations, у которого нижняя граница не задана $filtered = $patients->filter(function (array $p) use ($urgentStatuses) { - return collect($p['operations'] ?? [])->whereIn('urgent_status', $urgentStatuses)->isNotEmpty(); + return collect(data_get($p, 'latest_migration.operations', [])) + ->whereIn('urgent_status', $urgentStatuses) + ->isNotEmpty(); })->values(); return [