* изменил таблицы в основном отчете
* изменил метод сохранения пациентов основного отчета
This commit is contained in:
61
app/Models/ReportDutyPatient.php
Normal file
61
app/Models/ReportDutyPatient.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ReportDutyPatient extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'report_duty_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(ReportDutyMigrationPatient::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(ReportDutyMigrationPatient::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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user