* исправил вывод статистики в сводной если выбран период
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user