join('report_duties as rd', 'rd.id', '=', 'p.report_duty_id') ->where('rd.rf_department_id', $query->department->department_id) ->where('rd.status_id', 2) ->where('rd.period_start', '>=', $query->dateRange->startSql()) ->where('rd.period_end', '<=', $query->dateRange->endSql()); } public function dimensions(): array { return [ $this->urgencyDimension('p'), $this->outcomeDimension('p'), new Dimension('recipient_date', 'Дата поступления', 'date', 'CAST(p.recipient_date AS date)'), new Dimension( 'doctor', 'Врач', 'string', 'rd.rf_lpudoctor_id', labels: fn (array $ids) => MisLpuDoctor::whereIn('LPUDoctorID', $ids)->get() ->mapWithKeys(fn ($d) => [$d->LPUDoctorID => trim("{$d->FAM_V} {$d->IM_V} {$d->OT_V}") ?: "Врач #{$d->LPUDoctorID}"]) ->all(), ), new Dimension( 'department', 'Отделение', 'string', 'rd.rf_department_id', labels: fn (array $ids) => Department::whereIn('department_id', $ids)->get() ->mapWithKeys(fn ($d) => [$d->department_id => $d->name_full ?? $d->name_short]) ->all(), ), ]; } public function measures(): array { return $this->patientMeasures('p', 'rd'); } public function filters(): array { return [ new FilterDef('doctor', 'Врач', 'rd.rf_lpudoctor_id', 'select', null, 'doctors'), new FilterDef('urgency', 'Срочность', 'p.urgency_id', 'select', [1 => 'Планово', 2 => 'Экстренно']), ]; } }