50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Reports\BuiltIn;
|
|
|
|
use App\Models\Department;
|
|
use App\Services\DateRange;
|
|
use App\Services\Reports\Contracts\ReportDefinition;
|
|
use App\Services\Reports\ReportPayload;
|
|
use App\Services\Reports\ReportSourceRegistry;
|
|
|
|
class DutyDoctorReport implements ReportDefinition
|
|
{
|
|
public function __construct(private readonly ReportSourceRegistry $sources) {}
|
|
|
|
public function code(): string
|
|
{
|
|
return 'duty';
|
|
}
|
|
|
|
public function label(): string
|
|
{
|
|
return 'Отчёт дежурного врача';
|
|
}
|
|
|
|
public function requiredPermissions(): array
|
|
{
|
|
return ['report.view'];
|
|
}
|
|
|
|
public function build(Department $department, DateRange $dateRange): ReportPayload
|
|
{
|
|
$sections = [
|
|
$this->sources->get('duty_metrics')->toSection($department, $dateRange),
|
|
$this->sources->get('duty_patients')->toSection($department, $dateRange),
|
|
$this->sources->get('unwanted_events')->toSection($department, $dateRange),
|
|
$this->sources->get('observable_patients')->toSection($department, $dateRange),
|
|
];
|
|
|
|
return new ReportPayload(
|
|
title: $this->label(),
|
|
meta: [
|
|
'Отделение' => $department->name_full ?? $department->name_short,
|
|
'Период' => $dateRange->start()->format('d.m.Y H:i').' — '.$dateRange->end()->format('d.m.Y H:i'),
|
|
'Сформирован' => now('Asia/Yakutsk')->format('d.m.Y H:i'),
|
|
],
|
|
sections: $sections,
|
|
);
|
|
}
|
|
}
|