* поправил поле выбора даты * добавил индикатор в контроле * окно выбора пользователя для сводной * привязка окна для ввода причины контроля * добавил привязку историй пациентов для просмотра статистики по дням * поправил фиксацию фио ответственного, убрал при диапазоне * отключение ролей адм и зав от реплики
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class MedicalHistorySnapshot extends Model
|
|
{
|
|
protected $primaryKey = 'medical_history_snapshot_id';
|
|
|
|
protected $fillable = [
|
|
'rf_report_id',
|
|
'rf_medicalhistory_id',
|
|
'patient_type',
|
|
];
|
|
|
|
public function report()
|
|
{
|
|
return $this->belongsTo(Report::class, 'rf_report_id');
|
|
}
|
|
|
|
public function medicalHistory()
|
|
{
|
|
return $this->belongsTo(MisMedicalHistory::class, 'rf_medicalhistory_id', 'MedicalHistoryID');
|
|
}
|
|
|
|
// Скоупы для фильтрации
|
|
public function scopeForReport($query, $reportId)
|
|
{
|
|
return $query->where('rf_report_id', $reportId);
|
|
}
|
|
|
|
public function scopeByPatientType($query, $type)
|
|
{
|
|
return $query->where('patient_type', $type);
|
|
}
|
|
|
|
public function scopeByDepartment($query, $departmentId)
|
|
{
|
|
return $query->whereHas('medicalHistory.migrations.branch', function($q) use ($departmentId) {
|
|
$q->where('rf_DepartmentID', $departmentId);
|
|
});
|
|
}
|
|
}
|