* добавил удаление карты, если она была добавлена не из МИС
* добавил диалог при удалении карты * добавил сохранение движения * добавил вывод сохраненного отчета * изменил логику сохранения отчета
This commit is contained in:
@@ -45,24 +45,6 @@ class UnifiedMigrationPatient extends Model
|
||||
return $query->whereIn('stationar_branch_id', $branchIds);
|
||||
}
|
||||
|
||||
// Добавляет вычисляемый столбец `category` (только для отображения)
|
||||
public function scopeWithCategory($query, string $from, string $to)
|
||||
{
|
||||
$sql = "CASE
|
||||
WHEN ingoing_date BETWEEN ? AND ? THEN 'admitted'
|
||||
WHEN out_date BETWEEN ? AND ? THEN
|
||||
CASE
|
||||
WHEN death_date IS NOT NULL AND death_date BETWEEN ? AND ? THEN 'deceased'
|
||||
WHEN stat_cure_result_id IN (3,4,7) THEN 'transferred'
|
||||
ELSE 'discharged'
|
||||
END
|
||||
WHEN ingoing_date < ? AND (out_date IS NULL OR out_date > ?) THEN 'current'
|
||||
ELSE 'historical'
|
||||
END as category";
|
||||
|
||||
return $query->selectRaw($sql, [$from, $to, $from, $to, $from, $to, $to, $to]);
|
||||
}
|
||||
|
||||
// Быстрые фильтры по статусам (используют индексы MV, а не computed column)
|
||||
public function scopeAdmitted($query, string $from, string $to)
|
||||
{
|
||||
@@ -96,14 +78,14 @@ class UnifiedMigrationPatient extends Model
|
||||
{
|
||||
return $query->whereNull('out_date')
|
||||
->whereNotNull('medical_history_id')
|
||||
->whereHas('medicalHistory', function ($q) use ($dateRange) {
|
||||
$q->whereNull('extract_date');
|
||||
});
|
||||
->where('ingoing_date', '<', $dateRange->startSql())
|
||||
->whereNull('patient_extract_date');
|
||||
}
|
||||
|
||||
public function scopeCurrentMigration($query, $historyId)
|
||||
public function scopeCurrentMigration($query, $historyId, $departmentId)
|
||||
{
|
||||
return $query->where('medical_history_id', $historyId)
|
||||
->department($departmentId)
|
||||
->orderBy('ingoing_date', 'desc')
|
||||
->limit(1)->first();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user