Fix patient show 500 when assessment catalog reseed hits live answers.
Deploy Ladill Care / deploy (push) Successful in 1m8s
Deploy Ladill Care / deploy (push) Successful in 1m8s
ensureAssessmentCatalog was re-running AssessmentTemplateSeeder whenever nursing packs were missing; the seeder hard-deleted questions and blew up on FK care_assessment_answers. Upsert questions by code, only drop unused orphans, and never let catalog ensure throw on web requests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,7 +8,9 @@ use App\Models\Organization;
|
||||
use Database\Seeders\AssessmentTemplateSeeder;
|
||||
use Database\Seeders\ClinicalPathwaySeeder;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Product rollout flags stored under organization settings.rollout.*
|
||||
@@ -66,8 +68,21 @@ class CareFeatures
|
||||
/**
|
||||
* Ensure platform assessment/pathway catalog exists (idempotent seed).
|
||||
* Call when the engine is enabled so consult/patient UI has templates.
|
||||
* Never throws — web requests must not 500 if catalog seed races with live answers.
|
||||
*/
|
||||
public function ensureAssessmentCatalog(): void
|
||||
{
|
||||
try {
|
||||
$this->seedAssessmentCatalogIfNeeded();
|
||||
} catch (Throwable $e) {
|
||||
Log::warning('ensureAssessmentCatalog failed', [
|
||||
'message' => $e->getMessage(),
|
||||
'exception' => $e::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function seedAssessmentCatalogIfNeeded(): void
|
||||
{
|
||||
if (! Schema::hasTable('care_assessment_templates')) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user