Deploy Ladill Care / deploy (push) Successful in 38s
Schedule and start video visits via the Meet service API, persist join links on appointments, and propagate the shared copy-button component. Co-authored-by: Cursor <cursoragent@cursor.com>
116 lines
3.0 KiB
PHP
116 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\BelongsToOwner;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Appointment extends Model
|
|
{
|
|
use BelongsToOwner, SoftDeletes;
|
|
|
|
public const STATUS_SCHEDULED = 'scheduled';
|
|
|
|
public const STATUS_CHECKED_IN = 'checked_in';
|
|
|
|
public const STATUS_WAITING = 'waiting';
|
|
|
|
public const STATUS_IN_CONSULTATION = 'in_consultation';
|
|
|
|
public const STATUS_COMPLETED = 'completed';
|
|
|
|
public const STATUS_CANCELLED = 'cancelled';
|
|
|
|
public const STATUS_NO_SHOW = 'no_show';
|
|
|
|
public const TYPE_SCHEDULED = 'scheduled';
|
|
|
|
public const TYPE_WALK_IN = 'walk_in';
|
|
|
|
protected $table = 'care_appointments';
|
|
|
|
protected $fillable = [
|
|
'uuid', 'owner_ref', 'organization_id', 'branch_id', 'patient_id',
|
|
'practitioner_id', 'department_id', 'visit_id', 'type', 'status',
|
|
'scheduled_at', 'checked_in_at', 'waiting_at', 'started_at',
|
|
'completed_at', 'cancelled_at', 'queue_position', 'reason', 'notes',
|
|
'meet_room_uuid', 'meet_join_url', 'created_by',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'scheduled_at' => 'datetime',
|
|
'checked_in_at' => 'datetime',
|
|
'waiting_at' => 'datetime',
|
|
'started_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'cancelled_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (Appointment $appointment) {
|
|
if (! $appointment->uuid) {
|
|
$appointment->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'uuid';
|
|
}
|
|
|
|
public function patient(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Patient::class, 'patient_id');
|
|
}
|
|
|
|
public function practitioner(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Practitioner::class, 'practitioner_id');
|
|
}
|
|
|
|
public function branch(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Branch::class, 'branch_id');
|
|
}
|
|
|
|
public function department(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Department::class, 'department_id');
|
|
}
|
|
|
|
public function organization(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organization::class, 'organization_id');
|
|
}
|
|
|
|
public function visit(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Visit::class, 'visit_id');
|
|
}
|
|
|
|
public function consultation(): HasOne
|
|
{
|
|
return $this->hasOne(Consultation::class, 'appointment_id');
|
|
}
|
|
|
|
/** @return list<string> */
|
|
public static function activeStatuses(): array
|
|
{
|
|
return [
|
|
self::STATUS_SCHEDULED,
|
|
self::STATUS_CHECKED_IN,
|
|
self::STATUS_WAITING,
|
|
self::STATUS_IN_CONSULTATION,
|
|
];
|
|
}
|
|
}
|