Deploy Ladill Care / deploy (push) Failing after 45s
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>
70 lines
1.6 KiB
PHP
70 lines
1.6 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\SoftDeletes;
|
|
use Illuminate\Support\Str;
|
|
|
|
class FacilityWorkflow extends Model
|
|
{
|
|
use BelongsToOwner, SoftDeletes;
|
|
|
|
protected $table = 'care_facility_workflows';
|
|
|
|
protected $fillable = [
|
|
'uuid', 'owner_ref', 'organization_id', 'branch_id', 'name',
|
|
'template_key', 'category', 'is_active', 'settings',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_active' => 'boolean',
|
|
'settings' => 'array',
|
|
];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::creating(function (FacilityWorkflow $workflow) {
|
|
if (! $workflow->uuid) {
|
|
$workflow->uuid = (string) Str::uuid();
|
|
}
|
|
});
|
|
}
|
|
|
|
public function getRouteKeyName(): string
|
|
{
|
|
return 'uuid';
|
|
}
|
|
|
|
public function organization(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Organization::class, 'organization_id');
|
|
}
|
|
|
|
public function branch(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Branch::class, 'branch_id');
|
|
}
|
|
|
|
public function stages(): HasMany
|
|
{
|
|
return $this->hasMany(WorkflowStage::class, 'workflow_id')->orderBy('sort_order');
|
|
}
|
|
|
|
public function firstStage(): ?WorkflowStage
|
|
{
|
|
return $this->stages()->first();
|
|
}
|
|
|
|
public function stage(string $code): ?WorkflowStage
|
|
{
|
|
return $this->stages()->where('code', $code)->first();
|
|
}
|
|
}
|