fix(assessments): enable engine by default and wire into live UI
Deploy Ladill Care / deploy (push) Successful in 54s

The assessment engine was built but opt-in and hidden: flag defaulted
off, no sidebar entry, and no settings toggle. Default assessments_engine
on, auto-seed catalog when empty, add Settings toggle and Assessments
nav, and surface guidance from the patients list.
This commit is contained in:
isaacclad
2026-07-16 23:05:48 +00:00
parent 2ce4bc8993
commit f6780b9958
13 changed files with 120 additions and 4 deletions
@@ -250,6 +250,7 @@ class AssessmentController extends Controller
$this->features->enabled($this->organization($request), CareFeatures::ASSESSMENTS_ENGINE),
404,
);
$this->features->ensureAssessmentCatalog();
}
protected function authorizeCapture(Request $request): void
@@ -164,6 +164,7 @@ class PathwayController extends Controller
$this->features->enabled($this->organization($request), CareFeatures::ASSESSMENTS_ENGINE),
404,
);
$this->features->ensureAssessmentCatalog();
}
protected function authorizePatient(Request $request, Patient $patient): void
@@ -294,6 +294,7 @@ class AssessmentController extends Controller
$this->features->enabled($this->organization($request), CareFeatures::ASSESSMENTS_ENGINE),
404,
);
$this->features->ensureAssessmentCatalog();
}
protected function authorizeCapture(Request $request): void
@@ -47,7 +47,11 @@ class ConsultationController extends Controller
$canPrescribe = $permissions->can($member, 'prescriptions.manage');
$canGenerateBill = $permissions->can($member, 'bills.manage');
$assessmentsEnabled = app(CareFeatures::class)->enabled($organization, CareFeatures::ASSESSMENTS_ENGINE);
$careFeatures = app(CareFeatures::class);
$assessmentsEnabled = $careFeatures->enabled($organization, CareFeatures::ASSESSMENTS_ENGINE);
if ($assessmentsEnabled) {
$careFeatures->ensureAssessmentCatalog();
}
$canViewAssessments = $assessmentsEnabled && $permissions->can($member, 'assessments.view');
$canCaptureAssessment = $assessmentsEnabled && (
$permissions->can($member, 'assessments.capture')
@@ -94,6 +94,7 @@ class OutcomeController extends Controller
$this->features->enabled($this->organization($request), CareFeatures::ASSESSMENTS_ENGINE),
404,
);
$this->features->ensureAssessmentCatalog();
}
protected function authorizePatient(Request $request, Patient $patient): void
@@ -149,6 +149,7 @@ class PathwayController extends Controller
$this->features->enabled($org, CareFeatures::ASSESSMENTS_ENGINE),
404,
);
$this->features->ensureAssessmentCatalog();
}
protected function authorizePatient(Request $request, Patient $patient): void
@@ -102,7 +102,11 @@ class PatientController extends Controller
$suiteEmailReady = app(\App\Services\Billing\PlatformEmailClient::class)->isConfigured();
$suiteSmsReady = app(\App\Services\Billing\PlatformSmsClient::class)->isConfigured();
$assessmentsEnabled = app(CareFeatures::class)->enabled($organization, CareFeatures::ASSESSMENTS_ENGINE);
$careFeatures = app(CareFeatures::class);
$assessmentsEnabled = $careFeatures->enabled($organization, CareFeatures::ASSESSMENTS_ENGINE);
if ($assessmentsEnabled) {
$careFeatures->ensureAssessmentCatalog();
}
$canViewAssessments = $assessmentsEnabled && $permissions->can($member, 'assessments.view');
$canCaptureAssessment = $assessmentsEnabled && (
$permissions->can($member, 'assessments.capture')
@@ -7,6 +7,7 @@ use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Models\Branch;
use App\Services\Care\AppointmentPatientNotifier;
use App\Services\Care\AuditLogger;
use App\Services\Care\CareFeatures;
use App\Services\Care\CarePermissions;
use App\Services\Care\PlanService;
use App\Services\Billing\PlatformEmailClient;
@@ -45,6 +46,8 @@ class SettingsController extends Controller
$suiteEmailReady = $platformEmail->isConfigured();
$suiteSmsReady = $platformSms->isConfigured();
$careFeatures = app(CareFeatures::class);
return view('care.settings.edit', [
'organization' => $organization,
'canManage' => $canManage,
@@ -53,6 +56,7 @@ class SettingsController extends Controller
'canViewTeam' => $permissions->can($member, 'admin.members.view'),
'hasBranchesFeature' => $plans->hasFeature($organization, 'branches'),
'canUseQueueIntegration' => $plans->canUseQueueIntegration($organization),
'assessmentsEngineEnabled' => $careFeatures->enabled($organization, CareFeatures::ASSESSMENTS_ENGINE),
'messagingSmsReady' => $suiteSmsReady || $credential->hasValidSms(),
'messagingEmailReady' => $suiteEmailReady || $credential->hasValidBird(),
'suiteMessagingReady' => $suiteEmailReady || $suiteSmsReady,
@@ -82,6 +86,7 @@ class SettingsController extends Controller
'logo' => ['nullable', 'image', 'mimes:jpeg,png,jpg,webp,svg', 'max:2048'],
'remove_logo' => ['nullable', 'boolean'],
'queue_integration_enabled' => ['nullable', 'boolean'],
'assessments_engine' => ['nullable', 'boolean'],
'notify_appointment_booked_sms' => ['nullable', 'boolean'],
'notify_appointment_booked_email' => ['nullable', 'boolean'],
'notify_video_scheduled_sms' => ['nullable', 'boolean'],
@@ -92,6 +97,14 @@ class SettingsController extends Controller
$settings['onboarded'] = true;
$settings['facility_type'] = $validated['facility_type'];
$rollout = is_array($settings['rollout'] ?? null) ? $settings['rollout'] : [];
// Explicit save so opt-out is stored (engine defaults ON when unset).
$rollout[CareFeatures::ASSESSMENTS_ENGINE] = $request->boolean('assessments_engine');
$settings['rollout'] = $rollout;
if ($rollout[CareFeatures::ASSESSMENTS_ENGINE]) {
app(CareFeatures::class)->ensureAssessmentCatalog();
}
// Queue integration is Pro/Enterprise only — free plans cannot enable it.
$wantsQueue = $request->boolean('queue_integration_enabled');
if ($wantsQueue && ! $plans->canUseQueueIntegration($organization)) {