> */ public function all(): array { return [ [ 'key' => 'blank', 'label' => 'Без шаблона', 'description' => 'Самостоятельно выберите источник, группировки и показатели', 'category' => 'Все', 'dataset' => null, 'thumbnail' => [], 'config' => $this->config(null), ], [ 'key' => 'by_shifts', 'label' => 'По сменам', 'description' => 'Показатели дежурных смен по датам', 'category' => 'Дежурства', 'dataset' => 'shifts', 'thumbnail' => ['Дата смены', 'Поступило', 'Выписано', 'Умерло'], 'config' => $this->config('shifts', ['shift_date'], ['shifts_count', 'recipient_plan', 'recipient_emergency', 'discharged', 'deceased'], ['metric' => 'recipient_plan', 'type' => 'bar']), ], [ 'key' => 'by_patients', 'label' => 'По пациентам', 'description' => 'Структура пациентов по срочности и исходам', 'category' => 'Пациенты', 'dataset' => 'patients', 'thumbnail' => ['Срочность', 'Исход', 'Пациентов'], 'config' => $this->config('patients', ['urgency', 'outcome'], ['patients_count', 'admitted', 'discharged', 'deceased'], ['metric' => 'patients_count', 'type' => 'donut']), ], [ 'key' => 'unwanted', 'label' => 'Нежелательные события', 'description' => 'Количество нежелательных событий по типам', 'category' => 'События', 'dataset' => 'unwanted_events', 'thumbnail' => ['Событие', 'Количество'], 'config' => $this->config('unwanted_events', ['event_title'], ['events_count'], ['metric' => 'events_count', 'type' => 'bar']), ], [ 'key' => 'nurse', 'label' => 'Журнал медсестры', 'description' => 'Пациенты журнала по исходам', 'category' => 'Журнал', 'dataset' => 'nurse_journal', 'thumbnail' => ['Исход', 'Пациентов', 'Умерло'], 'config' => $this->config('nurse_journal', ['outcome'], ['patients_count', 'admitted', 'discharged', 'deceased'], ['metric' => 'patients_count', 'type' => 'bar']), ], [ 'key' => 'department_statistics', 'label' => 'Статистика по отделениям', 'description' => 'Сводная статистика по всем отделениям (профили, ИТОГО)', 'category' => 'Сводные', 'dataset' => 'department_statistics', 'thumbnail' => ['Отделение', 'Коек', 'Поступило', 'Состоит', 'Умерло'], 'config' => $this->config('department_statistics'), ], [ 'key' => 'nurse_shifts', 'label' => 'Смены медсестры', 'description' => 'Список своих смен с показателями по пациентам', 'category' => 'Журнал', 'dataset' => 'nurse_shifts', 'thumbnail' => ['Дата смены', 'Поступило', 'Выписано', 'Умерло'], 'config' => $this->config('nurse_shifts', ['shift_date'], ['shifts_count', 'patients_count', 'admitted', 'discharged', 'deceased'], ['metric' => 'admitted', 'type' => 'bar']), ], ]; } public function find(string $key): ?array { foreach ($this->all() as $preset) { if ($preset['key'] === $key) { return $preset; } } return null; } /** * @return array */ public function categories(): array { return ['Все', ...collect($this->all()) ->pluck('category') ->reject(fn ($c) => $c === 'Все') ->unique() ->values() ->all()]; } /** * @param array $dimensions * @param array $measures * @param array $chart * @return array */ private function config(?string $dataset, array $dimensions = [], array $measures = [], array $chart = []): array { return [ 'dataset' => $dataset, 'dimensions' => $dimensions, 'measures' => $measures, 'filters' => [], 'mode' => 'period', 'detalization' => 'month', 'chart' => [ 'metric' => $chart['metric'] ?? ($measures[0] ?? null), 'type' => $chart['type'] ?? 'bar', ], ]; } }