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:
@@ -24,6 +24,7 @@ class Visit extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'uuid', 'owner_ref', 'organization_id', 'branch_id', 'patient_id',
|
||||
'care_unit_id', 'bed_id', 'placed_at', 'placed_by',
|
||||
'status', 'specialty_stage', 'checked_in_at', 'completed_at', 'checked_in_by',
|
||||
];
|
||||
|
||||
@@ -32,6 +33,7 @@ class Visit extends Model
|
||||
return [
|
||||
'checked_in_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
'placed_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,6 +66,30 @@ class Visit extends Model
|
||||
return $this->belongsTo(Organization::class, 'organization_id');
|
||||
}
|
||||
|
||||
public function careUnit(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(CareUnit::class, 'care_unit_id');
|
||||
}
|
||||
|
||||
public function bed(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Bed::class, 'bed_id');
|
||||
}
|
||||
|
||||
public function bedStays(): HasMany
|
||||
{
|
||||
return $this->hasMany(BedStay::class, 'visit_id');
|
||||
}
|
||||
|
||||
public function activeBedStay(): HasOne
|
||||
{
|
||||
return $this->hasOne(BedStay::class, 'visit_id')
|
||||
->ofMany(
|
||||
['id' => 'max'],
|
||||
fn ($query) => $query->where('status', BedStay::STATUS_ACTIVE),
|
||||
);
|
||||
}
|
||||
|
||||
public function appointment(): HasOne
|
||||
{
|
||||
return $this->hasOne(Appointment::class, 'visit_id');
|
||||
|
||||
Reference in New Issue
Block a user