Wire Care lists into Ladill Queue workflows instead of reception panels.
Deploy Ladill Care / deploy (push) Successful in 1m45s

When Queue integration is on, role pages issue tickets into their own
department queues and drive Call next → Serve → Complete on the native
lists. Integration off leaves existing UI unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 16:27:48 +00:00
co-authored by Cursor
parent 15638d1672
commit 015a4cc7fe
38 changed files with 1857 additions and 196 deletions
+79 -90
View File
@@ -8,9 +8,11 @@ use App\Models\Member;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
/**
* Natural list UX: no bolted-on Service counter panels; Queue ops live on role lists when enabled.
*/
class CareNaturalQueueTest extends TestCase
{
use RefreshDatabase;
@@ -45,6 +47,38 @@ class CareNaturalQueueTest extends TestCase
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
'queue_integration_enabled' => true,
'department_queue_provisioning' => [
'consultation' => [
'queues' => [[
'branch_id' => 1,
'name' => 'Consultation',
'active' => true,
'synced' => true,
'queue_uuid' => 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'counter_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
]],
],
'pharmacy' => [
'queues' => [[
'branch_id' => 1,
'name' => 'Pharmacy',
'active' => true,
'synced' => true,
'queue_uuid' => 'cccccccc-cccc-cccc-cccc-cccccccccccc',
'counter_uuid' => 'dddddddd-dddd-dddd-dddd-dddddddddddd',
]],
],
'laboratory' => [
'queues' => [[
'branch_id' => 1,
'name' => 'Laboratory',
'active' => true,
'synced' => true,
'queue_uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'counter_uuid' => 'ffffffff-ffff-ffff-ffff-ffffffffffff',
]],
],
],
],
]);
@@ -55,49 +89,23 @@ class CareNaturalQueueTest extends TestCase
'role' => 'hospital_admin',
]);
Branch::create([
$branch = Branch::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Main',
'is_active' => true,
]);
}
protected function fakeQueueApi(): void
{
Http::fake(function (\Illuminate\Http\Client\Request $request) {
$url = $request->url();
if (str_contains($url, '/counters/') && str_contains($url, '/console')) {
return Http::response([
'data' => [
'counter' => ['name' => 'Reception desk', 'branch' => 'Main', 'status' => 'available'],
'current_ticket' => null,
'queues' => [['uuid' => '22222222-2222-2222-2222-222222222222', 'name' => 'Consultation']],
'waiting_by_queue' => [],
'transfer_queues' => [],
],
], 200);
}
if (str_contains($url, '/counters')) {
return Http::response([
'data' => [[
'uuid' => '11111111-1111-1111-1111-111111111111',
'name' => 'Reception desk',
'branch' => 'Main',
'status' => 'available',
'queues' => [['uuid' => '22222222-2222-2222-2222-222222222222', 'name' => 'Consultation']],
]],
], 200);
}
return Http::response(['message' => 'unexpected '.$url], 500);
});
// Keep provisioning stubs aligned with the created branch id.
$settings = $this->organization->settings;
foreach (['consultation', 'pharmacy', 'laboratory'] as $ctx) {
$settings['department_queue_provisioning'][$ctx]['queues'][0]['branch_id'] = $branch->id;
}
$this->organization->update(['settings' => $settings]);
}
public function test_sidebar_does_not_show_service_queues_nav(): void
{
$this->fakeQueueApi();
$this->actingAs($this->owner)
->get(route('care.dashboard'))
->assertOk()
@@ -111,89 +119,70 @@ class CareNaturalQueueTest extends TestCase
->assertRedirect(route('care.queue.index'));
}
public function test_clinical_queue_embeds_service_counter_panel(): void
public function test_clinical_queue_shows_inline_ops_not_service_counter(): void
{
$this->fakeQueueApi();
$this->actingAs($this->owner)
->get(route('care.queue.index'))
->assertOk()
->assertSee('Service counter')
->assertSee('Reception desk')
->assertDontSee('Service counter')
->assertSee('Call next');
}
public function test_pharmacist_sees_queue_panel_on_pharmacy_page(): void
public function test_pharmacist_sees_call_next_on_pharmacy_page(): void
{
$this->fakeQueueApi();
Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'pharmacist']);
$this->actingAs($this->owner)
->get(route('care.prescriptions.queue'))
->assertOk()
->assertSee('Service counter');
->assertDontSee('Service counter')
->assertSee('Call next');
}
public function test_lab_page_embeds_service_counter_when_integration_on(): void
public function test_lab_page_shows_call_next_when_integration_on(): void
{
$this->fakeQueueApi();
Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'lab_technician']);
$this->actingAs($this->owner)
->get(route('care.lab.queue.index'))
->assertOk()
->assertSee('Service counter');
->assertDontSee('Service counter')
->assertSee('Call next');
}
public function test_branch_scoped_member_panel_prefers_matching_branch_counter(): void
public function test_integration_off_hides_queue_controls(): void
{
Http::fake(function (\Illuminate\Http\Client\Request $request) {
$url = $request->url();
if (str_contains($url, '/counters/') && str_contains($url, '/console')) {
return Http::response([
'data' => [
'counter' => ['name' => 'Main reception', 'branch' => 'Main'],
'current_ticket' => null,
'queues' => [['uuid' => 'cccccccc-cccc-cccc-cccc-cccccccccccc', 'name' => 'Consultation']],
'waiting_by_queue' => [],
'transfer_queues' => [],
],
], 200);
}
if (str_contains($url, '/counters')) {
return Http::response([
'data' => [
[
'uuid' => 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'name' => 'Other site desk',
'branch' => 'Other',
'queues' => [['name' => 'Consultation']],
],
[
'uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'name' => 'Main reception',
'branch' => 'Main',
'queues' => [['name' => 'Consultation']],
],
],
], 200);
}
return Http::response(['message' => 'unexpected '.$url], 500);
});
$branch = Branch::query()->first();
Member::query()->where('user_ref', $this->owner->public_id)->update([
'role' => 'receptionist',
'branch_id' => $branch->id,
]);
$settings = $this->organization->settings;
$settings['queue_integration_enabled'] = false;
$this->organization->update(['settings' => $settings]);
$this->actingAs($this->owner)
->get(route('care.queue.index'))
->assertOk()
->assertSee('Main reception')
->assertDontSee('Other site desk');
->assertDontSee('Call next')
->assertDontSee('Service counter');
}
public function test_doctor_call_next_uses_consultation_queue_not_reception(): void
{
\Illuminate\Support\Facades\Http::fake([
'*/queues/*/call-next*' => \Illuminate\Support\Facades\Http::response([
'data' => [
'uuid' => '77777777-7777-7777-7777-777777777777',
'ticket_number' => 'C001',
'status' => 'called',
],
], 200),
]);
$branchId = Branch::query()->firstOrFail()->id;
$this->actingAs($this->owner)
->post(route('care.queue.call-next'), ['branch_id' => $branchId])
->assertRedirect();
\Illuminate\Support\Facades\Http::assertSent(function ($request) {
return str_contains($request->url(), '/queues/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/call-next');
});
}
}