Add workflow-centric patient journey with financial gates.
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>
This commit is contained in:
isaacclad
2026-07-17 20:47:33 +00:00
co-authored by Cursor
parent c319692b33
commit 86bfce1e17
16 changed files with 1564 additions and 27 deletions
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Care;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\Workflow\WorkflowTemplateRegistry;
use App\Support\OrganizationBranding;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
@@ -16,6 +17,7 @@ class OnboardingController extends Controller
public function __construct(
protected OrganizationResolver $organizations,
protected WorkflowTemplateRegistry $workflows,
) {}
public function show(Request $request): View|RedirectResponse
@@ -27,12 +29,9 @@ class OnboardingController extends Controller
return view('care.onboarding.show', [
'user' => $request->user(),
'timezones' => timezone_identifiers_list(),
'facilityTypes' => [
'clinic' => 'Clinic',
'hospital' => 'Hospital',
'diagnostic' => 'Diagnostic laboratory',
'specialist' => 'Specialist practice',
],
'categories' => $this->workflows->categories(),
'templates' => $this->workflows->templates(),
'defaultTemplate' => $this->workflows->defaultTemplateKey(),
]);
}
@@ -42,9 +41,13 @@ class OnboardingController extends Controller
return redirect()->route('care.dashboard');
}
$categoryKeys = array_keys($this->workflows->categories());
$templateKeys = array_keys($this->workflows->templates());
$validated = $request->validate([
'organization_name' => ['required', 'string', 'max:255'],
'facility_type' => ['required', 'string', 'in:clinic,hospital,diagnostic,specialist'],
'facility_category' => ['required', 'string', 'in:'.implode(',', $categoryKeys)],
'workflow_template' => ['required', 'string', 'in:'.implode(',', $templateKeys)],
'branch_name' => ['required', 'string', 'max:255'],
'branch_address' => ['nullable', 'string', 'max:500'],
'branch_phone' => ['nullable', 'string', 'max:50'],