From a916a7532a8df7cd820f120a5363def880ef1fe1 Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Thu, 11 Jun 2026 14:36:57 +0900 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/DutyReportService.php | 35 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/Services/DutyReportService.php b/app/Services/DutyReportService.php index 24cf6f2..ac6a888 100644 --- a/app/Services/DutyReportService.php +++ b/app/Services/DutyReportService.php @@ -330,8 +330,17 @@ class DutyReportService } } - // Если есть выбытие по миграции ИЛИ по карте - $hasOutcomeInPeriod = $hasExtractInPeriod || $hasDischargeInMigration; + // Умер в периоде (по дате смерти из карты) + $hasDeathInPeriod = false; + if (!empty($patient['death_date'])) { + $deathDateCarbon = Carbon::parse($patient['death_date']); + if ($deathDateCarbon >= $periodStartCarbon && $deathDateCarbon <= $periodEndCarbon) { + $hasDeathInPeriod = true; + } + } + + // Если есть выбытие по миграции, по карте ИЛИ смерть в периоде + $hasOutcomeInPeriod = $hasExtractInPeriod || $hasDischargeInMigration || $hasDeathInPeriod; if ($hasOutcomeInPeriod) { // Приоритет: данные из миграции (если есть), иначе из карты @@ -348,7 +357,6 @@ class DutyReportService // Флаги для пациента $hasRecipientInPeriod = false; - $hasDeathInPeriod = false; $hasTransferInPeriod = false; $hasDischargeInPeriod = false; $hasActiveMigrationInPeriod = false; @@ -372,18 +380,14 @@ class DutyReportService } } - // Умер в периоде - if (!empty($patient['death_date'])) { - $deathDateCarbon = Carbon::parse($patient['death_date']); - if ($deathDateCarbon >= $periodStartCarbon && $deathDateCarbon <= $periodEndCarbon) { - $hasDeathInPeriod = true; - } - } - // Выбытие в периоде (есть out_date в периоде) if ($outDate && $this->dateRangeService->dateInPeriod($outDate, $dateRange)) { + // Смерть (коды 5, 15) + if (in_array($visitResultId, [5, 15])) { + $hasDeathInPeriod = true; + } // Перевод (коды 4, 14) - if (in_array($visitResultId, [4, 14])) { + elseif (in_array($visitResultId, [4, 14])) { $hasTransferInPeriod = true; } // Выписка @@ -669,8 +673,11 @@ class DutyReportService } } - // extract_date оставляем всегда (это дата перевода/выбытия из отделения) - // Она может быть в пределах отчетного периода + // Если пациент умер, а дата выбытия из отделения не проставлена + // (миграция в МИС еще не закрыта) - используем дату смерти как дату выбытия + if (!empty($patient['death_date']) && empty($patient['extract_date'])) { + $patient['extract_date'] = $patient['death_date']; + } return $patient; }, $patientBatch);