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
@@ -10,6 +10,7 @@ use App\Models\PatientAttachment;
use App\Models\Visit;
use App\Services\Care\AppointmentService;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueSessionAdvance;
use App\Services\Care\ConsultationService;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\SpecialtyClinicalRecordService;
@@ -309,12 +310,14 @@ class SpecialtyModuleController extends Controller
string $module,
SpecialtyModuleService $modules,
CareQueueBridge $queueBridge,
CareQueueSessionAdvance $advance,
): RedirectResponse {
$definition = $modules->definition($module);
abort_unless($definition, 404);
$organization = $this->organization($request);
$member = $this->member($request);
$owner = $this->ownerRef($request);
abort_unless($modules->memberCanAccess($organization, $member, $module), 403);
abort_unless($queueBridge->isEnabled($organization), 404);
@@ -327,7 +330,7 @@ class SpecialtyModuleController extends Controller
if ($practitionerScope !== null) {
abort_unless($practitionerScope !== [], 422);
$practitionerId = $practitionerScope[0];
$pracBranch = (int) \App\Models\Practitioner::owned($this->ownerRef($request))
$pracBranch = (int) \App\Models\Practitioner::owned($owner)
->whereKey($practitionerId)
->value('branch_id');
if ($pracBranch > 0) {
@@ -337,10 +340,16 @@ class SpecialtyModuleController extends Controller
abort_unless($branchId > 0, 422);
if ($request->filled('appointment_id')) {
$current = Appointment::owned($owner)
->where('organization_id', $organization->id)
->findOrFail((int) $request->input('appointment_id'));
$advance->endCurrentEncounter($current, $owner, $owner);
}
$result = $queueBridge->callNext($organization, $module, $branchId, $member, $practitionerId);
$ticket = $result['ticket'] ?? null;
if (! $ticket) {
$owner = $this->ownerRef($request);
$departmentIds = Department::owned($owner)
->where('type', $definition['department_type'] ?? 'general')
->where('is_active', true)
@@ -381,6 +390,15 @@ class SpecialtyModuleController extends Controller
return back()->with('info', 'No patients waiting in this queue.');
}
$entity = $result['entity'] ?? null;
if ($entity instanceof Appointment) {
return $advance->redirectToOpenedPatient(
$entity,
$ticket,
'care.queue.index',
);
}
$name = $ticket['customer_name'] ?? 'patient';
return back()->with('success', 'Called '.$ticket['ticket_number'].' — '.$name.'.');