Deploy Ladill Care / deploy (push) Failing after 1m9s
Enforce service-queue gates, cashier settlements, and clinical stage progression so patient journeys cannot bypass configured payment or authorization rules. Co-authored-by: Cursor <cursoragent@cursor.com>
102 lines
2.4 KiB
PHP
102 lines
2.4 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\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
class Visit extends Model
|
|
{
|
|
use BelongsToOwner, SoftDeletes;
|
|
|
|
public const STATUS_OPEN = 'open';
|
|
|
|
public const STATUS_IN_PROGRESS = 'in_progress';
|
|
|
|
public const STATUS_COMPLETED = 'completed';
|
|
|
|
protected $table = 'care_visits';
|
|
|
|
protected $fillable = [
|
|
'uuid', 'owner_ref', 'organization_id', 'branch_id', 'patient_id',
|
|
'status', 'checked_in_at', 'completed_at', 'checked_in_by',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'checked_in_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (Visit $visit) {
|
|
if (! $visit->uuid) {
|
|
$visit->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'uuid';
|
|
}
|
|
|
|
public function patient(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Patient::class, 'patient_id');
|
|
}
|
|
|
|
public function branch(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Branch::class, 'branch_id');
|
|
}
|
|
|
|
public function organization(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organization::class, 'organization_id');
|
|
}
|
|
|
|
public function appointment(): HasOne
|
|
{
|
|
return $this->hasOne(Appointment::class, 'visit_id');
|
|
}
|
|
|
|
public function consultations(): HasMany
|
|
{
|
|
return $this->hasMany(Consultation::class, 'visit_id');
|
|
}
|
|
|
|
public function assessments(): HasMany
|
|
{
|
|
return $this->hasMany(Assessment::class, 'visit_id');
|
|
}
|
|
|
|
public function bill(): HasOne
|
|
{
|
|
return $this->hasOne(Bill::class, 'visit_id');
|
|
}
|
|
|
|
public function bills(): HasMany
|
|
{
|
|
return $this->hasMany(Bill::class, 'visit_id');
|
|
}
|
|
|
|
public function stageAdvances(): HasMany
|
|
{
|
|
return $this->hasMany(VisitStageAdvance::class, 'visit_id');
|
|
}
|
|
|
|
public function financialObligations(): HasMany
|
|
{
|
|
return $this->hasMany(FinancialObligation::class, 'visit_id');
|
|
}
|
|
}
|