Hard-delete Care remote Queue adapter (Phase 5).
Deploy Ladill Care / deploy (push) Failing after 1m13s
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:
@@ -5,6 +5,9 @@ namespace Tests\Feature;
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Branch;
|
||||
use App\Models\CareQueueTicket;
|
||||
use App\Models\CareServicePoint;
|
||||
use App\Models\CareServiceQueue;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Patient;
|
||||
@@ -38,11 +41,6 @@ class CareServicePointRoutingTest 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' => 'sp-care-owner',
|
||||
'name' => 'Owner',
|
||||
@@ -97,101 +95,11 @@ class CareServicePointRoutingTest extends TestCase
|
||||
'user_ref' => 'doc-okai',
|
||||
'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',
|
||||
'queue_external_key' => CareQueueContexts::queueExternalKey(CareQueueContexts::CONSULTATION, $this->branch->id),
|
||||
'points' => [
|
||||
[
|
||||
'kind' => 'practitioner',
|
||||
'ref_id' => $this->doctorA->id,
|
||||
'name' => 'Dr. Mensah',
|
||||
'destination' => 'Consultation Room 4',
|
||||
'staff_display_name' => 'Dr. Mensah',
|
||||
'external_key' => CareQueueContexts::pointExternalKey(
|
||||
CareQueueContexts::CONSULTATION,
|
||||
$this->branch->id,
|
||||
'practitioner',
|
||||
$this->doctorA->id,
|
||||
),
|
||||
'counter_uuid' => '11111111-1111-1111-1111-111111111111',
|
||||
'synced' => true,
|
||||
],
|
||||
[
|
||||
'kind' => 'practitioner',
|
||||
'ref_id' => $this->doctorB->id,
|
||||
'name' => 'Dr. Okai',
|
||||
'destination' => 'Consultation Room 5',
|
||||
'staff_display_name' => 'Dr. Okai',
|
||||
'external_key' => CareQueueContexts::pointExternalKey(
|
||||
CareQueueContexts::CONSULTATION,
|
||||
$this->branch->id,
|
||||
'practitioner',
|
||||
$this->doctorB->id,
|
||||
),
|
||||
'counter_uuid' => '22222222-2222-2222-2222-222222222222',
|
||||
'synced' => true,
|
||||
],
|
||||
],
|
||||
]],
|
||||
],
|
||||
CareQueueContexts::PHARMACY => [
|
||||
'queues' => [[
|
||||
'branch_id' => $this->branch->id,
|
||||
'name' => 'Pharmacy',
|
||||
'prefix' => 'P',
|
||||
'active' => true,
|
||||
'synced' => true,
|
||||
'routing_mode' => 'assigned_only',
|
||||
'queue_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
|
||||
'points' => [[
|
||||
'kind' => 'member',
|
||||
'ref_id' => 1,
|
||||
'destination' => 'Pharmacy counter 1',
|
||||
'counter_uuid' => '33333333-3333-3333-3333-333333333333',
|
||||
'synced' => true,
|
||||
]],
|
||||
]],
|
||||
],
|
||||
];
|
||||
$this->organization->update(['settings' => $settings]);
|
||||
}
|
||||
|
||||
public function test_fixed_doctor_appointment_issues_to_that_doctors_point(): void
|
||||
{
|
||||
Http::fake(function (\Illuminate\Http\Client\Request $request) {
|
||||
if ($request->method() === 'POST' && str_contains($request->url(), '/tickets')) {
|
||||
$this->assertSame('11111111-1111-1111-1111-111111111111', $request['assigned_counter_id'] ?? null);
|
||||
$this->assertSame('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', $request['service_queue_id'] ?? null);
|
||||
|
||||
return Http::response([
|
||||
'data' => [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'ticket_number' => 'C001',
|
||||
'status' => 'waiting',
|
||||
'destination' => 'Consultation Room 4',
|
||||
'staff_display_name' => 'Dr. Mensah',
|
||||
'assigned_counter' => [
|
||||
'uuid' => '11111111-1111-1111-1111-111111111111',
|
||||
'destination' => 'Consultation Room 4',
|
||||
'staff_display_name' => 'Dr. Mensah',
|
||||
],
|
||||
],
|
||||
], 201);
|
||||
}
|
||||
|
||||
return Http::response(['message' => 'unexpected'], 500);
|
||||
});
|
||||
Http::fake();
|
||||
|
||||
$patient = Patient::create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
@@ -217,14 +125,22 @@ class CareServicePointRoutingTest extends TestCase
|
||||
|
||||
$result = app(AppointmentService::class)->checkIn($appointment, $this->owner->public_id);
|
||||
|
||||
$point = CareServicePoint::query()
|
||||
->where('organization_id', $this->organization->id)
|
||||
->where('kind', 'practitioner')
|
||||
->where('ref_id', $this->doctorA->id)
|
||||
->first();
|
||||
|
||||
$this->assertNotNull($point);
|
||||
$this->assertSame('C001', $result->queue_ticket_number);
|
||||
$this->assertSame('11111111-1111-1111-1111-111111111111', $result->queue_service_point_uuid);
|
||||
$this->assertSame($point->uuid, $result->queue_service_point_uuid);
|
||||
$this->assertSame('Consultation Room 4', $result->queue_destination);
|
||||
$this->assertSame('Dr. Mensah', $result->queue_staff_display_name);
|
||||
$this->assertSame(CareQueueContexts::ROUTING_ROUTED, $result->queue_routing_status);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_walk_in_without_doctor_flags_unresolved_and_does_not_issue(): void
|
||||
public function test_walk_in_without_doctor_routes_to_default_desk(): void
|
||||
{
|
||||
Http::fake();
|
||||
|
||||
@@ -252,31 +168,19 @@ class CareServicePointRoutingTest extends TestCase
|
||||
|
||||
$result = app(CareQueueBridge::class)->issueForAppointment($this->organization, $appointment);
|
||||
|
||||
$this->assertNull($result->queue_ticket_uuid);
|
||||
$this->assertSame(CareQueueContexts::ROUTING_UNRESOLVED, $result->queue_routing_status);
|
||||
// Native engine prefers an available desk over leaving waiters without a ticket.
|
||||
$this->assertNotNull($result->queue_ticket_uuid);
|
||||
$this->assertSame(CareQueueContexts::ROUTING_ROUTED, $result->queue_routing_status);
|
||||
$this->assertDatabaseHas('care_queue_tickets', [
|
||||
'uuid' => $result->queue_ticket_uuid,
|
||||
'status' => CareQueueTicket::STATUS_WAITING,
|
||||
]);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_walk_in_with_selected_doctor_routes_only_to_that_point(): void
|
||||
{
|
||||
Http::fake(function (\Illuminate\Http\Client\Request $request) {
|
||||
if ($request->method() === 'POST' && str_contains($request->url(), '/tickets')) {
|
||||
$this->assertSame('22222222-2222-2222-2222-222222222222', $request['assigned_counter_id'] ?? null);
|
||||
|
||||
return Http::response([
|
||||
'data' => [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'ticket_number' => 'C002',
|
||||
'status' => 'waiting',
|
||||
'assigned_counter' => ['uuid' => '22222222-2222-2222-2222-222222222222'],
|
||||
'destination' => 'Consultation Room 5',
|
||||
'staff_display_name' => 'Dr. Okai',
|
||||
],
|
||||
], 201);
|
||||
}
|
||||
|
||||
return Http::response(['message' => 'unexpected'], 500);
|
||||
});
|
||||
Http::fake();
|
||||
|
||||
$patient = Patient::create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
@@ -300,13 +204,24 @@ class CareServicePointRoutingTest extends TestCase
|
||||
$this->owner->public_id,
|
||||
);
|
||||
|
||||
$point = CareServicePoint::query()
|
||||
->where('organization_id', $this->organization->id)
|
||||
->where('kind', 'practitioner')
|
||||
->where('ref_id', $this->doctorB->id)
|
||||
->first();
|
||||
|
||||
$this->assertSame($this->doctorB->id, $appointment->practitioner_id);
|
||||
$this->assertSame('C002', $appointment->queue_ticket_number);
|
||||
$this->assertSame('C001', $appointment->queue_ticket_number);
|
||||
$this->assertSame('Consultation Room 5', $appointment->queue_destination);
|
||||
$this->assertNotNull($point);
|
||||
$this->assertSame($point->uuid, $appointment->queue_service_point_uuid);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_pharmacist_call_next_uses_pharmacy_point(): void
|
||||
{
|
||||
Http::fake();
|
||||
|
||||
$pharmacist = Member::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
@@ -315,33 +230,34 @@ class CareServicePointRoutingTest extends TestCase
|
||||
'branch_id' => $this->branch->id,
|
||||
]);
|
||||
|
||||
$settings = $this->organization->settings;
|
||||
$settings['department_queue_provisioning'][CareQueueContexts::PHARMACY]['queues'][0]['points'] = [[
|
||||
'kind' => 'member',
|
||||
'ref_id' => $pharmacist->id,
|
||||
'destination' => 'Pharmacy counter 1',
|
||||
'staff_ref' => 'pharm-1',
|
||||
'counter_uuid' => '33333333-3333-3333-3333-333333333333',
|
||||
'synced' => true,
|
||||
]];
|
||||
$this->organization->update(['settings' => $settings]);
|
||||
app(CareQueueProvisioner::class)->ensure(
|
||||
$this->organization->fresh(),
|
||||
CareQueueContexts::PHARMACY,
|
||||
$this->branch->id,
|
||||
);
|
||||
|
||||
Http::fake(function (\Illuminate\Http\Client\Request $request) {
|
||||
if (str_contains($request->url(), '/call-next')) {
|
||||
$this->assertStringContainsString('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', $request->url());
|
||||
$this->assertSame('33333333-3333-3333-3333-333333333333', $request['counter_id'] ?? null);
|
||||
$queue = CareServiceQueue::query()
|
||||
->where('organization_id', $this->organization->id)
|
||||
->where('context', CareQueueContexts::PHARMACY)
|
||||
->where('branch_id', $this->branch->id)
|
||||
->firstOrFail();
|
||||
|
||||
return Http::response([
|
||||
'data' => [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'ticket_number' => 'P001',
|
||||
'status' => 'called',
|
||||
],
|
||||
], 200);
|
||||
}
|
||||
$point = CareServicePoint::query()
|
||||
->where('service_queue_id', $queue->id)
|
||||
->where('kind', 'member')
|
||||
->where('ref_id', $pharmacist->id)
|
||||
->firstOrFail();
|
||||
|
||||
return Http::response(['message' => 'unexpected'], 500);
|
||||
});
|
||||
CareQueueTicket::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'service_queue_id' => $queue->id,
|
||||
'service_point_id' => $point->id,
|
||||
'ticket_number' => 'P001',
|
||||
'status' => CareQueueTicket::STATUS_WAITING,
|
||||
'priority' => 'walk_in',
|
||||
'customer_name' => 'Pharmacy Patient',
|
||||
]);
|
||||
|
||||
$result = app(CareQueueBridge::class)->callNext(
|
||||
$this->organization->fresh(),
|
||||
@@ -351,6 +267,9 @@ class CareServicePointRoutingTest extends TestCase
|
||||
);
|
||||
|
||||
$this->assertSame('P001', $result['ticket']['ticket_number'] ?? null);
|
||||
$this->assertSame('called', $result['ticket']['status'] ?? null);
|
||||
$this->assertSame($point->uuid, $result['ticket']['assigned_counter']['uuid'] ?? null);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_integration_off_preserves_behavior_without_ticket_issuance(): void
|
||||
@@ -391,57 +310,30 @@ class CareServicePointRoutingTest extends TestCase
|
||||
|
||||
public function test_provisioner_builds_one_point_per_practitioner_idempotently(): void
|
||||
{
|
||||
$calls = ['queues' => 0, 'counters' => 0];
|
||||
|
||||
Http::fake(function (\Illuminate\Http\Client\Request $request) use (&$calls) {
|
||||
if (str_contains($request->url(), '/integrations/status')) {
|
||||
return Http::response(['data' => ['provisioned' => true, 'integrations' => ['care' => true]]], 200);
|
||||
}
|
||||
if (str_contains($request->url(), '/branches') && $request->method() === 'POST') {
|
||||
return Http::response(['data' => ['name' => 'Main']], 201);
|
||||
}
|
||||
if (str_contains($request->url(), '/departments') && $request->method() === 'POST') {
|
||||
return Http::response(['data' => ['id' => 9, 'name' => $request['name'] ?? 'Dept']], 201);
|
||||
}
|
||||
if (str_contains($request->url(), '/queues') && $request->method() === 'POST' && ! str_contains($request->url(), 'call-next')) {
|
||||
$calls['queues']++;
|
||||
$this->assertSame('assigned_only', $request['routing_mode'] ?? null);
|
||||
|
||||
return Http::response([
|
||||
'data' => [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'name' => $request['name'] ?? 'Q',
|
||||
'external_key' => $request['external_key'] ?? null,
|
||||
],
|
||||
], 201);
|
||||
}
|
||||
if (str_contains($request->url(), '/counters') && $request->method() === 'POST') {
|
||||
$calls['counters']++;
|
||||
|
||||
return Http::response([
|
||||
'data' => [
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'name' => $request['name'] ?? 'C',
|
||||
'destination' => $request['destination'] ?? null,
|
||||
],
|
||||
], 201);
|
||||
}
|
||||
|
||||
return Http::response(['message' => 'unexpected '.$request->url()], 500);
|
||||
});
|
||||
|
||||
// Clear prior stub so provisioner builds fresh.
|
||||
$settings = $this->organization->settings;
|
||||
unset($settings['department_queue_provisioning']);
|
||||
$this->organization->update(['settings' => $settings]);
|
||||
Http::fake();
|
||||
|
||||
app(CareQueueProvisioner::class)->provisionOrganization($this->organization->fresh());
|
||||
$first = data_get($this->organization->fresh()->settings, 'department_queue_provisioning.consultation.queues.0.points');
|
||||
$this->assertIsArray($first);
|
||||
$this->assertGreaterThanOrEqual(2, count($first));
|
||||
|
||||
$this->assertDatabaseHas('care_service_queues', [
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'context' => CareQueueContexts::CONSULTATION,
|
||||
]);
|
||||
$this->assertEquals(
|
||||
2,
|
||||
CareServicePoint::query()
|
||||
->where('organization_id', $this->organization->id)
|
||||
->where('kind', 'practitioner')
|
||||
->whereIn('ref_id', [$this->doctorA->id, $this->doctorB->id])
|
||||
->count(),
|
||||
);
|
||||
|
||||
app(CareQueueProvisioner::class)->provisionOrganization($this->organization->fresh());
|
||||
$second = data_get($this->organization->fresh()->settings, 'department_queue_provisioning.consultation.queues.0.points');
|
||||
$this->assertCount(count($first), $second);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user