Align specialty queue board with hero waiting counts.
Deploy Ladill Care / deploy (push) Successful in 35s

Board lists used type-only departments while KPIs used provisioned department IDs, so Waiting could show N with an empty WAITING column.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-20 18:52:03 +00:00
co-authored by Cursor
parent 9443465c5c
commit 4dd683161a
3 changed files with 87 additions and 5 deletions
@@ -1458,8 +1458,6 @@ class SpecialtyModuleController extends Controller
->orderBy('name')
->get();
$departmentIds = $departments->pluck('id')->all();
$branchId = (int) ($branchScope ?: $departments->first()?->branch_id);
if ($practitionerScope !== null && $practitionerScope !== []) {
$pracBranch = (int) \App\Models\Practitioner::owned($owner)
@@ -1475,6 +1473,23 @@ class SpecialtyModuleController extends Controller
// while Call next is local.
$kpiBranch = $branchScope ?? ($branchId > 0 ? $branchId : null);
// Same department set as SpecialtyShellService::kpis() (provisioned IDs, not
// type-only). Otherwise hero "Waiting: N" can disagree with an empty board.
$departmentIds = $shell->departmentIds($organization, $module, $owner, $kpiBranch);
if ($departmentIds !== [] && $departments->isEmpty()) {
$departments = Department::owned($owner)
->whereIn('id', $departmentIds)
->where('is_active', true)
->with('branch')
->orderBy('name')
->get();
if (! $branchId && $departments->isNotEmpty()) {
$branchId = (int) $departments->first()->branch_id;
$kpiBranch = $branchScope ?? ($branchId > 0 ? $branchId : null);
$departmentIds = $shell->departmentIds($organization, $module, $owner, $kpiBranch);
}
}
$waiting = Appointment::owned($owner)
->where('organization_id', $organization->id)
->whereIn('status', [Appointment::STATUS_WAITING, Appointment::STATUS_CHECKED_IN])
@@ -1571,6 +1586,11 @@ class SpecialtyModuleController extends Controller
->limit(20)
->get();
// Keep hero tiles aligned with the board columns (same collections).
$kpis['waiting'] = $waiting->count();
$kpis['in_progress'] = $inConsultation->count();
$kpis['completed_today'] = $done->count();
$workspaceVisit = null;
$patientHeader = null;
$timeline = [];