Issue Queue tickets for every waiting appointment when integration is on.
Deploy Ladill Care / deploy (push) Successful in 51s
Deploy Ladill Care / deploy (push) Successful in 51s
Patient queue syncs consultation and specialty waiters; specialty contexts now provision desks so check-in/onboarding no longer leaves half the list on local positions only. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -368,5 +368,104 @@ class CareQueueBridgeTest extends TestCase
|
||||
->assertSee('Call again')
|
||||
->assertSee('C055');
|
||||
}
|
||||
|
||||
public function test_patient_queue_sync_issues_specialty_tickets(): void
|
||||
{
|
||||
$department = \App\Models\Department::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'name' => 'Dentistry',
|
||||
'type' => 'dental',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$practitioner = \App\Models\Practitioner::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'department_id' => $department->id,
|
||||
'name' => 'Dentistry Clinic',
|
||||
'room' => 'Dental Bay 1',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$settings = $this->organization->settings;
|
||||
$settings['specialty_modules'] = ['dentistry' => true];
|
||||
$settings['specialty_module_provisioning'] = [
|
||||
'dentistry' => [
|
||||
'active' => true,
|
||||
'department_ids' => [$department->id],
|
||||
'queues' => [[
|
||||
'module' => 'dentistry',
|
||||
'branch_id' => $this->branch->id,
|
||||
'branch_name' => 'Main',
|
||||
'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,
|
||||
]],
|
||||
]],
|
||||
],
|
||||
];
|
||||
$this->organization->update(['settings' => $settings]);
|
||||
|
||||
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,
|
||||
'department_id' => $department->id,
|
||||
'type' => Appointment::TYPE_WALK_IN,
|
||||
'status' => Appointment::STATUS_WAITING,
|
||||
'scheduled_at' => now(),
|
||||
'waiting_at' => now(),
|
||||
'queue_position' => 1,
|
||||
'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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user