Add full Blood Bank specialty suite on shared shell.
Deploy Ladill Care / deploy (push) Successful in 37s

Mirror Emergency: stage workflow, issue/transfusion records, analytics,
print, and action-menu stage flow without a parallel EHR.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 21:36:57 +00:00
co-authored by Cursor
parent 847d63c1c2
commit f688a48c37
19 changed files with 1590 additions and 30 deletions
@@ -169,6 +169,7 @@ class SpecialtyModuleController extends Controller
$preferredTab = match ($module) {
'dentistry' => 'odontogram',
'emergency' => 'triage',
'blood_bank' => 'requests',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -226,7 +227,7 @@ class SpecialtyModuleController extends Controller
} catch (\InvalidArgumentException) {
// Stage map may be empty for some modules.
}
} elseif ($nextStage && in_array($visit->specialty_stage, ['waiting', 'arrival'], true)) {
} elseif ($nextStage && in_array($visit->specialty_stage, ['waiting', 'arrival', 'request'], true)) {
try {
$stageService->setStage($organization, $visit, $module, $nextStage, $owner, $owner);
$visit = $visit->fresh();
@@ -239,6 +240,7 @@ class SpecialtyModuleController extends Controller
$preferredTab = match ($module) {
'dentistry' => 'odontogram',
'emergency' => 'triage',
'blood_bank' => 'requests',
default => (collect(array_keys($shellTabs))
->first(fn (string $tab) => $clinical->recordTypeForTab($module, $tab) !== null)
?? 'clinical_notes'),
@@ -335,6 +337,42 @@ class SpecialtyModuleController extends Controller
}
}
if ($module === 'blood_bank' && $recordType === 'blood_request') {
$workflow = app(\App\Services\Care\BloodBank\BloodBankWorkflowService::class);
$stageService = app(\App\Services\Care\SpecialtyVisitStageService::class);
$suggested = $workflow->stageFromRequest($record->payload ?? []);
$current = $visit->specialty_stage;
if (! $current || in_array($current, ['request', 'waiting'], true)) {
try {
$stageService->setStage(
$organization,
$visit,
'blood_bank',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
} elseif ($suggested !== $current && in_array($suggested, ['crossmatch', 'issue'], true)) {
// Advance when cross-match / issue status progresses on an existing request.
$order = ['request' => 0, 'crossmatch' => 1, 'issue' => 2, 'transfusion' => 3, 'completed' => 4];
if (($order[$suggested] ?? 0) > ($order[$current] ?? 0)) {
try {
$stageService->setStage(
$organization,
$visit,
'blood_bank',
$suggested,
$this->ownerRef($request),
$this->ownerRef($request),
);
} catch (\InvalidArgumentException) {
}
}
}
}
return redirect()
->route('care.specialty.workspace', [
'module' => $module,
@@ -726,6 +764,12 @@ class SpecialtyModuleController extends Controller
$emergencyLatestVitals = null;
$emergencyStageCodes = [];
$emergencyStageFlow = [];
$bloodBankRequest = null;
$bloodBankInventory = null;
$bloodBankIssue = null;
$bloodBankTransfusion = null;
$bloodBankStageCodes = [];
$bloodBankStageFlow = [];
$activeTab = (string) $request->query('tab', array_key_first($shell->workspaceTabs($module)) ?: 'overview');
$clinical = app(SpecialtyClinicalRecordService::class);
@@ -842,6 +886,15 @@ class SpecialtyModuleController extends Controller
$emergencyStageFlow = app(\App\Services\Care\Emergency\EmergencyWorkflowService::class)->stageFlow();
}
if ($module === 'blood_bank') {
$bloodBankRequest = $clinical->findForVisit($workspaceVisit, 'blood_bank', 'blood_request');
$bloodBankInventory = $clinical->findForVisit($workspaceVisit, 'blood_bank', 'inventory_note');
$bloodBankIssue = $clinical->findForVisit($workspaceVisit, 'blood_bank', 'issue_note');
$bloodBankTransfusion = $clinical->findForVisit($workspaceVisit, 'blood_bank', 'transfusion_note');
$bloodBankStageCodes = collect($shell->stages('blood_bank'))->pluck('code')->all();
$bloodBankStageFlow = app(\App\Services\Care\BloodBank\BloodBankWorkflowService::class)->stageFlow();
}
if ($patientHeader !== null) {
$patientHeader['clinical_alerts'] = $clinicalAlerts;
}
@@ -921,6 +974,12 @@ class SpecialtyModuleController extends Controller
'emergencyLatestVitals' => $emergencyLatestVitals,
'emergencyStageCodes' => $emergencyStageCodes,
'emergencyStageFlow' => $emergencyStageFlow,
'bloodBankRequest' => $bloodBankRequest,
'bloodBankInventory' => $bloodBankInventory,
'bloodBankIssue' => $bloodBankIssue,
'bloodBankTransfusion' => $bloodBankTransfusion,
'bloodBankStageCodes' => $bloodBankStageCodes,
'bloodBankStageFlow' => $bloodBankStageFlow,
'queueStubs' => $modules->queueStubsFor($organization, $module),
'branchId' => $branchId,
'branchLabel' => $branchLabel,