Add full Oncology, Renal Care, and Surgery specialty clinical suites.
Deploy Ladill Care / deploy (push) Successful in 32s

Match Pediatrics/ENT depth with stages, workspace tabs, clinical records, reports/print, demo seed, and suite tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-19 20:16:18 +00:00
co-authored by Cursor
parent dc86b51ed5
commit b7e5a7d9ad
33 changed files with 3392 additions and 53 deletions
@@ -162,6 +162,9 @@ class SpecialtyModuleController extends Controller
'pediatrics' => 'history',
'orthopedics' => 'history',
'ent' => 'history',
'oncology' => 'history',
'renal' => 'history',
'surgery' => 'history',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -242,6 +245,9 @@ class SpecialtyModuleController extends Controller
'pediatrics' => 'history',
'orthopedics' => 'history',
'ent' => 'history',
'oncology' => 'history',
'renal' => 'history',
'surgery' => 'history',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -806,6 +812,109 @@ class SpecialtyModuleController extends Controller
}
}
if ($module === 'oncology' && in_array($recordType, ['onc_history', 'onc_staging', 'onc_investigation', 'onc_plan'], true)) {
$workflow = app(\App\Services\Care\Oncology\OncologyWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'onc_history' => $workflow->stageFromHistory($record->payload ?? []),
'onc_staging' => $workflow->stageFromStaging($record->payload ?? []),
'onc_investigation' => $workflow->stageFromInvestigation($record->payload ?? []),
'onc_plan' => $workflow->stageFromPlan($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'staging' => 2,
'investigation' => 3,
'plan' => 4,
'treatment' => 5,
'completed' => 6,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage($organization, $visit, 'oncology', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage($organization, $visit, 'oncology', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'renal' && in_array($recordType, ['renal_history', 'renal_exam', 'renal_session'], true)) {
$workflow = app(\App\Services\Care\Renal\RenalWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'renal_history' => $workflow->stageFromHistory($record->payload ?? []),
'renal_exam' => $workflow->stageFromExam($record->payload ?? []),
'renal_session' => $workflow->stageFromDialysis($record->payload ?? []),
default => null,
};
$current = $visit->specialty_stage;
$early = ['check_in', 'waiting', null, ''];
$order = [
'check_in' => 0,
'history' => 1,
'exam' => 2,
'dialysis' => 3,
'plan' => 4,
'completed' => 5,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage($organization, $visit, 'renal', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage($organization, $visit, 'renal', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'surgery' && in_array($recordType, ['surg_history', 'surg_exam', 'surg_investigation', 'surg_plan', 'surg_procedure'], true)) {
$workflow = app(\App\Services\Care\Surgery\SurgeryWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = match ($recordType) {
'surg_history' => $workflow->stageFromHistory($record->payload ?? []),
'surg_exam' => $workflow->stageFromExam($record->payload ?? []),
'surg_investigation' => $workflow->stageFromInvestigation($record->payload ?? []),
'surg_plan' => $workflow->stageFromPlan($record->payload ?? []),
'surg_procedure' => $workflow->stageFromProcedure($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,
'postop' => 6,
'completed' => 7,
];
if ($suggested && (! $current || in_array($current, $early, true))) {
try {
$stageService->setStage($organization, $visit, 'surgery', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
} elseif ($suggested && $suggested !== $current && ($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage($organization, $visit, 'surgery', $suggested, $this->ownerRef($request), $this->ownerRef($request));
} catch (\InvalidArgumentException) {
}
}
}
return redirect()
->route('care.specialty.workspace', [
'module' => $module,
@@ -1262,6 +1371,27 @@ class SpecialtyModuleController extends Controller
$entProcedure = null;
$entStageCodes = [];
$entStageFlow = [];
$oncologyHistory = null;
$oncologyStaging = null;
$oncologyInvestigation = null;
$oncologyPlan = null;
$oncologyTreatment = null;
$oncologyStageCodes = [];
$oncologyStageFlow = [];
$renalHistory = null;
$renalExam = null;
$renalDialysis = null;
$renalPlan = null;
$renalStageCodes = [];
$renalStageFlow = [];
$surgeryHistory = null;
$surgeryExam = null;
$surgeryInvestigation = null;
$surgeryPlan = null;
$surgeryProcedure = null;
$surgeryPostop = null;
$surgeryStageCodes = [];
$surgeryStageFlow = [];
$activeTab = (string) $request->query('tab', array_key_first($shell->workspaceTabs($module)) ?: 'overview');
$clinical = app(SpecialtyClinicalRecordService::class);
@@ -1456,6 +1586,36 @@ class SpecialtyModuleController extends Controller
$entStageFlow = app(\App\Services\Care\Ent\EntWorkflowService::class)->stageFlow();
}
if ($module === 'oncology') {
$oncologyHistory = $clinical->findForVisit($workspaceVisit, 'oncology', 'onc_history');
$oncologyStaging = $clinical->findForVisit($workspaceVisit, 'oncology', 'onc_staging');
$oncologyInvestigation = $clinical->findForVisit($workspaceVisit, 'oncology', 'onc_investigation');
$oncologyPlan = $clinical->findForVisit($workspaceVisit, 'oncology', 'onc_plan');
$oncologyTreatment = $clinical->findForVisit($workspaceVisit, 'oncology', 'onc_treatment');
$oncologyStageCodes = collect($shell->stages('oncology'))->pluck('code')->all();
$oncologyStageFlow = app(\App\Services\Care\Oncology\OncologyWorkflowService::class)->stageFlow();
}
if ($module === 'renal') {
$renalHistory = $clinical->findForVisit($workspaceVisit, 'renal', 'renal_history');
$renalExam = $clinical->findForVisit($workspaceVisit, 'renal', 'renal_exam');
$renalDialysis = $clinical->findForVisit($workspaceVisit, 'renal', 'renal_session');
$renalPlan = $clinical->findForVisit($workspaceVisit, 'renal', 'renal_plan');
$renalStageCodes = collect($shell->stages('renal'))->pluck('code')->all();
$renalStageFlow = app(\App\Services\Care\Renal\RenalWorkflowService::class)->stageFlow();
}
if ($module === 'surgery') {
$surgeryHistory = $clinical->findForVisit($workspaceVisit, 'surgery', 'surg_history');
$surgeryExam = $clinical->findForVisit($workspaceVisit, 'surgery', 'surg_exam');
$surgeryInvestigation = $clinical->findForVisit($workspaceVisit, 'surgery', 'surg_investigation');
$surgeryPlan = $clinical->findForVisit($workspaceVisit, 'surgery', 'surg_plan');
$surgeryProcedure = $clinical->findForVisit($workspaceVisit, 'surgery', 'surg_procedure');
$surgeryPostop = $clinical->findForVisit($workspaceVisit, 'surgery', 'surg_postop');
$surgeryStageCodes = collect($shell->stages('surgery'))->pluck('code')->all();
$surgeryStageFlow = app(\App\Services\Care\Surgery\SurgeryWorkflowService::class)->stageFlow();
}
if ($patientHeader !== null) {
$patientHeader['clinical_alerts'] = $clinicalAlerts;
}
@@ -1604,6 +1764,27 @@ class SpecialtyModuleController extends Controller
'entProcedure' => $entProcedure,
'entStageCodes' => $entStageCodes,
'entStageFlow' => $entStageFlow,
'oncologyHistory' => $oncologyHistory,
'oncologyStaging' => $oncologyStaging,
'oncologyInvestigation' => $oncologyInvestigation,
'oncologyPlan' => $oncologyPlan,
'oncologyTreatment' => $oncologyTreatment,
'oncologyStageCodes' => $oncologyStageCodes,
'oncologyStageFlow' => $oncologyStageFlow,
'renalHistory' => $renalHistory,
'renalExam' => $renalExam,
'renalDialysis' => $renalDialysis,
'renalPlan' => $renalPlan,
'renalStageCodes' => $renalStageCodes,
'renalStageFlow' => $renalStageFlow,
'surgeryHistory' => $surgeryHistory,
'surgeryExam' => $surgeryExam,
'surgeryInvestigation' => $surgeryInvestigation,
'surgeryPlan' => $surgeryPlan,
'surgeryProcedure' => $surgeryProcedure,
'surgeryPostop' => $surgeryPostop,
'surgeryStageCodes' => $surgeryStageCodes,
'surgeryStageFlow' => $surgeryStageFlow,
'queueStubs' => $modules->queueStubsFor($organization, $module),
'branchId' => $branchId,
'branchLabel' => $branchLabel,