Files
ladill-care/app/Models/VisitStageAdvance.php
isaaccladandCursor 86bfce1e17
Deploy Ladill Care / deploy (push) Failing after 45s
Add workflow-centric patient journey with financial gates.
Introduces a facility workflow engine as Care's primary configuration
object: onboarding now leads with a facility category (which modules to
enable) and a workflow template (how patients move + where money is
collected), including standard herbal hospital/clinic templates.

Templates materialize into care_facility_workflows/care_workflow_stages.
The engine tracks a visit's position via care_visit_stage_advances and,
with FinancialGateService, gates a stage's queue behind a cleared
FinancialObligation (paid/authorized/waived/deferred) for "before"
payment timing while leaving "after" (pay-at-exit) flows unblocked.
Gated behavior is opt-in behind the workflow_engine/financial_gates
rollout flags; legacy orgs keep current behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-17 20:47:33 +00:00

58 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use App\Models\Concerns\BelongsToOwner;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class VisitStageAdvance extends Model
{
use BelongsToOwner;
public const STATUS_ACTIVE = 'active';
public const STATUS_BLOCKED = 'blocked';
public const STATUS_COMPLETED = 'completed';
public const STATUS_SKIPPED = 'skipped';
protected $table = 'care_visit_stage_advances';
protected $fillable = [
'owner_ref', 'visit_id', 'workflow_id', 'workflow_stage_id', 'stage_code',
'status', 'blocked_reason', 'entered_at', 'cleared_at', 'completed_at', 'meta',
];
protected function casts(): array
{
return [
'entered_at' => 'datetime',
'cleared_at' => 'datetime',
'completed_at' => 'datetime',
'meta' => 'array',
];
}
public function visit(): BelongsTo
{
return $this->belongsTo(Visit::class, 'visit_id');
}
public function workflow(): BelongsTo
{
return $this->belongsTo(FacilityWorkflow::class, 'workflow_id');
}
public function stage(): BelongsTo
{
return $this->belongsTo(WorkflowStage::class, 'workflow_stage_id');
}
public function isBlocked(): bool
{
return $this->status === self::STATUS_BLOCKED;
}
}