Убрал инкремент из получения текущих пациентов
This commit is contained in:
@@ -126,17 +126,28 @@ class MetrikaService
|
||||
// Один запрос, который сразу возвращает суммы по каждому типу
|
||||
$totals = DB::table('duty_report_metric_results')
|
||||
->whereIn('rf_report_id', $reportIds) // предполагаем внешний ключ `report_id`
|
||||
->whereIn('rf_metrika_item_id', [3, 7, 8, 17])
|
||||
->whereIn('rf_metrika_item_id', [3, 15, 17])
|
||||
->select('rf_metrika_item_id', DB::raw('SUM(value::integer) as total'))
|
||||
->groupBy('rf_metrika_item_id')
|
||||
->pluck('total', 'rf_metrika_item_id')
|
||||
->toArray();
|
||||
|
||||
// Получаем последний отчёт из коллекции (по полю report_date)
|
||||
$lastReport = $reportsDuty->sortByDesc('report_date')->first();
|
||||
$currentValue = 0;
|
||||
|
||||
if ($lastReport) {
|
||||
$currentValue = DB::table('duty_report_metric_results')
|
||||
->where('rf_report_id', $lastReport->id)
|
||||
->where('rf_metrika_item_id', 8)
|
||||
->value('value');
|
||||
}
|
||||
|
||||
// Формируем итоговый массив с ключами, как у вас
|
||||
return [
|
||||
'recipient' => $totals[3] ?? 0,
|
||||
'outcome' => $totals[7] ?? 0,
|
||||
'current' => $totals[8] ?? 0,
|
||||
'current' => intval($currentValue),
|
||||
'staff' => $totals[17] ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user