Files
onboard/app/Models/MisBedAction.php
brusnitsyn 52a80ccd3b nothing
2026-02-20 17:28:16 +09:00

63 lines
1.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisBedAction extends Model
{
protected $table = 'stt_BedAction';
protected $primaryKey = 'BedActionID';
public $timestamps = false;
protected $fillable = [
'x_Edition',
'x_Status',
'Date',
'rf_ActionTypeID',
'Flag',
'rf_BedID',
'rf_MigrationPatientID',
'rf_LPUDoctorID',
'UGUID',
'rf_PatientID',
'rf_DocPRVDID',
'rf_MedStageID',
'rf_BedProfileID',
'SystemDate'
];
protected $casts = [
'Date' => 'datetime',
'SystemDate' => 'datetime',
'UGUID' => 'string',
'x_Status' => 'integer'
];
/**
* Типы действий с койками
*/
const ACTION_TYPE_OCCUPIED = 1; // Поступление
const ACTION_TYPE_FREE = 2; // Выписка
public function bed()
{
return $this->belongsTo(MisBed::class, 'rf_BedID', 'BedID');
}
/**
* Получить информацию о пребывании пациента на койке
*/
public static function getPatientStayPeriods($migrationPatientId)
{
$query = self::where('rf_MigrationPatientID', $migrationPatientId)
->whereIn('rf_ActionTypeID', [
self::ACTION_TYPE_OCCUPIED,
self::ACTION_TYPE_FREE
])
->orderBy('Date');
return $query->get();
}
}