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
+46 -1
View File
@@ -2,7 +2,12 @@
namespace App\Services\Care;
use App\Models\AssessmentTemplate;
use App\Models\Organization;
use Database\Seeders\AssessmentTemplateSeeder;
use Database\Seeders\ClinicalPathwaySeeder;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Schema;
/**
* Product rollout flags stored under organization settings.rollout.*
@@ -16,12 +21,25 @@ class CareFeatures
public const ASSESSMENT_REQUIRED_ON_COMPLETE = 'assessment_required_on_complete';
/**
* Flags that default ON when unset (opt-out). Others default OFF (opt-in).
*
* @var list<string>
*/
protected array $defaultOn = [
self::ASSESSMENTS_ENGINE,
];
public function enabled(Organization $organization, string $flag): bool
{
$settings = $organization->settings ?? [];
$rollout = is_array($settings['rollout'] ?? null) ? $settings['rollout'] : [];
return (bool) ($rollout[$flag] ?? false);
if (array_key_exists($flag, $rollout)) {
return (bool) $rollout[$flag];
}
return in_array($flag, $this->defaultOn, true);
}
/**
@@ -37,4 +55,31 @@ class CareFeatures
return $organization->fresh();
}
/**
* Ensure platform assessment/pathway catalog exists (idempotent seed).
* Call when the engine is enabled so consult/patient UI has templates.
*/
public function ensureAssessmentCatalog(): void
{
if (! Schema::hasTable('care_assessment_templates')) {
return;
}
if (AssessmentTemplate::query()->whereNull('organization_id')->exists()) {
return;
}
Artisan::call('db:seed', [
'--class' => AssessmentTemplateSeeder::class,
'--force' => true,
]);
if (Schema::hasTable('care_clinical_pathways')) {
Artisan::call('db:seed', [
'--class' => ClinicalPathwaySeeder::class,
'--force' => true,
]);
}
}
}