Добавил реанимацию

Правки окна операций
This commit is contained in:
brusnitsyn
2026-05-07 22:37:07 +09:00
parent bb9e67ab3d
commit 6cf1ffbb2b
11 changed files with 137 additions and 45 deletions

View File

@@ -76,6 +76,7 @@ class MedicalHistoryService
->sortByDesc(fn ($mh) => $mh->latestMigration->ingoing_date ?? $mh->recipient_date)
->values();
}
public function getEmergencyHistories(DateRange $dateRange, int $departmentId)
{
return MedicalHistory::query()
@@ -146,4 +147,27 @@ class MedicalHistoryService
}, 'latestMigration.operations'])
->get();
}
public function getReanimationHistories(DateRange $dateRange, int $departmentId)
{
return MedicalHistory::query()
->whereHas('migrations', function ($q) use ($departmentId, $dateRange) {
$q->department($departmentId)->currentOrAdmitted($dateRange);
})
->whereHas('latestMigration.reanimations', function ($q) use ($dateRange) {
$q->currentOrAdmitted($dateRange);
})
->with(
[
'latestMigration' => function ($q) use ($departmentId, $dateRange) {
$q->department($departmentId)->currentOrAdmitted($dateRange)->latest('ingoing_date'); // подгружаем только отфильтрованные движения
},
'latestMigration.operations',
'latestMigration.reanimations'
])
->get()
// Сортировка по дате поступления в отделение (поле дочерней таблицы)
->sortByDesc(fn ($mh) => $mh->latestMigration->ingoing_date ?? $mh->recipient_date)
->values();
}
}