Fix patient queue showing position 1 for every waiter.
Deploy Ladill Care / deploy (push) Successful in 1m44s
Deploy Ladill Care / deploy (push) Successful in 1m44s
Specialty demo seed reused slot+1 per module; repair duplicates on queue load and renumber after demo seed so waiting lists show 1..n. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -209,6 +209,52 @@ class CareAppointmentTest extends TestCase
|
||||
->assertSee('Patient queue');
|
||||
}
|
||||
|
||||
public function test_queue_repairs_duplicate_positions(): void
|
||||
{
|
||||
$second = Patient::create([
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'patient_number' => 'LC-2026-00002',
|
||||
'first_name' => 'Kofi',
|
||||
'last_name' => 'Mensah',
|
||||
]);
|
||||
|
||||
foreach ([$this->patient, $second] as $index => $patient) {
|
||||
Appointment::create([
|
||||
'uuid' => (string) \Illuminate\Support\Str::uuid(),
|
||||
'owner_ref' => $this->user->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'patient_id' => $patient->id,
|
||||
'practitioner_id' => $this->practitioner->id,
|
||||
'type' => Appointment::TYPE_WALK_IN,
|
||||
'status' => Appointment::STATUS_WAITING,
|
||||
'scheduled_at' => now()->subMinutes(10 - $index),
|
||||
'waiting_at' => now()->subMinutes(10 - $index),
|
||||
'queue_position' => 1,
|
||||
'reason' => $index === 0 ? 'Toothache' : 'Blurry vision',
|
||||
'created_by' => $this->user->public_id,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->actingAs($this->user)
|
||||
->get(route('care.queue.index', ['branch_id' => $this->branch->id]))
|
||||
->assertOk()
|
||||
->assertSee('Toothache')
|
||||
->assertSee('Blurry vision');
|
||||
|
||||
$positions = Appointment::query()
|
||||
->where('branch_id', $this->branch->id)
|
||||
->where('status', Appointment::STATUS_WAITING)
|
||||
->orderBy('waiting_at')
|
||||
->pluck('queue_position')
|
||||
->all();
|
||||
|
||||
$this->assertSame([1, 2], array_map('intval', $positions));
|
||||
}
|
||||
|
||||
public function test_api_can_book_and_check_in(): void
|
||||
{
|
||||
Sanctum::actingAs($this->user);
|
||||
|
||||
Reference in New Issue
Block a user