Добавил ограничение по отказникам
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user