From 3f51af226e3c2fec8e5b99753faad21e5f854f0a Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Mon, 15 Jun 2026 10:04:35 +0900 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=B0=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=D0=BC=D0=B5=D1=80=D1=82=D0=B8=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DutyReportService.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Services/DutyReportService.php b/app/Services/DutyReportService.php index a3240c7..10765bb 100644 --- a/app/Services/DutyReportService.php +++ b/app/Services/DutyReportService.php @@ -424,7 +424,15 @@ class DutyReportService $hasDeathInPeriod = false; if (!empty($patient['death_date'])) { $deathDateCarbon = Carbon::parse($patient['death_date']); - if ($deathDateCarbon >= $periodStartCarbon && $deathDateCarbon <= $periodEndCarbon) { + $deathInPeriod = $deathDateCarbon >= $periodStartCarbon && $deathDateCarbon <= $periodEndCarbon; + + // Если пациента выписали/перевели из этого отделения раньше даты смерти, + // значит смерть наступила уже в другом отделении - здесь её не учитываем, + // иначе одна смерть считается в нескольких отделениях (источник + принимающее). + $diedAfterLeavingDepartment = $migrationOutDate + && Carbon::parse($migrationOutDate)->lt($deathDateCarbon); + + if ($deathInPeriod && !$diedAfterLeavingDepartment) { $hasDeathInPeriod = true; } } @@ -436,7 +444,8 @@ class DutyReportService // Приоритет: данные из миграции (если есть), иначе из карты $patientData['visit_result_id'] = $migrationVisitResultId ?? $patient['visit_result_id'] ?? null; $patientData['extract_date'] = $migrationOutDate ?? $patient['extract_date'] ?? null; - $patientData['death_date'] = $patient['death_date'] ?? null; + // Дату смерти проставляем только если пациент действительно умер в этом отделении + $patientData['death_date'] = $hasDeathInPeriod ? ($patient['death_date'] ?? null) : null; } else { $patientData['visit_result_id'] = null; $patientData['extract_date'] = null;