Добавил ограничение по отказникам

This commit is contained in:
brusnitsyn
2026-06-17 17:38:48 +09:00
parent fe59410187
commit 839a534bb2
6 changed files with 105 additions and 3 deletions

View File

@@ -53,6 +53,24 @@ class MedicalHistory extends MaterializedViewModel
->latest('observable_in');
}
public function denial()
{
return $this->hasOne(MisDenial::class, 'rf_MedicalHistoryID', 'id');
}
/**
* Исключить отказников от госпитализации.
* Безопасно: пока таблицы отказов нет в реплике no-op (см. MisDenial::tableAvailable()).
*/
public function scopeWithoutDenials($query)
{
if (MisDenial::tableAvailable()) {
$query->whereDoesntHave('denial');
}
return $query;
}
public function operationsInDepartment($query, $departmentId)
{
return $this->operations()->where('department_id', $departmentId);