Добавлено сохранение правок поверх МИС

Добавлено версионирование сохраненных правок
Добавлено сохранение отчета мед. сестры
This commit is contained in:
brusnitsyn
2026-05-04 22:23:21 +09:00
parent 7a58812072
commit 82673f385b
9 changed files with 241 additions and 23 deletions

View File

@@ -6,7 +6,7 @@ use Illuminate\Database\Eloquent\Model;
class UnifiedMedicalHistory extends MaterializedViewModel
{
protected $table = 'v_unified_medical_history';
protected $table = 'v_unified_medical_history_nurse';
protected $primaryKey = 'id';
protected $casts = [
@@ -16,4 +16,31 @@ class UnifiedMedicalHistory extends MaterializedViewModel
'death_date' => 'datetime',
'male' => 'boolean',
];
public function migrations(): \Illuminate\Database\Eloquent\Relations\HasMany|MedicalHistory
{
return $this->hasMany(MigrationPatient::class, 'medical_history_id', 'id');
}
public function operations(): \Illuminate\Database\Eloquent\Relations\HasMany|MedicalHistory
{
return $this->hasMany(SurgicalOperation::class, 'medical_history_id', 'id');
}
public function latestMigration()
{
return $this->hasOne(MigrationPatient::class, 'medical_history_id', 'id')
->latest('ingoing_date');
}
public function operationsInDepartment($query, $departmentId)
{
return $this->operations()->where('department_id', $departmentId);
}
// Скоупы
public function scopeUrgency($query, $typeId) // 1 = Экстренно, 2 = Планово
{
return $query->where('urgency_id', $typeId);
}
}