diff --git a/app/Exports/DutyReportExport.php b/app/Exports/DutyReportExport.php index f126ad0..ce7dd58 100644 --- a/app/Exports/DutyReportExport.php +++ b/app/Exports/DutyReportExport.php @@ -37,7 +37,7 @@ class DutyReportExport 'plannedOperations' => $this->operationsGroup($patients, [6]), 'urgentOperations' => $this->operationsGroup($patients, [4, 5]), 'reanimation' => $this->flagGroup($patients, 'in_reanimation'), - 'observableCount' => $patients->where('in_observable', true)->count(), + 'observables' => $this->observableGroup($patients), 'deceased' => $this->flagGroup($patients, 'period_flags.deceased'), ]; } @@ -92,10 +92,23 @@ class DutyReportExport 'full_name' => $patient['full_name'], 'age' => $age !== null ? "{$age} ".$this->pluralizeAge($age) : '', 'diagnosis' => $withDiagnosis ? (data_get($patient, 'latest_migration.diagnosis_name') ?? '') : null, - 'migration_id' => (data_get($patient, 'latest_migration.original_id') ?? '') + 'migration_id' => (data_get($patient, 'latest_migration.original_id') ?? ''), + 'observable_reason' => (data_get($patient, 'observable.observable_reason') ?? '') ]; } + private function observableGroup(Collection $patients): array + { + // Поступившие именно в этот отчётный период (сутки), а не все, кто вообще сейчас в отделении + $filtered = $patients + ->where('in_observable', true) + ->values(); + + return [ + 'count' => $filtered->count(), + 'patients' => $filtered->map(fn (array $p) => $this->presentPatient($p))->all(), + ]; + } private function pluralizeAge(int $age): string { $mod100 = $age % 100; diff --git a/resources/views/reports/duty.blade.php b/resources/views/reports/duty.blade.php index 1245fea..960376e 100644 --- a/resources/views/reports/duty.blade.php +++ b/resources/views/reports/duty.blade.php @@ -18,12 +18,12 @@

Плановые: {{ $planned['count'] }}

@foreach ($planned['patients'] as $i => $p) -

{{ $i + 1 }}. {{ $p['full_name'] }} {{ $p['age'] }}.@if ($p['diagnosis']) Д/З: {{ $p['diagnosis'] }}.@endif id = {{ $p['migration_id'] }}

+

{{ $i + 1 }}. {{ $p['full_name'] }} {{ $p['age'] }}.@if ($p['diagnosis']) Д/З: {{ $p['diagnosis'] }}.@endif

@endforeach

Экстренные: {{ $urgent['count'] }}

@foreach ($urgent['patients'] as $i => $p) -

{{ $i + 1 }}. {{ $p['full_name'] }} {{ $p['age'] }}.@if ($p['diagnosis']) Д/З: {{ $p['diagnosis'] }}.@endif id = {{ $p['migration_id'] }}

+

{{ $i + 1 }}. {{ $p['full_name'] }} {{ $p['age'] }}.@if ($p['diagnosis']) Д/З: {{ $p['diagnosis'] }}.@endif

@endforeach

В отделении состоит: {{ $inDepartment }}

@@ -43,7 +43,10 @@

{{ $i + 1 }}. {{ $p['full_name'] }} {{ $p['age'] }}.@if ($p['diagnosis']) {{ $p['diagnosis'] }}.@endif

@endforeach -

Под наблюдением: {{ $observableCount }}

+

Под наблюдением: {{ $observables['count'] }}

+ @foreach ($observables['patients'] as $i => $p) +

{{ $i + 1 }}. {{ $p['full_name'] }} {{ $p['age'] }}.@if ($p['diagnosis']) {{ $p['diagnosis'] }}.@endif
@if ($p['observable_reason']) {{ $p['observable_reason'] }}.@endif

+ @endforeach

Летальные исходы: {{ $deceased['count'] > 0 ? '' : 'не было.' }}

@foreach ($deceased['patients'] as $i => $p)