diff --git a/app/Http/Controllers/Care/QueueController.php b/app/Http/Controllers/Care/QueueController.php
index 5644be5..2c8ecd7 100644
--- a/app/Http/Controllers/Care/QueueController.php
+++ b/app/Http/Controllers/Care/QueueController.php
@@ -46,6 +46,19 @@ class QueueController extends Controller
: ($request->input('practitioner_id') ? (int) $request->input('practitioner_id') : null);
$queueIntegration = ['enabled' => false];
+ $queueContext = CareQueueContexts::CONSULTATION;
+ $specialtyLabel = null;
+ if ($lockToPractitioner && $practitionerId) {
+ $prac = Practitioner::owned($owner)->with('organization')->find($practitionerId);
+ $deskContext = $this->queueBridge->contextForPractitioner($organization, $prac);
+ if ($deskContext !== CareQueueContexts::CONSULTATION) {
+ $queueContext = $deskContext;
+ $specialtyLabel = (string) (config("care.specialty_modules.{$deskContext}.label")
+ ?? config("care.specialty_modules.{$deskContext}.nav_label")
+ ?? ucfirst(str_replace('_', ' ', $deskContext)));
+ }
+ }
+
if ($this->queueBridge->isEnabled($organization)) {
$syncBranches = $lockToPractitioner
? Practitioner::owned($owner)
@@ -63,11 +76,11 @@ class QueueController extends Controller
}
if ($branchId > 0) {
- $queueIntegration = $this->queueBridge->listMeta($organization, CareQueueContexts::CONSULTATION, $branchId);
+ $queueIntegration = $this->queueBridge->listMeta($organization, $queueContext, $branchId);
} elseif ($syncBranches !== []) {
$queueIntegration = $this->queueBridge->listMeta(
$organization,
- CareQueueContexts::CONSULTATION,
+ $queueContext,
(int) $syncBranches[0],
);
}
@@ -83,7 +96,7 @@ class QueueController extends Controller
->where('organization_id', $organization->id)
->where('status', Appointment::STATUS_IN_CONSULTATION)
->whereIn('practitioner_id', $practitionerScope ?: [0])
- ->with(['patient', 'practitioner', 'consultation'])
+ ->with(['patient', 'practitioner', 'consultation', 'visit', 'organization'])
->orderBy('started_at')
->get();
} else {
@@ -95,7 +108,7 @@ class QueueController extends Controller
->where('status', Appointment::STATUS_IN_CONSULTATION)
->when($branchId, fn ($q) => $q->where('branch_id', $branchId))
->when($practitionerId, fn ($q) => $q->where('practitioner_id', $practitionerId))
- ->with(['patient', 'practitioner', 'consultation'])
+ ->with(['patient', 'practitioner', 'consultation', 'visit', 'organization'])
->orderBy('started_at')
->get();
}
@@ -139,6 +152,8 @@ class QueueController extends Controller
'canConsult' => $canConsult,
'heroStats' => $heroStats,
'queueIntegration' => $queueIntegration,
+ 'queueContext' => $queueContext,
+ 'specialtyLabel' => $specialtyLabel,
]);
}
diff --git a/app/Http/Controllers/Care/SpecialtyModuleController.php b/app/Http/Controllers/Care/SpecialtyModuleController.php
index bccead3..7b11a79 100644
--- a/app/Http/Controllers/Care/SpecialtyModuleController.php
+++ b/app/Http/Controllers/Care/SpecialtyModuleController.php
@@ -29,8 +29,16 @@ class SpecialtyModuleController extends Controller
SpecialtyModuleService $modules,
SpecialtyShellService $shell,
CareQueueBridge $queueBridge,
- ): View {
- return $this->renderShell($request, $module, 'overview', $modules, $shell, $queueBridge);
+ ): RedirectResponse {
+ $definition = $modules->definition($module);
+ abort_unless($definition, 404);
+ abort_unless(
+ $modules->memberCanAccess($this->organization($request), $this->member($request), $module),
+ 403,
+ );
+
+ // Specialty patient flow lives on Queue; clinical depth opens from Queue Start.
+ return redirect()->route('care.queue.index');
}
public function visits(
@@ -39,8 +47,15 @@ class SpecialtyModuleController extends Controller
SpecialtyModuleService $modules,
SpecialtyShellService $shell,
CareQueueBridge $queueBridge,
- ): View {
- return $this->renderShell($request, $module, 'visits', $modules, $shell, $queueBridge);
+ ): RedirectResponse {
+ $definition = $modules->definition($module);
+ abort_unless($definition, 404);
+ abort_unless(
+ $modules->memberCanAccess($this->organization($request), $this->member($request), $module),
+ 403,
+ );
+
+ return redirect()->route('care.queue.index');
}
public function history(
diff --git a/app/Services/Care/AppointmentService.php b/app/Services/Care/AppointmentService.php
index 78b20e4..195eae8 100644
--- a/app/Services/Care/AppointmentService.php
+++ b/app/Services/Care/AppointmentService.php
@@ -5,6 +5,7 @@ namespace App\Services\Care;
use App\Models\Appointment;
use App\Models\Organization;
use App\Models\Patient;
+use App\Models\Practitioner;
use App\Models\Visit;
use App\Services\Care\Workflow\WorkflowQueueGate;
use App\Services\Care\Workflow\WorkflowStageCompletionService;
@@ -153,17 +154,41 @@ class AppointmentService
->orderBy('waiting_at')
->orderBy('checked_in_at');
+ $practitioners = Practitioner::owned($ownerRef)
+ ->whereIn('id', $practitionerIds)
+ ->get();
+
+ $allowedSpecialtyContexts = [];
+ $orgIds = $practitioners->pluck('organization_id')->filter()->unique()->all();
+ $orgsById = \App\Models\Organization::query()
+ ->whereIn('id', $orgIds ?: [0])
+ ->get()
+ ->keyBy('id');
+
+ foreach ($practitioners as $practitioner) {
+ $org = $orgsById->get((int) $practitioner->organization_id);
+ if (! $org) {
+ continue;
+ }
+ $deskContext = $this->queueBridge->contextForPractitioner($org, $practitioner);
+ if ($deskContext !== CareQueueContexts::CONSULTATION) {
+ $allowedSpecialtyContexts[$deskContext] = true;
+ }
+ }
+ $allowedSpecialtyContexts = array_keys($allowedSpecialtyContexts);
+
return new Collection(
$query->get()
- ->filter(function (Appointment $appointment) {
+ ->filter(function (Appointment $appointment) use ($allowedSpecialtyContexts) {
$organization = $appointment->organization;
if (! $organization) {
return true;
}
$context = $this->queueBridge->contextForAppointment($organization, $appointment);
- // Regular doctor Queue is consultation-only; specialty waiters belong on specialty modules.
- if ($context !== CareQueueContexts::CONSULTATION) {
+ // GPs see consultation only. Specialty desks see their own specialty waiters on Queue.
+ if ($context !== CareQueueContexts::CONSULTATION
+ && ! in_array($context, $allowedSpecialtyContexts, true)) {
return false;
}
diff --git a/resources/views/care/queue/index.blade.php b/resources/views/care/queue/index.blade.php
index a113c88..84e0c63 100644
--- a/resources/views/care/queue/index.blade.php
+++ b/resources/views/care/queue/index.blade.php
@@ -1,12 +1,20 @@
+@php
+ $specialtyLabel = $specialtyLabel ?? null;
+ $queueBridge = app(\App\Services\Care\CareQueueBridge::class);
+@endphp
Open a visit from the queue, or call next from the waiting list.No open visit selected
Service catalog for this module.