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
+122 -195
View File
@@ -5,12 +5,12 @@ namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\Appointment;
use App\Models\Branch;
use App\Models\CareQueueTicket;
use App\Models\CareServiceQueue;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Patient;
use App\Models\Prescription;
use App\Models\User;
use App\Models\Visit;
use App\Services\Care\AppointmentService;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
@@ -34,11 +34,6 @@ class CareQueueWorkflowTest 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' => 'care-queue-workflow-owner',
'name' => 'Owner',
@@ -73,105 +68,6 @@ class CareQueueWorkflowTest extends TestCase
]);
}
protected function fakeQueueApi(): void
{
$consultationQueue = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa';
$pharmacyQueue = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb';
$consultationCounter = 'cccccccc-cccc-cccc-cccc-cccccccccccc';
$pharmacyCounter = 'dddddddd-dddd-dddd-dddd-dddddddddddd';
$seq = ['C' => 0, 'P' => 0];
Http::fake(function (\Illuminate\Http\Client\Request $request) use (
$consultationQueue,
$pharmacyQueue,
$consultationCounter,
$pharmacyCounter,
&$seq,
) {
$url = $request->url();
$method = $request->method();
if (str_contains($url, '/integrations/status')) {
return Http::response([
'data' => [
'provisioned' => true,
'integrations' => ['care' => true],
],
], 200);
}
if ($method === 'POST' && str_contains($url, '/branches')) {
return Http::response(['data' => ['id' => 1, 'name' => 'Main']], 201);
}
if ($method === 'POST' && str_contains($url, '/queues') && ! str_contains($url, 'call-next')) {
$payload = $request->data();
$key = (string) ($payload['external_key'] ?? '');
$isPharmacy = str_contains($key, 'pharmacy');
return Http::response([
'data' => [
'uuid' => $isPharmacy ? $pharmacyQueue : $consultationQueue,
'name' => $payload['name'] ?? 'Queue',
'prefix' => $payload['prefix'] ?? 'X',
],
], 201);
}
if ($method === 'POST' && str_contains($url, '/counters')) {
$payload = $request->data();
$key = (string) ($payload['external_key'] ?? '');
$isPharmacy = str_contains($key, 'pharmacy');
return Http::response([
'data' => [
'uuid' => $isPharmacy ? $pharmacyCounter : $consultationCounter,
'name' => $payload['name'] ?? 'Counter',
],
], 201);
}
if ($method === 'POST' && preg_match('#/tickets$#', parse_url($url, PHP_URL_PATH) ?? '')) {
$payload = $request->data();
$queueId = (string) ($payload['service_queue_id'] ?? '');
$prefix = $queueId === $pharmacyQueue ? 'P' : 'C';
$seq[$prefix]++;
return Http::response([
'data' => [
'uuid' => (string) Str::uuid(),
'ticket_number' => $prefix.sprintf('%03d', $seq[$prefix]),
'status' => 'waiting',
'customer_name' => $payload['customer_name'] ?? null,
],
], 201);
}
if ($method === 'POST' && str_contains($url, '/call-next')) {
$path = parse_url($url, PHP_URL_PATH) ?? '';
$isPharmacy = str_contains($path, $pharmacyQueue);
return Http::response([
'data' => [
'uuid' => (string) Str::uuid(),
'ticket_number' => $isPharmacy ? 'P001' : 'C001',
'status' => 'called',
'customer_name' => 'Called Patient',
],
], 200);
}
if ($method === 'POST' && str_contains($url, '/tickets/') && str_contains($url, '/action')) {
$payload = $request->data();
return Http::response([
'data' => [
'uuid' => basename(dirname(parse_url($url, PHP_URL_PATH) ?? '/x/x')),
'ticket_number' => 'C001',
'status' => $payload['action'] === 'complete' ? 'completed' : ($payload['action'] === 'start' ? 'serving' : 'called'),
],
], 200);
}
return Http::response(['message' => 'unexpected '.$method.' '.$url], 500);
});
}
public function test_integration_off_does_not_issue_tickets_on_check_in(): void
{
$settings = $this->organization->settings;
@@ -211,7 +107,7 @@ class CareQueueWorkflowTest extends TestCase
public function test_integration_on_issues_consultation_ticket_on_check_in(): void
{
$this->fakeQueueApi();
Http::fake();
$practitioner = \App\Models\Practitioner::create([
'owner_ref' => $this->owner->public_id,
@@ -222,33 +118,6 @@ class CareQueueWorkflowTest extends TestCase
'is_active' => true,
]);
$this->organization->update([
'settings' => array_merge($this->organization->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' => 'cccccccc-cccc-cccc-cccc-cccccccccccc',
'points' => [[
'kind' => 'practitioner',
'ref_id' => $practitioner->id,
'destination' => 'Room 2',
'counter_uuid' => 'cccccccc-cccc-cccc-cccc-cccccccccccc',
'synced' => true,
]],
]],
],
],
]),
]);
$patient = Patient::create([
'uuid' => (string) Str::uuid(),
'owner_ref' => $this->owner->public_id,
@@ -277,11 +146,22 @@ class CareQueueWorkflowTest extends TestCase
$this->assertNotNull($appointment->queue_ticket_uuid);
$this->assertSame('C001', $appointment->queue_ticket_number);
$this->assertSame('waiting', $appointment->queue_ticket_status);
$this->assertDatabaseHas('care_queue_tickets', [
'uuid' => $appointment->queue_ticket_uuid,
'ticket_number' => 'C001',
'status' => CareQueueTicket::STATUS_WAITING,
]);
$this->assertDatabaseHas('care_service_queues', [
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'context' => CareQueueContexts::CONSULTATION,
]);
Http::assertNothingSent();
}
public function test_pharmacy_call_next_uses_pharmacy_queue_not_reception(): void
{
$this->fakeQueueApi();
Http::fake();
$pharmacist = Member::create([
'owner_ref' => $this->owner->public_id,
@@ -291,51 +171,98 @@ class CareQueueWorkflowTest extends TestCase
'branch_id' => $this->branch->id,
]);
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'department_queue_provisioning' => [
CareQueueContexts::PHARMACY => [
'queues' => [[
'branch_id' => $this->branch->id,
'branch_name' => 'Main',
'name' => 'Pharmacy',
'prefix' => 'P',
'active' => true,
'synced' => true,
'routing_mode' => 'assigned_only',
'queue_uuid' => 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
'counter_uuid' => 'dddddddd-dddd-dddd-dddd-dddddddddddd',
'queue_external_key' => CareQueueContexts::queueExternalKey(CareQueueContexts::PHARMACY, $this->branch->id),
'counter_external_key' => CareQueueContexts::counterExternalKey(CareQueueContexts::PHARMACY, $this->branch->id),
'points' => [[
'kind' => 'member',
'ref_id' => $pharmacist->id,
'staff_ref' => 'pharm-workflow',
'destination' => 'Pharmacy counter 1',
'counter_uuid' => 'dddddddd-dddd-dddd-dddd-dddddddddddd',
'synced' => true,
]],
]],
],
],
]),
Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'pharmacist']);
$queue = CareServiceQueue::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'context' => CareQueueContexts::PHARMACY,
'name' => 'Pharmacy',
'prefix' => 'P',
'routing_mode' => 'assigned_only',
'external_key' => CareQueueContexts::queueExternalKey(CareQueueContexts::PHARMACY, $this->branch->id),
]);
Member::query()->where('user_ref', $this->owner->public_id)->update(['role' => 'pharmacist']);
$point = $queue->points()->create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Pharmacy counter 1',
'destination' => 'Pharmacy counter 1',
'kind' => 'member',
'ref_id' => $pharmacist->id,
'staff_ref' => 'pharm-workflow',
'external_key' => CareQueueContexts::pointExternalKey(
CareQueueContexts::PHARMACY,
$this->branch->id,
'member',
$pharmacist->id,
),
]);
$settings = $this->organization->settings;
$settings['department_queue_provisioning'] = [
CareQueueContexts::PHARMACY => [
'queues' => [[
'branch_id' => $this->branch->id,
'branch_name' => 'Main',
'name' => 'Pharmacy',
'prefix' => 'P',
'active' => true,
'synced' => true,
'routing_mode' => 'assigned_only',
'queue_uuid' => $queue->uuid,
'counter_uuid' => $point->uuid,
'queue_external_key' => $queue->external_key,
'points' => [[
'kind' => 'member',
'ref_id' => $pharmacist->id,
'staff_ref' => 'pharm-workflow',
'destination' => 'Pharmacy counter 1',
'counter_uuid' => $point->uuid,
'external_key' => $point->external_key,
'synced' => true,
]],
]],
],
];
$this->organization->update(['settings' => $settings]);
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',
]);
$this->actingAs($this->owner)
->post(route('care.prescriptions.call-next'), ['branch_id' => $this->branch->id])
->assertRedirect();
Http::assertSent(function (\Illuminate\Http\Client\Request $request) {
return $request->method() === 'POST'
&& str_contains($request->url(), '/queues/bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb/call-next');
});
$this->assertDatabaseHas('care_queue_tickets', [
'ticket_number' => 'P001',
'status' => CareQueueTicket::STATUS_CALLED,
'service_queue_id' => $queue->id,
]);
Http::assertNothingSent();
}
public function test_complete_advances_ticket_status_on_appointment(): void
{
$this->fakeQueueApi();
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. Complete',
'room' => 'Room 1',
'is_active' => true,
]);
$patient = Patient::create([
'uuid' => (string) Str::uuid(),
@@ -353,42 +280,41 @@ class CareQueueWorkflowTest extends TestCase
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $patient->id,
'practitioner_id' => $practitioner->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_WAITING,
'queue_ticket_uuid' => 'eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee',
'queue_ticket_number' => 'C009',
'queue_ticket_status' => 'serving',
'status' => Appointment::STATUS_SCHEDULED,
'scheduled_at' => now(),
]);
app(CareQueueBridge::class)->complete($this->organization, $appointment);
$appointment->refresh();
$appointment = app(AppointmentService::class)->checkIn(
$appointment->fresh(['organization', 'patient', 'practitioner']),
$this->owner->public_id,
$this->owner->public_id,
);
$bridge = app(CareQueueBridge::class);
$bridge->callNext(
$this->organization->fresh(),
CareQueueContexts::CONSULTATION,
(int) $this->branch->id,
null,
$practitioner->id,
);
$bridge->serve($this->organization->fresh(), $appointment->fresh());
$bridge->complete($this->organization->fresh(), $appointment->fresh());
$appointment->refresh();
$this->assertSame('completed', $appointment->queue_ticket_status);
$this->assertDatabaseHas('care_queue_tickets', [
'uuid' => $appointment->queue_ticket_uuid,
'status' => CareQueueTicket::STATUS_COMPLETED,
]);
Http::assertNothingSent();
}
public function test_patient_queue_shows_call_next_not_service_counter_panel(): void
{
$this->fakeQueueApi();
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'department_queue_provisioning' => [
CareQueueContexts::CONSULTATION => [
'queues' => [[
'branch_id' => $this->branch->id,
'branch_name' => 'Main',
'name' => 'Consultation',
'prefix' => 'C',
'active' => true,
'synced' => true,
'queue_uuid' => 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
'counter_uuid' => 'cccccccc-cccc-cccc-cccc-cccccccccccc',
]],
],
],
]),
]);
Http::fake();
$this->actingAs($this->owner)
->get(route('care.queue.index'))
@@ -396,6 +322,7 @@ class CareQueueWorkflowTest extends TestCase
->assertDontSee('Service counter')
->assertSee('Call next')
->assertSee('assigned service point', false);
Http::assertNothingSent();
}
public function test_integration_off_hides_queue_ops_on_pharmacy_page(): void