Patients can be admitted, transferred, and discharged from unit/bed stays with occupancy sync, so MAR and ward boards have inpatient context. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,8 @@ namespace App\Models;
|
||||
use App\Models\Concerns\BelongsToOwner;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Bed extends Model
|
||||
@@ -41,4 +43,18 @@ class Bed extends Model
|
||||
{
|
||||
return $this->belongsTo(CareUnit::class, 'care_unit_id');
|
||||
}
|
||||
|
||||
public function stays(): HasMany
|
||||
{
|
||||
return $this->hasMany(BedStay::class, 'bed_id');
|
||||
}
|
||||
|
||||
public function activeStay(): HasOne
|
||||
{
|
||||
return $this->hasOne(BedStay::class, 'bed_id')
|
||||
->ofMany(
|
||||
['id' => 'max'],
|
||||
fn ($query) => $query->where('status', BedStay::STATUS_ACTIVE),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user