Обновлен стартовый экран
Переписаны запросы для статистики, отчетов Добавлена интеграция отчета сестры
This commit is contained in:
@@ -4,11 +4,13 @@ namespace App\Models;
|
||||
|
||||
use App\Services\DateRange;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReportDutyMigrationPatient extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'original_id',
|
||||
'medical_history_id',
|
||||
'ingoing_date',
|
||||
'out_date',
|
||||
@@ -32,12 +34,18 @@ class ReportDutyMigrationPatient extends Model
|
||||
|
||||
public function medicalHistory()
|
||||
{
|
||||
return $this->belongsTo(ReportNursePatient::class, 'medical_history_id', 'id');
|
||||
return $this->belongsTo(ReportDutyPatient::class, 'medical_history_id', 'id');
|
||||
}
|
||||
|
||||
public function operations()
|
||||
{
|
||||
return $this->hasMany(SurgicalOperation::class, 'migration_patient_id', 'id');
|
||||
return $this->hasMany(SurgicalOperation::class, 'migration_patient_id', 'original_id');
|
||||
}
|
||||
|
||||
public function reanimations()
|
||||
{
|
||||
return $this->hasMany(Reanimation::class, 'migration_patient_id', 'original_id')
|
||||
->orderBy('out_date', 'desc');
|
||||
}
|
||||
|
||||
// Пересечение с отчетным периодом
|
||||
@@ -105,4 +113,23 @@ class ReportDutyMigrationPatient extends Model
|
||||
->orderBy('ingoing_date', 'desc')
|
||||
->limit(1)->first();
|
||||
}
|
||||
|
||||
public function getAdmittedInCurrentAttribute(DateRange $dateRange): bool
|
||||
{
|
||||
// Получаем дату поступления из последнего движения
|
||||
$ingoing = $this->ingoing_date;
|
||||
|
||||
if (!$ingoing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ingoingLocal = Carbon::parse($ingoing)->setTimezone(config('app.timezone', 'Europe/Moscow'));
|
||||
$now = $dateRange->endDate;//Carbon::now(config('app.timezone', 'Europe/Moscow'));
|
||||
|
||||
// Окно смены: вчера 09:00 → сегодня 09:00
|
||||
$shiftStart = $now->copy()->subDay()->setTime(9, 0);
|
||||
$shiftEnd = $now->copy()->setTime(9, 0);
|
||||
|
||||
return $ingoingLocal->between($shiftStart, $shiftEnd);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user