diff --git a/app/Http/Controllers/Care/ServiceQueueController.php b/app/Http/Controllers/Care/ServiceQueueController.php index 10a216b..909a9fe 100644 --- a/app/Http/Controllers/Care/ServiceQueueController.php +++ b/app/Http/Controllers/Care/ServiceQueueController.php @@ -4,12 +4,14 @@ namespace App\Http\Controllers\Care; use App\Http\Controllers\Controller; use App\Http\Controllers\Care\Concerns\ScopesToAccount; +use App\Models\Member; +use App\Services\Care\CarePermissions; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; /** - * Legacy Ladill Queue console routes — redirect to the Care patient queue (doctors) - * or appointments list when the actor cannot open the patient-flow board. + * Legacy Ladill Queue console routes — redirect each role to its natural + * Care list (billing booth, pharmacy/lab queues, doctor patient-flow board). */ class ServiceQueueController extends Controller { @@ -38,10 +40,29 @@ class ServiceQueueController extends Controller protected function redirectAwayFromLegacyConsole(Request $request): RedirectResponse { - if (app(\App\Services\Care\CarePermissions::class)->canAccessPatientQueue($this->member($request))) { + $member = $this->member($request); + $permissions = app(CarePermissions::class); + + if ($permissions->canAccessPatientQueue($member)) { return redirect()->route('care.queue.index'); } - return redirect()->route('care.appointments.index'); + return redirect()->route($this->naturalListRouteFor($member)); + } + + /** + * Role pages that own Call next / payment ops after the old counter console + * was removed. Must be a route the member can open (not appointments for + * cashiers / pharmacists / lab techs who lack appointments.view). + */ + protected function naturalListRouteFor(?Member $member): string + { + return match ($member?->role) { + 'cashier' => 'care.bills.index', + 'pharmacist' => 'care.prescriptions.queue', + 'lab_technician' => 'care.lab.queue.index', + 'receptionist', 'nurse' => 'care.appointments.index', + default => 'care.dashboard', + }; } } diff --git a/tests/Feature/CareNaturalQueueTest.php b/tests/Feature/CareNaturalQueueTest.php index d794cd1..db4965b 100644 --- a/tests/Feature/CareNaturalQueueTest.php +++ b/tests/Feature/CareNaturalQueueTest.php @@ -90,6 +90,24 @@ class CareNaturalQueueTest extends TestCase ->assertRedirect(route('care.queue.index')); } + public function test_service_queues_redirect_cashiers_to_billing_not_appointments(): void + { + Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'cashier']); + + $this->actingAs($this->owner) + ->get(route('care.service-queues.index')) + ->assertRedirect(route('care.bills.index')); + } + + public function test_service_queues_redirect_pharmacists_to_pharmacy_queue(): void + { + Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'pharmacist']); + + $this->actingAs($this->owner) + ->get(route('care.service-queues.index')) + ->assertRedirect(route('care.prescriptions.queue')); + } + public function test_clinical_queue_shows_inline_ops_not_service_counter(): void { Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'doctor']);