* восстановление окна наблюдения

* добавил получение выбывших
* фильтрация выбывших по результатам лечения
* добавил подсказку при наведении на операции
* добавил вывод причины наблюдения
* добавил вкладки для выбывших
* изменил связь и сохранение пациентов на контроле
* добавил возможность редактирования причины контроля
* полное изменение окна с нежелательными событиями
* исправил просмотр причины контроля
* работа над окном редактирования причины контроля в таблице
* визуальное выделение умерших и проведенных операций
* добавил выбор даты для роли врач
* центрирование блоков статистики
* разделение выполненных операций на срочность
* поправил метод определения текущего дня для роли врач
* функция блокировки при выборе другой даты для роли врач
This commit is contained in:
brusnitsyn
2026-01-29 16:42:42 +09:00
parent cb43c74a72
commit 87e21f0e08
24 changed files with 2065 additions and 501 deletions

View File

@@ -0,0 +1,21 @@
<?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');
}
}

View File

@@ -26,7 +26,7 @@ class MisMedicalHistory extends Model
public function observationPatient()
{
return $this->belongsTo(ObservationPatient::class, 'MedicalHistoryID', 'rf_medicalhistory_id');
return $this->hasMany(ObservationPatient::class, 'rf_medicalhistory_id', 'MedicalHistoryID');
}
public function surgicalOperations()
@@ -34,6 +34,12 @@ class MisMedicalHistory extends Model
return $this->hasMany(MisSurgicalOperation::class, 'rf_MedicalHistoryID', 'MedicalHistoryID');
}
public function scopeOperationOnBranch($query, $branchId, $startDate, $endDate)
{
return $this->surgicalOperations()->where('rf_StationarBranchID', $branchId)
->whereBetween('Date', [$startDate, $endDate]);
}
public function scopeCurrentlyHospitalized($query)
{
return $query->whereDate('DateExtract', '1900-01-01')
@@ -43,25 +49,25 @@ class MisMedicalHistory extends Model
/*
* Истории со срочностью - Плановая
*/
public function scopePlan()
public function scopePlan($query)
{
return $this->where('rf_EmerSignID', 1);
return $query->where('rf_EmerSignID', 1);
}
/*
* Истории со срочностью - Экстренная
*/
public function scopeEmergency()
public function scopeEmergency($query)
{
return $this->where('rf_EmerSignID', 2);
return $query->where('rf_EmerSignID', 2);
}
/*
* Истории с результатом - Умер
*/
public function scopeDeceased()
public function scopeDeceased($query)
{
return $this->where('rf_kl_VisitResultID', 5);
return $query->where('rf_kl_VisitResultID', 5);
}
/*

View File

@@ -25,7 +25,7 @@ class MisMigrationPatient extends Model
return $this->hasOne(MisMKB::class, 'MKBID', 'rf_MKBID');
}
public function scopeCurrentlyInTreatment($query, $branchId = null)
public function scopeCurrentlyInTreatment($query, $branchId = null, $startDate = null, $endDate = null)
{
$query->where('rf_kl_VisitResultID', 0)
->where('rf_MedicalHistoryID', '<>', 0);
@@ -34,6 +34,10 @@ class MisMigrationPatient extends Model
$query->where('rf_StationarBranchID', $branchId);
}
if ($startDate && $endDate) {
$query->whereBetween('DateIngoing', [$startDate, $endDate]);
}
return $query;
}
@@ -48,6 +52,95 @@ class MisMigrationPatient extends Model
return $query;
}
/**
* Выбывшие пациенты (все исходы)
*/
public function scopeOutcomePatients($query, $branchId = null, $startDate = null, $endDate = null)
{
$query->where('rf_kl_VisitResultID', '<>', 0) // не активное лечение
->whereDate('DateOut', '<>', '1900-01-01') // есть дата выбытия
->where('rf_MedicalHistoryID', '<>', 0);
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
if ($startDate && $endDate) {
$query->whereBetween('DateOut', [$startDate, $endDate]);
}
return $query;
}
/**
* Выписанные пациенты
*/
public function scopeDischarged($query, $branchId = null, $startDate = null, $endDate = null)
{
// ID выписки
$dischargeCodes = [1, 7, 8, 9, 10, 11, 48, 49, 124];
$query->whereIn('rf_kl_VisitResultID', $dischargeCodes)
->whereDate('DateOut', '<>', '1900-01-01')
->where('rf_MedicalHistoryID', '<>', 0);
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
if ($startDate && $endDate) {
$query->whereBetween('DateOut', [$startDate, $endDate]);
}
return $query;
}
/**
* Перевод в другое отделение
*/
public function scopeTransferred($query, $branchId = null, $startDate = null, $endDate = null)
{
// ID перевода
$transferCodes = [2, 3, 4, 12, 13, 14];
$query->whereIn('rf_kl_VisitResultID', $transferCodes)
->whereDate('DateOut', '<>', '1900-01-01')
->where('rf_MedicalHistoryID', '<>', 0);
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
if ($startDate && $endDate) {
$query->whereBetween('DateOut', [$startDate, $endDate]);
}
return $query;
}
/**
* Умершие пациенты
*/
public function scopeDeceasedOutcome($query, $branchId = null, $startDate = null, $endDate = null)
{
// ID умершего
$deceasedCodes = [5, 6, 15, 16];
$query->whereIn('rf_kl_VisitResultID', $deceasedCodes)
->whereDate('DateOut', '<>', '1900-01-01')
->where('rf_MedicalHistoryID', '<>', 0);
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
if ($startDate && $endDate) {
$query->whereBetween('DateOut', [$startDate, $endDate]);
}
return $query;
}
public function scopeExtractedToday($query, $branchId = null, $startDate = null, $endDate = null)
{
if (is_null($startDate)) $startDate = Carbon::now()->addDays(-1)->format('Y-m-d');

View File

@@ -25,4 +25,9 @@ class Report extends Model
{
return $this->hasMany(ObservationPatient::class, 'rf_report_id', 'report_id');
}
public function unwantedEvents()
{
return $this->hasMany(UnwantedEvent::class, 'rf_report_id', 'report_id');
}
}

View File

@@ -10,6 +10,13 @@ class UnwantedEvent extends Model
protected $fillable = [
'rf_report_id',
'comment'
'comment',
'title',
'is_visible',
];
public function report()
{
return $this->belongsTo(Report::class, 'rf_report_id');
}
}