Fix specialty Call next vs WAITING KPI mismatch.
Deploy Ladill Care / deploy (push) Successful in 1m44s
Deploy Ladill Care / deploy (push) Successful in 1m44s
Admins without a desk now scan all specialty service points, KPIs use the same branch as queue ops, and empty Call next flashes explain tickets vs other branches. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Models\Branch;
|
||||
use App\Models\CareQueueTicket;
|
||||
use App\Models\CareServicePoint;
|
||||
use App\Models\CareServiceQueue;
|
||||
use App\Models\Department;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Patient;
|
||||
@@ -336,4 +337,114 @@ class CareServicePointRoutingTest extends TestCase
|
||||
$this->assertCount(count($first), $second);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_admin_specialty_call_next_finds_ticket_on_other_service_point(): void
|
||||
{
|
||||
Http::fake();
|
||||
|
||||
$department = Department::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'name' => 'Dentistry',
|
||||
'type' => 'dental',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$dentistA = Practitioner::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'department_id' => $department->id,
|
||||
'name' => 'Dr. Dental A',
|
||||
'specialty' => 'Dentistry',
|
||||
'room' => 'Bay 1',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$dentistB = Practitioner::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'department_id' => $department->id,
|
||||
'name' => 'Dr. Dental B',
|
||||
'specialty' => 'Dentistry',
|
||||
'room' => 'Bay 2',
|
||||
'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' => false,
|
||||
]],
|
||||
],
|
||||
];
|
||||
$this->organization->update(['settings' => $settings]);
|
||||
|
||||
app(CareQueueProvisioner::class)->ensure(
|
||||
$this->organization->fresh(),
|
||||
'dentistry',
|
||||
$this->branch->id,
|
||||
);
|
||||
|
||||
$queue = CareServiceQueue::query()
|
||||
->where('organization_id', $this->organization->id)
|
||||
->where('context', 'dentistry')
|
||||
->where('branch_id', $this->branch->id)
|
||||
->firstOrFail();
|
||||
|
||||
$pointA = CareServicePoint::query()
|
||||
->where('service_queue_id', $queue->id)
|
||||
->where('kind', 'practitioner')
|
||||
->where('ref_id', $dentistA->id)
|
||||
->firstOrFail();
|
||||
|
||||
$pointB = CareServicePoint::query()
|
||||
->where('service_queue_id', $queue->id)
|
||||
->where('kind', 'practitioner')
|
||||
->where('ref_id', $dentistB->id)
|
||||
->firstOrFail();
|
||||
|
||||
// Ticket waits only at Bay 2; admin default desk is Bay 1 (lower ref_id).
|
||||
CareQueueTicket::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'service_queue_id' => $queue->id,
|
||||
'service_point_id' => $pointB->id,
|
||||
'ticket_number' => 'DEN001',
|
||||
'status' => CareQueueTicket::STATUS_WAITING,
|
||||
'priority' => 'walk_in',
|
||||
'customer_name' => 'Waiting Dental Patient',
|
||||
]);
|
||||
|
||||
$admin = Member::query()
|
||||
->where('organization_id', $this->organization->id)
|
||||
->where('role', 'hospital_admin')
|
||||
->firstOrFail();
|
||||
|
||||
$result = app(CareQueueBridge::class)->callNext(
|
||||
$this->organization->fresh(),
|
||||
'dentistry',
|
||||
$this->branch->id,
|
||||
$admin,
|
||||
null,
|
||||
);
|
||||
|
||||
$this->assertSame('DEN001', $result['ticket']['ticket_number'] ?? null);
|
||||
$this->assertSame('called', $result['ticket']['status'] ?? null);
|
||||
$this->assertSame($pointB->uuid, $result['ticket']['assigned_counter']['uuid'] ?? null);
|
||||
$this->assertNotSame($pointA->uuid, $result['ticket']['assigned_counter']['uuid'] ?? null);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user