* оптимизация обновления при редактировании спец контингента * добавил поддержку заключительных диагнозов * изменил определение законченной операции * добавил поддержку исхода операции * добавил определение отмены для операции через назначение * работа над диапазонами календарей, подсчет статистики * добавил статусы отчетов и подкорректировал привязку спец контингента к отчету * добавил новые сервисы для будущего кеширования * частичное разделение логики подсчета пациентов
62 lines
1.4 KiB
PHP
62 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class DepartmentPatient extends Model
|
|
{
|
|
protected $primaryKey = 'department_patient_id';
|
|
|
|
protected $fillable = [
|
|
'rf_department_id',
|
|
'rf_report_id',
|
|
'source_type',
|
|
'rf_medicalhistory_id',
|
|
'full_name',
|
|
'birth_date',
|
|
'patient_kind',
|
|
'diagnosis_code',
|
|
'diagnosis_name',
|
|
'admitted_at',
|
|
'is_current',
|
|
'outcome_type',
|
|
'outcome_at',
|
|
'created_by',
|
|
'linked_to_mis_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'birth_date' => 'date',
|
|
'admitted_at' => 'datetime',
|
|
'is_current' => 'boolean',
|
|
'outcome_at' => 'datetime',
|
|
'linked_to_mis_at' => 'datetime',
|
|
];
|
|
|
|
public function scopeCurrent($query)
|
|
{
|
|
return $query->where('is_current', true);
|
|
}
|
|
|
|
public function scopeManual($query)
|
|
{
|
|
return $query->where('source_type', 'manual');
|
|
}
|
|
|
|
public function observationPatients()
|
|
{
|
|
return $this->hasMany(ObservationPatient::class, 'rf_department_patient_id', 'department_patient_id');
|
|
}
|
|
|
|
public function operations()
|
|
{
|
|
return $this->hasMany(DepartmentPatientOperation::class, 'rf_department_patient_id', 'department_patient_id');
|
|
}
|
|
|
|
public function report()
|
|
{
|
|
return $this->belongsTo(Report::class, 'rf_report_id', 'report_id');
|
|
}
|
|
}
|