join('report_nurses as rn', 'rn.id', '=', 'p.report_nurse_id') ->where('rn.rf_department_id', $query->department->department_id) ->where('rn.status_id', 2) ->where('rn.period_start', '>=', $query->dateRange->startSql()) ->where('rn.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( 'department', 'Отделение', 'string', 'rn.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', 'rn'); } public function filters(): array { return [ new FilterDef('nurse', 'Медсестра', 'rn.rf_lpudoctor_id', 'select', null, 'nurse_doctors'), new FilterDef('urgency', 'Срочность', 'p.urgency_id', 'select', [1 => 'Планово', 2 => 'Экстренно']), ]; } }