From 68626918a605bcd8c794051737a3de0af7701836 Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Mon, 9 Feb 2026 09:42:10 +0900 Subject: [PATCH] =?UTF-8?q?*=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D0=B8=D1=81=D1=82=D0=B8=D0=BA=D0=B8=20=D0=B2=20=D1=81?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D0=BD=D0=BE=D0=B9=20=D0=B5=D1=81=D0=BB=D0=B8?= =?UTF-8?q?=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/ReportService.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Services/ReportService.php b/app/Services/ReportService.php index 4f5f202..2a519ca 100644 --- a/app/Services/ReportService.php +++ b/app/Services/ReportService.php @@ -341,11 +341,11 @@ class ReportService 'emergency' => $this->getMetrikaResultCount(12, $reportIds), 'outcome' => $this->getMetrikaResultCount(7, $reportIds), 'deceased' => $this->getMetrikaResultCount(9, $reportIds), - 'current' => $this->getMetrikaResultCount(8, $reportIds), + 'current' => $this->getMetrikaResultCount(8, $reportIds, false), // 'discharged' => $this->getMetrikaResultCount('discharged', $reportIds), 'transferred' => $this->getMetrikaResultCount(13, $reportIds), 'recipient' => $this->getMetrikaResultCount(3, $reportIds), - 'beds' => $this->getMetrikaResultCount(1, $reportIds) + 'beds' => $this->getMetrikaResultCount(1, $reportIds, false) ]; // Получаем ID поступивших пациентов @@ -592,7 +592,7 @@ class ReportService if ($status === 'outcome') { return MedicalHistorySnapshot::whereIn('rf_report_id', $reportIds) - ->whereIn('patient_type', ['discharged', 'transferred', 'deceased']) + ->whereIn('patient_type', ['discharged', 'deceased']) ->distinct('rf_medicalhistory_id') ->count('rf_medicalhistory_id'); } @@ -737,17 +737,19 @@ class ReportService /** * Получить количество из метрик */ - private function getMetrikaResultCount(int $metrikaItemId, array $reportIds): int + private function getMetrikaResultCount(int $metrikaItemId, array $reportIds, bool $sum = true): int { $count = 0; $reports = Report::whereIn('report_id', $reportIds) ->with('metrikaResults') + ->orderBy('created_at', 'DESC') ->get(); foreach ($reports as $report) { foreach ($report->metrikaResults as $metrikaResult) { if ($metrikaResult->rf_metrika_item_id === $metrikaItemId) { - $count += intval($metrikaResult->value) ?? 0; + if ($sum) $count += intval($metrikaResult->value) ?? 0; + else $count = intval($metrikaResult->value) ?? 0; } } }