Добавил реанимацию
Правки окна операций
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user