Add full Radiology, Cardiology, and Psychiatry specialty clinical suites.
Deploy Ladill Care / deploy (push) Successful in 49s

Mirror the Ophthalmology/Maternity shell pattern with stages, stage_tabs,
workspace clinical records, reports/print, demo seeds, and suite tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-19 18:41:55 +00:00
co-authored by Cursor
parent b3805023b1
commit 8e23cdeae3
36 changed files with 3932 additions and 34 deletions
@@ -156,6 +156,9 @@ class SpecialtyModuleController extends Controller
'ophthalmology' => 'refraction',
'physiotherapy' => 'assessment',
'maternity' => 'history',
'radiology' => 'protocol',
'cardiology' => 'history',
'psychiatry' => 'history',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -230,6 +233,9 @@ class SpecialtyModuleController extends Controller
'ophthalmology' => 'refraction',
'physiotherapy' => 'assessment',
'maternity' => 'history',
'radiology' => 'protocol',
'cardiology' => 'history',
'psychiatry' => 'history',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -510,6 +516,146 @@ class SpecialtyModuleController extends Controller
}
}
if ($module === 'radiology' && in_array($recordType, ['imaging_request', 'imaging_acquisition', 'imaging_report'], true)) {
$workflow = app(\App\Services\Care\Radiology\RadiologyWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'imaging_request' => $workflow->stageFromRequest($record->payload ?? []),
'imaging_acquisition' => $workflow->stageFromAcquisition($record->payload ?? []),
'imaging_report' => $workflow->stageFromReport($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', 'request', null, ''];
$order = [
'check_in' => 0,
'protocol' => 1,
'acquisition' => 2,
'reporting' => 3,
'verified' => 4,
'completed' => 5,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage(
$organization,
$visit,
'radiology',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage(
$organization,
$visit,
'radiology',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'cardiology' && in_array($recordType, ['cardio_history', 'cardiac_exam', 'cardio_investigation', 'cardio_plan'], true)) {
$workflow = app(\App\Services\Care\Cardiology\CardiologyWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'cardio_history' => $workflow->stageFromHistory($record->payload ?? []),
'cardiac_exam' => $workflow->stageFromExam($record->payload ?? []),
'cardio_investigation' => $workflow->stageFromInvestigation($record->payload ?? []),
'cardio_plan' => $workflow->stageFromPlan($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'exam' => 2,
'investigation' => 3,
'plan' => 4,
'procedure' => 5,
'completed' => 6,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage(
$organization,
$visit,
'cardiology',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage(
$organization,
$visit,
'cardiology',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'psychiatry' && in_array($recordType, ['mental_status', 'risk_assessment', 'psych_plan'], true)) {
$workflow = app(\App\Services\Care\Psychiatry\PsychiatryWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'mental_status' => $workflow->stageFromHistory($record->payload ?? []),
'risk_assessment' => $workflow->stageFromRisk($record->payload ?? []),
'psych_plan' => $workflow->stageFromFormulation($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'risk' => 2,
'formulation' => 3,
'review' => 4,
'completed' => 5,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage(
$organization,
$visit,
'psychiatry',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage(
$organization,
$visit,
'psychiatry',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
}
}
return redirect()
->route('care.specialty.workspace', [
'module' => $module,
@@ -926,6 +1072,25 @@ class SpecialtyModuleController extends Controller
$maternityPostnatal = null;
$maternityStageCodes = [];
$maternityStageFlow = [];
$radiologyRequest = null;
$radiologyAcquisition = null;
$radiologyReport = null;
$radiologyVerification = null;
$radiologyStageCodes = [];
$radiologyStageFlow = [];
$cardiologyHistory = null;
$cardiologyExam = null;
$cardiologyInvestigation = null;
$cardiologyPlan = null;
$cardiologyProcedure = null;
$cardiologyStageCodes = [];
$cardiologyStageFlow = [];
$psychiatryHistory = null;
$psychiatryRisk = null;
$psychiatryPlan = null;
$psychiatryFollowup = null;
$psychiatryStageCodes = [];
$psychiatryStageFlow = [];
$activeTab = (string) $request->query('tab', array_key_first($shell->workspaceTabs($module)) ?: 'overview');
$clinical = app(SpecialtyClinicalRecordService::class);
@@ -1062,6 +1227,34 @@ class SpecialtyModuleController extends Controller
$maternityStageFlow = app(\App\Services\Care\Maternity\MaternityWorkflowService::class)->stageFlow();
}
if ($module === 'radiology') {
$radiologyRequest = $clinical->findForVisit($workspaceVisit, 'radiology', 'imaging_request');
$radiologyAcquisition = $clinical->findForVisit($workspaceVisit, 'radiology', 'imaging_acquisition');
$radiologyReport = $clinical->findForVisit($workspaceVisit, 'radiology', 'imaging_report');
$radiologyVerification = $clinical->findForVisit($workspaceVisit, 'radiology', 'imaging_verification');
$radiologyStageCodes = collect($shell->stages('radiology'))->pluck('code')->all();
$radiologyStageFlow = app(\App\Services\Care\Radiology\RadiologyWorkflowService::class)->stageFlow();
}
if ($module === 'cardiology') {
$cardiologyHistory = $clinical->findForVisit($workspaceVisit, 'cardiology', 'cardio_history');
$cardiologyExam = $clinical->findForVisit($workspaceVisit, 'cardiology', 'cardiac_exam');
$cardiologyInvestigation = $clinical->findForVisit($workspaceVisit, 'cardiology', 'cardio_investigation');
$cardiologyPlan = $clinical->findForVisit($workspaceVisit, 'cardiology', 'cardio_plan');
$cardiologyProcedure = $clinical->findForVisit($workspaceVisit, 'cardiology', 'cardio_procedure');
$cardiologyStageCodes = collect($shell->stages('cardiology'))->pluck('code')->all();
$cardiologyStageFlow = app(\App\Services\Care\Cardiology\CardiologyWorkflowService::class)->stageFlow();
}
if ($module === 'psychiatry') {
$psychiatryHistory = $clinical->findForVisit($workspaceVisit, 'psychiatry', 'mental_status');
$psychiatryRisk = $clinical->findForVisit($workspaceVisit, 'psychiatry', 'risk_assessment');
$psychiatryPlan = $clinical->findForVisit($workspaceVisit, 'psychiatry', 'psych_plan');
$psychiatryFollowup = $clinical->findForVisit($workspaceVisit, 'psychiatry', 'psych_followup');
$psychiatryStageCodes = collect($shell->stages('psychiatry'))->pluck('code')->all();
$psychiatryStageFlow = app(\App\Services\Care\Psychiatry\PsychiatryWorkflowService::class)->stageFlow();
}
if ($patientHeader !== null) {
$patientHeader['clinical_alerts'] = $clinicalAlerts;
}
@@ -1170,6 +1363,25 @@ class SpecialtyModuleController extends Controller
'maternityPostnatal' => $maternityPostnatal,
'maternityStageCodes' => $maternityStageCodes,
'maternityStageFlow' => $maternityStageFlow,
'radiologyRequest' => $radiologyRequest,
'radiologyAcquisition' => $radiologyAcquisition,
'radiologyReport' => $radiologyReport,
'radiologyVerification' => $radiologyVerification,
'radiologyStageCodes' => $radiologyStageCodes,
'radiologyStageFlow' => $radiologyStageFlow,
'cardiologyHistory' => $cardiologyHistory,
'cardiologyExam' => $cardiologyExam,
'cardiologyInvestigation' => $cardiologyInvestigation,
'cardiologyPlan' => $cardiologyPlan,
'cardiologyProcedure' => $cardiologyProcedure,
'cardiologyStageCodes' => $cardiologyStageCodes,
'cardiologyStageFlow' => $cardiologyStageFlow,
'psychiatryHistory' => $psychiatryHistory,
'psychiatryRisk' => $psychiatryRisk,
'psychiatryPlan' => $psychiatryPlan,
'psychiatryFollowup' => $psychiatryFollowup,
'psychiatryStageCodes' => $psychiatryStageCodes,
'psychiatryStageFlow' => $psychiatryStageFlow,
'queueStubs' => $modules->queueStubsFor($organization, $module),
'branchId' => $branchId,
'branchLabel' => $branchLabel,