Improve specialty workspace actions and Call next handoff.
Deploy Ladill Care / deploy (push) Successful in 40s

Move timeline into a workspace tab, surface Complete consultation and Call again in Actions, and make Call next end the current encounter then open the next called patient.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 16:12:30 +00:00
co-authored by Cursor
parent 5bdc17777c
commit a00a8249ad
13 changed files with 587 additions and 149 deletions
+112 -2
View File
@@ -198,18 +198,18 @@ class CareQueueBridgeTest extends TestCase
'queue_position' => 1,
]);
$this->actingAs($this->owner)
$response = $this->actingAs($this->owner)
->from(route('care.queue.index'))
->post(route('care.queue.call-next'), [
'branch_id' => $this->branch->id,
'practitioner_id' => $practitioner->id,
])
->assertRedirect(route('care.queue.index'))
->assertSessionHas('success');
$appointment = Appointment::query()->where('patient_id', $this->patient->id)->first();
$this->assertNotNull($appointment?->queue_ticket_uuid);
$this->assertSame('called', $appointment->queue_ticket_status);
$response->assertRedirect(route('care.appointments.show', $appointment));
$this->assertDatabaseHas('care_queue_tickets', [
'uuid' => $appointment->queue_ticket_uuid,
'status' => CareQueueTicket::STATUS_CALLED,
@@ -387,4 +387,114 @@ class CareQueueBridgeTest extends TestCase
]);
Http::assertNothingSent();
}
public function test_call_next_ends_current_session_and_opens_next_patient(): void
{
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. Advance',
'room' => 'Room 4',
'is_active' => true,
]);
$currentPatient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'P-CUR',
'first_name' => 'Current',
'last_name' => 'Patient',
'gender' => 'female',
'date_of_birth' => '1991-01-01',
]);
$currentVisit = \App\Models\Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $currentPatient->id,
'status' => \App\Models\Visit::STATUS_IN_PROGRESS,
'checked_in_at' => now(),
]);
$current = Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $currentPatient->id,
'practitioner_id' => $practitioner->id,
'visit_id' => $currentVisit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_IN_CONSULTATION,
'scheduled_at' => now()->subHour(),
'waiting_at' => now()->subHour(),
'checked_in_at' => now()->subHour(),
'started_at' => now()->subMinutes(30),
'queue_ticket_status' => 'serving',
]);
\App\Models\Consultation::create([
'owner_ref' => $this->owner->public_id,
'visit_id' => $currentVisit->id,
'appointment_id' => $current->id,
'practitioner_id' => $practitioner->id,
'patient_id' => $currentPatient->id,
'status' => \App\Models\Consultation::STATUS_DRAFT,
'started_at' => now()->subMinutes(30),
]);
$nextVisit = \App\Models\Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'status' => \App\Models\Visit::STATUS_OPEN,
'checked_in_at' => now(),
]);
$next = 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,
'visit_id' => $nextVisit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_WAITING,
'scheduled_at' => now(),
'waiting_at' => now(),
'checked_in_at' => now(),
'queue_position' => 1,
]);
app(\App\Services\Care\CareQueueBridge::class)->issueForAppointment(
$this->organization->fresh(),
$next->fresh(['patient', 'practitioner', 'organization']),
);
$response = $this->actingAs($this->owner)
->post(route('care.queue.call-next'), [
'branch_id' => $this->branch->id,
'practitioner_id' => $practitioner->id,
'appointment_id' => $current->id,
])
->assertSessionHas('success');
$this->assertSame(Appointment::STATUS_COMPLETED, $current->fresh()->status);
$this->assertSame(\App\Models\Consultation::STATUS_COMPLETED, $current->consultation->fresh()->status);
$next = $next->fresh();
$this->assertSame('called', $next->queue_ticket_status);
$response->assertRedirect(route('care.appointments.show', $next));
$this->actingAs($this->owner)
->get(route('care.appointments.show', $next))
->assertOk()
->assertSee('Call again');
Http::assertNothingSent();
}
}
+144
View File
@@ -291,4 +291,148 @@ class CareSpecialtyShellTest extends TestCase
]));
$this->assertSame(Appointment::STATUS_IN_CONSULTATION, $appointment->fresh()->status);
}
public function test_workspace_includes_timeline_tab_and_complete_action(): void
{
app(SpecialtyModuleService::class)->activate(
$this->organization,
$this->owner->public_id,
'dentistry',
);
$department = Department::query()
->where('branch_id', $this->branch->id)
->where('type', 'dental')
->firstOrFail();
$patient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'P-DEN-TL',
'first_name' => 'Afia',
'last_name' => 'Darko',
'gender' => 'female',
'date_of_birth' => '1992-01-01',
]);
$visit = Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $patient->id,
'status' => Visit::STATUS_IN_PROGRESS,
'checked_in_at' => now(),
]);
$appointment = Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $patient->id,
'department_id' => $department->id,
'visit_id' => $visit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_IN_CONSULTATION,
'scheduled_at' => now(),
'waiting_at' => now(),
'checked_in_at' => now(),
'started_at' => now(),
'queue_ticket_status' => 'serving',
]);
\App\Models\Consultation::create([
'owner_ref' => $this->owner->public_id,
'visit_id' => $visit->id,
'appointment_id' => $appointment->id,
'patient_id' => $patient->id,
'status' => \App\Models\Consultation::STATUS_DRAFT,
'started_at' => now(),
]);
$tabs = app(SpecialtyShellService::class)->workspaceTabs('dentistry');
$this->assertArrayHasKey('timeline', $tabs);
$this->assertSame(['overview', 'timeline'], array_slice(array_keys($tabs), 0, 2));
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'dentistry',
'visit' => $visit,
'tab' => 'timeline',
]))
->assertOk()
->assertSee('Timeline')
->assertSee('Patient timeline')
->assertSee('Complete consultation')
->assertDontSee('>Call again<', false);
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'dentistry',
'visit' => $visit,
'tab' => 'overview',
]))
->assertOk()
->assertDontSee('Patient timeline');
}
public function test_called_workspace_shows_call_again_until_session_starts(): void
{
app(SpecialtyModuleService::class)->activate(
$this->organization,
$this->owner->public_id,
'dentistry',
);
$department = Department::query()
->where('branch_id', $this->branch->id)
->where('type', 'dental')
->firstOrFail();
$patient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'P-DEN-CALL',
'first_name' => 'Kofi',
'last_name' => 'Mensah',
'gender' => 'male',
'date_of_birth' => '1988-01-01',
]);
$visit = Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $patient->id,
'status' => Visit::STATUS_OPEN,
'checked_in_at' => now(),
]);
Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $patient->id,
'department_id' => $department->id,
'visit_id' => $visit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_WAITING,
'scheduled_at' => now(),
'waiting_at' => now(),
'checked_in_at' => now(),
'queue_ticket_status' => 'called',
'queue_ticket_number' => 'DEN001',
]);
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'dentistry',
'visit' => $visit,
]))
->assertOk()
->assertSee('Call again')
->assertSee('Start')
->assertDontSee('Complete consultation');
}
}