Files
onboard/app/Models/ReportNursePatient.php
brusnitsyn 2026a1ca9f * добавил удаление карты, если она была добавлена не из МИС
* добавил диалог при удалении карты
* добавил сохранение движения
* добавил вывод сохраненного отчета
* изменил логику сохранения отчета
2026-05-06 17:03:41 +09:00

62 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ReportNursePatient extends Model
{
protected $fillable = [
'report_nurse_id',
'source_type',
'original_id',
'medical_card_number',
'full_name',
'birth_date',
'recipient_date',
'extract_date',
'death_date',
'male',
'urgency_id',
'hospital_result_id',
'visit_result_id',
'comment',
'user_id'
];
protected $casts = [
'birth_date' => 'date:Y-m-d',
'recipient_date' => 'datetime:Y-m-d H:i:s',
'extract_date' => 'datetime:Y-m-d H:i:s',
'death_date' => 'datetime:Y-m-d H:i:s',
'male' => 'boolean',
];
public function migrations(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(ReportNurseMigrationPatient::class, 'medical_history_id', 'id');
}
public function operations(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(SurgicalOperation::class, 'medical_history_id', 'id');
}
public function latestMigration()
{
return $this->hasOne(ReportNurseMigrationPatient::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);
}
}