Files
onboard/app/Models/MigrationPatientNurse.php
brusnitsyn 739168d427 Обновлен стартовый экран
Переписаны запросы для статистики, отчетов
Добавлена интеграция отчета сестры
2026-05-28 22:10:00 +09:00

49 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class MigrationPatientNurse extends Model
{
protected $fillable = [
'medical_history_id',
'ingoing_date',
'out_date',
'diagnosis_id',
'diagnosis_code',
'diagnosis_name',
'interrupted_event_id',
'stationar_branch_id',
'department_id',
'visit_result_id',
'stat_cure_result_id',
'user_id',
'mis_user_id',
'comment',
];
protected $casts = [
'ingoing_date' => 'datetime:Y-m-d H:i:s',
'out_date' => 'datetime:Y-m-d H:i:s',
];
// Фильтр по подразделению (получает ID отделений)
public function scopeDepartment($query, int $departmentId)
{
$branchIds = DB::table('stt_stationarbranch')
->where('rf_DepartmentID', $departmentId)
->pluck('StationarBranchID');
return $query->whereIn('stationar_branch_id', $branchIds);
}
public function scopeCurrentMigration($query, $historyId, $departmentId)
{
return $query->where('medical_history_id', $historyId)
->department($departmentId)
->orderBy('ingoing_date', 'desc');
}
}