* добавил диалог при удалении карты * добавил сохранение движения * добавил вывод сохраненного отчета * изменил логику сохранения отчета
50 lines
1.3 KiB
PHP
50 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')
|
|
->limit(1)->first();
|
|
}
|
|
}
|