Ship full Emergency specialty suite on the shared shell.
Deploy Ladill Care / deploy (push) Successful in 34s

Add ED visit stages, triage-driven routing, vitals, observation, disposition, reports, and print summary so Emergency matches Dentistry’s operational depth without a parallel EHR.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 17:48:57 +00:00
co-authored by Cursor
parent 18c24077e3
commit 7989ab9184
19 changed files with 1413 additions and 22 deletions
@@ -156,11 +156,13 @@ class SpecialtyModuleController extends Controller
if ($openConsultation && $openConsultation->status !== \App\Models\Consultation::STATUS_COMPLETED) {
$clinical = app(SpecialtyClinicalRecordService::class);
$shellTabs = app(SpecialtyShellService::class)->workspaceTabs($module);
$preferredTab = $module === 'dentistry'
? 'odontogram'
: (collect(array_keys($shellTabs))
$preferredTab = match ($module) {
'dentistry' => 'odontogram',
'emergency' => 'triage',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes');
?? 'clinical_notes'),
};
return redirect()
->route('care.specialty.workspace', [
@@ -214,7 +216,7 @@ class SpecialtyModuleController extends Controller
} catch (\InvalidArgumentException) {
// Stage map may be empty for some modules.
}
} elseif ($nextStage && $visit->specialty_stage === 'waiting') {
} elseif ($nextStage && in_array($visit->specialty_stage, ['waiting', 'arrival'], true)) {
try {
$stageService->setStage($organization, $visit, $module, $nextStage, $owner, $owner);
$visit = $visit->fresh();
@@ -224,11 +226,13 @@ class SpecialtyModuleController extends Controller
}
$clinical = app(SpecialtyClinicalRecordService::class);
$shellTabs = app(SpecialtyShellService::class)->workspaceTabs($module);
$preferredTab = $module === 'dentistry'
? 'odontogram'
: (collect(array_keys($shellTabs))
$preferredTab = match ($module) {
'dentistry' => 'odontogram',
'emergency' => 'triage',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes');
?? 'clinical_notes'),
};
return redirect()
->route('care.specialty.workspace', [
@@ -285,6 +289,41 @@ class SpecialtyModuleController extends Controller
$validated['status'] ?? \App\Models\SpecialtyClinicalRecord::STATUS_ACTIVE,
);
if ($module === 'emergency' && $recordType === 'triage') {
$workflow = app(\App\Services\Care\Emergency\EmergencyWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = $workflow->stageFromTriage($record->payload ?? []);
$current = $visit->specialty_stage;
if (! $current || in_array($current, ['arrival', 'waiting'], true)) {
try {
$stageService->setStage(
$organization,
$visit,
'emergency',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
}
}
if ($module === 'emergency' && $recordType === 'observation') {
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
try {
$stageService->setStage(
$organization,
$visit,
'emergency',
\App\Services\Care\Emergency\EmergencyWorkflowService::STAGE_OBSERVATION,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
}
return redirect()
->route('care.specialty.workspace', [
'module' => $module,
@@ -555,6 +594,14 @@ class SpecialtyModuleController extends Controller
$dentalLabCaseStatuses = [];
$dentalRecalls = collect();
$dentalStageCodes = [];
$emergencyTriage = null;
$emergencyClinicalNote = null;
$emergencyObservation = null;
$emergencyDisposition = null;
$emergencyVitals = collect();
$emergencyLatestVitals = null;
$emergencyStageCodes = [];
$emergencyStageFlow = [];
$activeTab = (string) $request->query('tab', array_key_first($shell->workspaceTabs($module)) ?: 'overview');
$clinical = app(SpecialtyClinicalRecordService::class);
@@ -659,6 +706,18 @@ class SpecialtyModuleController extends Controller
);
}
if ($module === 'emergency') {
$emergencyTriage = $clinical->findForVisit($workspaceVisit, 'emergency', 'triage');
$emergencyClinicalNote = $clinical->findForVisit($workspaceVisit, 'emergency', 'clinical_note');
$emergencyObservation = $clinical->findForVisit($workspaceVisit, 'emergency', 'observation');
$emergencyDisposition = $clinical->findForVisit($workspaceVisit, 'emergency', 'disposition');
$vitalsService = app(\App\Services\Care\Emergency\EmergencyVitalsService::class);
$emergencyVitals = $vitalsService->forVisit($workspaceVisit);
$emergencyLatestVitals = $vitalsService->latestForVisit($workspaceVisit);
$emergencyStageCodes = collect($shell->stages('emergency'))->pluck('code')->all();
$emergencyStageFlow = app(\App\Services\Care\Emergency\EmergencyWorkflowService::class)->stageFlow();
}
if ($patientHeader !== null) {
$patientHeader['clinical_alerts'] = $clinicalAlerts;
}
@@ -729,6 +788,14 @@ class SpecialtyModuleController extends Controller
'dentalLabCaseStatuses' => $dentalLabCaseStatuses,
'dentalRecalls' => $dentalRecalls,
'dentalStageCodes' => $dentalStageCodes,
'emergencyTriage' => $emergencyTriage,
'emergencyClinicalNote' => $emergencyClinicalNote,
'emergencyObservation' => $emergencyObservation,
'emergencyDisposition' => $emergencyDisposition,
'emergencyVitals' => $emergencyVitals,
'emergencyLatestVitals' => $emergencyLatestVitals,
'emergencyStageCodes' => $emergencyStageCodes,
'emergencyStageFlow' => $emergencyStageFlow,
'queueStubs' => $modules->queueStubsFor($organization, $module),
'branchId' => $branchId,
'branchLabel' => $branchLabel,