Hard-delete Care remote Queue adapter (Phase 5).
Deploy Ladill Care / deploy (push) Failing after 1m13s

Care Queue Engine is the only path; remove QueueClient, driver config, and remote HTTP tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 11:16:41 +00:00
co-authored by Cursor
parent 966f0496b2
commit dd4bc493b4
31 changed files with 441 additions and 2108 deletions
+76 -179
View File
@@ -5,6 +5,7 @@ namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\Appointment;
use App\Models\Branch;
use App\Models\CareQueueTicket;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Patient;
@@ -32,11 +33,6 @@ class CareQueueBridgeTest extends TestCase
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
config([
'care.queue.api_url' => 'https://queue.test/api/v1',
'care.queue.api_key' => 'care-test-key',
]);
$this->owner = User::create([
'public_id' => 'bridge-owner',
'name' => 'Owner',
@@ -70,33 +66,6 @@ class CareQueueBridgeTest extends TestCase
'is_active' => true,
]);
$settings = $this->organization->settings;
$settings['department_queue_provisioning'] = [
CareQueueContexts::CONSULTATION => [
'queues' => [[
'branch_id' => $this->branch->id,
'branch_name' => 'Main',
'name' => 'Consultation',
'prefix' => 'C',
'active' => true,
'synced' => true,
'routing_mode' => 'assigned_only',
'queue_uuid' => 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'counter_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'queue_external_key' => CareQueueContexts::queueExternalKey(CareQueueContexts::CONSULTATION, $this->branch->id),
'counter_external_key' => CareQueueContexts::counterExternalKey(CareQueueContexts::CONSULTATION, $this->branch->id),
'points' => [[
'kind' => 'practitioner',
'ref_id' => 0, // filled after practitioner create in tests that need it
'destination' => 'Consultation desk',
'counter_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'synced' => true,
]],
]],
],
];
$this->organization->update(['settings' => $settings]);
$this->patient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
@@ -111,6 +80,8 @@ class CareQueueBridgeTest extends TestCase
public function test_check_in_issues_consultation_ticket_when_integration_on(): void
{
Http::fake();
$practitioner = \App\Models\Practitioner::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
@@ -120,36 +91,6 @@ class CareQueueBridgeTest extends TestCase
'is_active' => true,
]);
$settings = $this->organization->settings;
$settings['department_queue_provisioning'][CareQueueContexts::CONSULTATION]['queues'][0]['points'] = [[
'kind' => 'practitioner',
'ref_id' => $practitioner->id,
'destination' => 'Room 1',
'staff_display_name' => 'Dr. Bridge',
'counter_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'synced' => true,
]];
$this->organization->update(['settings' => $settings]);
Http::fake(function (\Illuminate\Http\Client\Request $request) {
if (str_contains($request->url(), '/tickets') && $request->method() === 'POST') {
$this->assertSame('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', $request['assigned_counter_id'] ?? null);
return Http::response([
'data' => [
'uuid' => 'cccccccc-cccc-cccc-cccc-cccccccccccc',
'ticket_number' => 'C001',
'status' => 'waiting',
'assigned_counter' => ['uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'],
'destination' => 'Room 1',
'staff_display_name' => 'Dr. Bridge',
],
], 201);
}
return Http::response(['message' => 'unexpected '.$request->url()], 500);
});
$appointment = Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
@@ -163,13 +104,19 @@ class CareQueueBridgeTest extends TestCase
$result = app(AppointmentService::class)->checkIn($appointment, $this->owner->public_id, $this->owner->public_id);
$this->assertSame('C001', $result->queue_ticket_number);
$this->assertNotNull($result->queue_ticket_uuid);
$this->assertSame('waiting', $result->queue_ticket_status);
$this->assertSame('cccccccc-cccc-cccc-cccc-cccccccccccc', $result->queue_ticket_uuid);
Http::assertSent(fn ($request) => str_contains($request->url(), '/tickets')
&& ($request['service_queue_id'] ?? null) === 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
&& ($request['customer_name'] ?? null) === 'Ada Lovelace');
$this->assertStringStartsWith('C', (string) $result->queue_ticket_number);
$this->assertSame('Room 1', $result->queue_destination);
$this->assertSame('Dr. Bridge', $result->queue_staff_display_name);
$this->assertDatabaseHas('care_queue_tickets', [
'uuid' => $result->queue_ticket_uuid,
'ticket_number' => $result->queue_ticket_number,
'status' => CareQueueTicket::STATUS_WAITING,
'care_entity' => 'appointment',
'care_entity_id' => $result->id,
]);
Http::assertNothingSent();
}
public function test_check_in_skips_ticket_when_integration_off(): void
@@ -227,6 +174,8 @@ class CareQueueBridgeTest extends TestCase
public function test_call_next_backfills_missing_ticket_then_calls(): void
{
Http::fake();
$practitioner = \App\Models\Practitioner::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
@@ -236,50 +185,6 @@ class CareQueueBridgeTest extends TestCase
'is_active' => true,
]);
$settings = $this->organization->settings;
$settings['department_queue_provisioning'][CareQueueContexts::CONSULTATION]['queues'][0]['points'] = [[
'kind' => 'practitioner',
'ref_id' => $practitioner->id,
'destination' => 'Room 3',
'counter_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'synced' => true,
]];
$settings['department_queue_provisioning'][CareQueueContexts::CONSULTATION]['queues'][0]['counter_uuid'] = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb';
$this->organization->update(['settings' => $settings]);
$ticketSeq = 0;
Http::fake(function (\Illuminate\Http\Client\Request $request) use (&$ticketSeq) {
if (str_contains($request->url(), '/call-next') && $request->method() === 'POST') {
if ($ticketSeq < 1) {
return Http::response(['data' => null], 200);
}
return Http::response([
'data' => [
'uuid' => 'ffffffff-ffff-ffff-ffff-ffffffffffff',
'ticket_number' => 'C100',
'customer_name' => 'Ada Lovelace',
'status' => 'called',
],
], 200);
}
if (str_contains($request->url(), '/tickets') && $request->method() === 'POST') {
$ticketSeq++;
return Http::response([
'data' => [
'uuid' => 'ffffffff-ffff-ffff-ffff-ffffffffffff',
'ticket_number' => 'C100',
'status' => 'waiting',
'assigned_counter' => ['uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb'],
],
], 201);
}
return Http::response(['message' => 'unexpected '.$request->url()], 500);
});
Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
@@ -302,16 +207,19 @@ class CareQueueBridgeTest extends TestCase
->assertRedirect(route('care.queue.index'))
->assertSessionHas('success');
$this->assertNotNull(Appointment::query()->where('patient_id', $this->patient->id)->value('queue_ticket_uuid'));
Http::assertSent(fn ($r) => str_contains($r->url(), '/tickets') && $r->method() === 'POST');
Http::assertSent(fn ($r) => str_contains($r->url(), '/call-next'));
$appointment = Appointment::query()->where('patient_id', $this->patient->id)->first();
$this->assertNotNull($appointment?->queue_ticket_uuid);
$this->assertSame('called', $appointment->queue_ticket_status);
$this->assertDatabaseHas('care_queue_tickets', [
'uuid' => $appointment->queue_ticket_uuid,
'status' => CareQueueTicket::STATUS_CALLED,
]);
Http::assertNothingSent();
}
public function test_call_next_empty_queue_flashes_info_not_error(): void
{
Http::fake([
'*/queues/*/call-next*' => Http::response(['data' => null], 200),
]);
Http::fake();
$this->actingAs($this->owner)
->from(route('care.queue.index'))
@@ -319,35 +227,51 @@ class CareQueueBridgeTest extends TestCase
->assertRedirect(route('care.queue.index'))
->assertSessionHas('info', 'No patients waiting at your consultation service point.')
->assertSessionMissing('error');
Http::assertNothingSent();
}
public function test_recall_reannounces_called_ticket_from_patient_queue(): void
{
Http::fake();
$practitioner = \App\Models\Practitioner::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'name' => 'Dr. Recall',
'room' => 'Room 2',
'is_active' => true,
]);
$appointment = Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'practitioner_id' => $practitioner->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_WAITING,
'status' => Appointment::STATUS_SCHEDULED,
'scheduled_at' => now(),
'waiting_at' => now(),
'queue_position' => 1,
'queue_ticket_uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'queue_ticket_number' => 'C055',
'queue_ticket_status' => 'called',
]);
Http::fake([
'*/tickets/*/action*' => Http::response([
'data' => [
'uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'ticket_number' => 'C055',
'status' => 'called',
'customer_name' => 'Ada Lovelace',
],
], 200),
]);
$checkedIn = app(AppointmentService::class)->checkIn(
$appointment->fresh(['organization', 'patient', 'practitioner']),
$this->owner->public_id,
$this->owner->public_id,
);
$bridge = app(\App\Services\Care\CareQueueBridge::class);
$called = $bridge->callNext(
$this->organization->fresh(),
CareQueueContexts::CONSULTATION,
(int) $this->branch->id,
null,
$practitioner->id,
);
$this->assertNotNull($called['ticket']);
$appointment = $checkedIn->fresh();
$this->assertSame('called', $appointment->queue_ticket_status);
$this->actingAs($this->owner)
->from(route('care.queue.index'))
@@ -355,22 +279,20 @@ class CareQueueBridgeTest extends TestCase
->assertRedirect(route('care.queue.index'))
->assertSessionHas('success');
Http::assertSent(function ($request) {
return str_contains($request->url(), '/tickets/eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee/action')
&& ($request['action'] ?? null) === 'recall';
});
$this->assertSame('called', $appointment->fresh()->queue_ticket_status);
$this->actingAs($this->owner)
->get(route('care.queue.index', ['branch_id' => $this->branch->id]))
->assertOk()
->assertSee('Call again')
->assertSee('C055');
->assertSee($appointment->queue_ticket_number);
Http::assertNothingSent();
}
public function test_patient_queue_sync_issues_specialty_tickets(): void
{
Http::fake();
$department = \App\Models\Department::create([
'owner_ref' => $this->owner->public_id,
'branch_id' => $this->branch->id,
@@ -402,20 +324,7 @@ class CareQueueBridgeTest extends TestCase
'name' => 'Dentistry',
'prefix' => 'DEN',
'active' => true,
'synced' => true,
'routing_mode' => 'assigned_only',
'queue_uuid' => 'dddddddd-dddd-dddd-dddd-dddddddddddd',
'counter_uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'queue_external_key' => CareQueueContexts::queueExternalKey('dentistry', $this->branch->id),
'counter_external_key' => CareQueueContexts::counterExternalKey('dentistry', $this->branch->id),
'points' => [[
'kind' => 'practitioner',
'ref_id' => $practitioner->id,
'destination' => 'Dental Bay 1',
'staff_display_name' => 'Dentistry Clinic',
'counter_uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'synced' => true,
]],
'synced' => false,
]],
],
];
@@ -436,36 +345,24 @@ class CareQueueBridgeTest extends TestCase
'reason' => 'Toothache',
]);
Http::fake(function (\Illuminate\Http\Client\Request $request) {
if (str_contains($request->url(), '/tickets') && $request->method() === 'POST') {
$this->assertSame('dddddddd-dddd-dddd-dddd-dddddddddddd', $request['service_queue_id'] ?? null);
$this->assertSame('eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee', $request['assigned_counter_id'] ?? null);
return Http::response([
'data' => [
'uuid' => 'ffffffff-ffff-ffff-ffff-ffffffffffff',
'ticket_number' => 'DEN001',
'status' => 'waiting',
'assigned_counter' => ['uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee'],
'destination' => 'Dental Bay 1',
'staff_display_name' => 'Dentistry Clinic',
],
], 201);
}
return Http::response(['data' => []], 200);
});
$this->actingAs($this->owner)
->get(route('care.queue.index', ['branch_id' => $this->branch->id]))
->assertOk()
->assertSee('DEN001')
->assertSee('Toothache');
$this->assertDatabaseHas('care_appointments', [
'patient_id' => $this->patient->id,
'queue_ticket_number' => 'DEN001',
$appointment = Appointment::query()->where('patient_id', $this->patient->id)->first();
$this->assertNotNull($appointment?->queue_ticket_uuid);
$this->assertStringStartsWith('DEN', (string) $appointment->queue_ticket_number);
$this->assertDatabaseHas('care_service_queues', [
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'context' => 'dentistry',
]);
$this->assertDatabaseHas('care_queue_tickets', [
'uuid' => $appointment->queue_ticket_uuid,
'ticket_number' => $appointment->queue_ticket_number,
'status' => CareQueueTicket::STATUS_WAITING,
]);
Http::assertNothingSent();
}
}