Wire Care lists into Ladill Queue workflows instead of reception panels.
Deploy Ladill Care / deploy (push) Successful in 1m45s

When Queue integration is on, role pages issue tickets into their own
department queues and drive Call next → Serve → Complete on the native
lists. Integration off leaves existing UI unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 16:27:48 +00:00
co-authored by Cursor
parent 15638d1672
commit 015a4cc7fe
38 changed files with 1857 additions and 196 deletions
@@ -11,7 +11,6 @@ use App\Models\Patient;
use App\Models\Practitioner;
use App\Services\Care\AppointmentService;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\ServiceQueuePresenter;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -22,7 +21,6 @@ class AppointmentController extends Controller
public function __construct(
protected AppointmentService $appointments,
protected ServiceQueuePresenter $serviceQueues,
) {}
public function index(Request $request): View
@@ -61,13 +59,6 @@ class AppointmentController extends Controller
'practitioners' => $practitioners,
'statuses' => config('care.appointment_statuses'),
'heroStats' => $heroStats,
'serviceQueuePanel' => $this->serviceQueues->panel(
$request,
$organization,
$member,
'clinical',
$request->input('counter_uuid'),
),
]);
}
+51 -1
View File
@@ -7,6 +7,8 @@ use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Models\Bill;
use App\Models\Visit;
use App\Services\Care\BillService;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
use App\Services\Care\OrganizationResolver;
use App\Services\Payments\MerchantGatewayService;
use Illuminate\Http\RedirectResponse;
@@ -21,13 +23,15 @@ class BillController extends Controller
public function __construct(
protected BillService $bills,
protected MerchantGatewayService $gateway,
protected CareQueueBridge $queueBridge,
) {}
public function index(Request $request): View
{
$this->authorizeAbility($request, 'bills.view');
$organization = $this->organization($request);
$branchScope = app(OrganizationResolver::class)->branchScope($this->member($request));
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$bills = $this->bills->list(
$this->ownerRef($request),
@@ -36,13 +40,59 @@ class BillController extends Controller
$branchScope,
);
$branchId = (int) ($branchScope ?: \App\Models\Branch::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
->where('is_active', true)
->orderBy('name')
->value('id'));
return view('care.bills.index', [
'organization' => $organization,
'bills' => $bills,
'statuses' => config('care.bill_statuses'),
'branchId' => $branchId,
'queueIntegration' => $branchId
? $this->queueBridge->listMeta($organization, CareQueueContexts::BILLING, $branchId)
: ['enabled' => false],
'canManageQueue' => app(\App\Services\Care\CarePermissions::class)
->can($member, 'service_queues.console'),
]);
}
public function callNext(Request $request): RedirectResponse
{
$this->authorizeAbility($request, 'bills.manage');
$organization = $this->organization($request);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
abort_unless($branchId > 0, 422);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$result = $this->queueBridge->callNext($organization, CareQueueContexts::BILLING, $branchId);
$ticket = $result['ticket'] ?? null;
if (! $ticket) {
return back()->with('error', 'No bills waiting in the billing queue.');
}
return back()->with('success', 'Called '.$ticket['ticket_number'].'.');
}
public function serve(Request $request, Bill $bill): RedirectResponse
{
$this->authorizeAbility($request, 'bills.manage');
$this->authorizeBill($request, $bill);
$organization = $this->organization($request);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$ticket = $this->queueBridge->serve($organization, $bill);
if (! $ticket) {
return back()->with('error', 'Could not serve billing ticket.');
}
return back()->with('success', 'Now serving '.$ticket['ticket_number'].'.');
}
public function generate(Request $request, Visit $visit): RedirectResponse
{
$this->authorizeAbility($request, 'bills.manage');
@@ -12,7 +12,6 @@ use App\Services\Care\AppointmentService;
use App\Services\Care\CarePermissions;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\ReportService;
use App\Services\Care\ServiceQueuePresenter;
use App\Services\Care\SpecialtyModuleService;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
@@ -26,7 +25,6 @@ class DashboardController extends Controller
protected ReportService $reports,
protected CarePermissions $permissions,
protected AppointmentService $appointments,
protected ServiceQueuePresenter $serviceQueues,
protected SpecialtyModuleService $specialtyModules,
) {}
@@ -80,12 +78,6 @@ class DashboardController extends Controller
? $this->patientQueueForMember($request, $organization->id, $owner, $member, $branchScope)
: [collect(), collect(), null];
$serviceQueueContext = match ($member?->role) {
'pharmacist' => 'pharmacy',
'lab_technician' => 'laboratory',
default => 'clinical',
};
return view('care.dashboard', [
'organization' => $organization,
'member' => $member,
@@ -103,13 +95,6 @@ class DashboardController extends Controller
'patientQueue' => $queue,
'inConsultation' => $inConsultation,
'practitionerId' => $practitionerId,
'serviceQueuePanel' => $this->serviceQueues->panel(
$request,
$organization,
$member,
$serviceQueueContext,
$request->input('counter_uuid'),
),
'specialtyModules' => $this->specialtyModules->enabledModules($organization),
]);
}
@@ -9,9 +9,10 @@ use App\Models\Consultation;
use App\Models\InvestigationRequest;
use App\Models\InvestigationType;
use App\Models\Member;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
use App\Services\Care\InvestigationService;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\ServiceQueuePresenter;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -22,7 +23,7 @@ class InvestigationController extends Controller
public function __construct(
protected InvestigationService $investigations,
protected ServiceQueuePresenter $serviceQueues,
protected CareQueueBridge $queueBridge,
) {}
public function index(Request $request): View
@@ -76,16 +77,46 @@ class InvestigationController extends Controller
->where('organization_id', $organization->id)
->orderBy('role')
->get(),
'serviceQueuePanel' => $this->serviceQueues->panel(
$request,
$organization,
$this->member($request),
'laboratory',
$request->input('counter_uuid'),
),
'queueIntegration' => $branchId
? $this->queueBridge->listMeta($organization, CareQueueContexts::LABORATORY, $branchId)
: ['enabled' => false],
]);
}
public function callNext(Request $request): RedirectResponse
{
$this->authorizeAbility($request, 'lab.manage');
$organization = $this->organization($request);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
abort_unless($branchId > 0, 422);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$result = $this->queueBridge->callNext($organization, CareQueueContexts::LABORATORY, $branchId);
$ticket = $result['ticket'] ?? null;
if (! $ticket) {
return back()->with('error', 'No lab work waiting in the laboratory queue.');
}
return back()->with('success', 'Called '.$ticket['ticket_number'].'.');
}
public function serve(Request $request, InvestigationRequest $investigation): RedirectResponse
{
$this->authorizeAbility($request, 'lab.manage');
$this->authorizeInvestigation($request, $investigation);
$organization = $this->organization($request);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$ticket = $this->queueBridge->serve($organization, $investigation);
if (! $ticket) {
return back()->with('error', 'Could not serve lab ticket.');
}
return back()->with('success', 'Now serving '.$ticket['ticket_number'].'.');
}
public function requestFromConsultation(Request $request, Consultation $consultation): RedirectResponse
{
$this->authorizeAbility($request, 'investigations.request');
@@ -7,10 +7,11 @@ use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Models\Consultation;
use App\Models\Prescription;
use App\Models\Practitioner;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\PharmacyService;
use App\Services\Care\PrescriptionService;
use App\Services\Care\ServiceQueuePresenter;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -22,7 +23,7 @@ class PrescriptionController extends Controller
public function __construct(
protected PrescriptionService $prescriptions,
protected PharmacyService $pharmacy,
protected ServiceQueuePresenter $serviceQueues,
protected CareQueueBridge $queueBridge,
) {}
public function index(Request $request): View
@@ -49,8 +50,18 @@ class PrescriptionController extends Controller
{
$this->authorizeAbility($request, 'prescriptions.view');
$organization = $this->organization($request);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branchId = (int) ($branchScope ?: \App\Models\Branch::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
->where('is_active', true)
->orderBy('name')
->value('id'));
$queue = $this->prescriptions->pharmacyQueue($this->ownerRef($request), $organization->id);
if ($branchScope) {
$queue = $queue->filter(fn (Prescription $rx) => (int) ($rx->visit?->branch_id) === $branchScope)->values();
}
$drugs = \App\Models\Drug::owned($this->ownerRef($request))
->where('organization_id', $organization->id)
@@ -60,23 +71,54 @@ class PrescriptionController extends Controller
->get();
$canDispense = app(\App\Services\Care\CarePermissions::class)
->can($this->member($request), 'prescriptions.dispense');
->can($member, 'prescriptions.dispense');
return view('care.prescriptions.queue', [
'organization' => $organization,
'queue' => $queue,
'drugs' => $drugs,
'canDispense' => $canDispense,
'serviceQueuePanel' => $this->serviceQueues->panel(
$request,
$organization,
$this->member($request),
'pharmacy',
$request->input('counter_uuid'),
),
'branchId' => $branchId,
'queueIntegration' => $branchId
? $this->queueBridge->listMeta($organization, CareQueueContexts::PHARMACY, $branchId)
: ['enabled' => false],
]);
}
public function callNext(Request $request): RedirectResponse
{
$this->authorizeAbility($request, 'prescriptions.dispense');
$organization = $this->organization($request);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
abort_unless($branchId > 0, 422);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$result = $this->queueBridge->callNext($organization, CareQueueContexts::PHARMACY, $branchId);
$ticket = $result['ticket'] ?? null;
if (! $ticket) {
return back()->with('error', 'No prescriptions waiting in the pharmacy queue.');
}
return back()->with('success', 'Called '.$ticket['ticket_number'].'.');
}
public function serve(Request $request, Prescription $prescription): RedirectResponse
{
$this->authorizeAbility($request, 'prescriptions.dispense');
$this->authorizePrescription($request, $prescription);
$organization = $this->organization($request);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$ticket = $this->queueBridge->serve($organization, $prescription);
if (! $ticket) {
return back()->with('error', 'Could not serve pharmacy ticket.');
}
return back()->with('success', 'Now serving '.$ticket['ticket_number'].'.');
}
public function create(Request $request, Consultation $consultation): View
{
$this->authorizeAbility($request, 'prescriptions.manage');
+41 -9
View File
@@ -8,9 +8,10 @@ use App\Models\Appointment;
use App\Models\Branch;
use App\Models\Practitioner;
use App\Services\Care\AppointmentService;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
use App\Services\Care\ConsultationService;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\ServiceQueuePresenter;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -22,7 +23,7 @@ class QueueController extends Controller
public function __construct(
protected AppointmentService $appointments,
protected ConsultationService $consultations,
protected ServiceQueuePresenter $serviceQueues,
protected CareQueueBridge $queueBridge,
) {}
public function index(Request $request): View
@@ -85,16 +86,47 @@ class QueueController extends Controller
'canManageQueue' => $canManageQueue,
'canConsult' => $canConsult,
'heroStats' => $heroStats,
'serviceQueuePanel' => $this->serviceQueues->panel(
$request,
$organization,
$member,
'clinical',
$request->input('counter_uuid'),
),
'queueIntegration' => $branchId
? $this->queueBridge->listMeta($organization, CareQueueContexts::CONSULTATION, $branchId)
: ['enabled' => false],
]);
}
public function callNext(Request $request): RedirectResponse
{
$this->authorizeAbility($request, 'appointments.view');
$organization = $this->organization($request);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
abort_unless($branchId > 0, 422);
$result = $this->queueBridge->callNext($organization, CareQueueContexts::CONSULTATION, $branchId);
$ticket = $result['ticket'] ?? null;
if (! $ticket) {
return back()->with('error', 'No patients waiting in the consultation queue.');
}
return back()->with('success', 'Called '.$ticket['ticket_number'].' — '.($ticket['customer_name'] ?? 'patient').'.');
}
public function completeTicket(Request $request, Appointment $appointment): RedirectResponse
{
$this->authorizeAbility($request, 'consultations.manage');
$this->authorizeAppointment($request, $appointment);
$organization = $this->organization($request);
abort_unless($this->queueBridge->isEnabled($organization), 404);
$ticket = $this->queueBridge->complete($organization, $appointment);
if (! $ticket) {
return back()->with('error', 'Could not complete queue ticket.');
}
return back()->with('success', 'Completed '.$ticket['ticket_number'].'.');
}
public function start(Request $request, Appointment $appointment): RedirectResponse
{
$this->authorizeAbility($request, 'consultations.manage');
@@ -9,6 +9,7 @@ use App\Services\Care\AppointmentPatientNotifier;
use App\Services\Care\AuditLogger;
use App\Services\Care\CareFeatures;
use App\Services\Care\CarePermissions;
use App\Services\Care\CareQueueProvisioner;
use App\Services\Care\PlanService;
use App\Services\Billing\PlatformEmailClient;
use App\Services\Billing\PlatformSmsClient;
@@ -75,7 +76,7 @@ class SettingsController extends Controller
]);
}
public function update(Request $request, QueueClient $queue): RedirectResponse
public function update(Request $request, QueueClient $queue, CareQueueProvisioner $provisioner): RedirectResponse
{
$this->authorizeAbility($request, 'settings.manage');
$organization = $this->organization($request);
@@ -152,6 +153,14 @@ class SettingsController extends Controller
'settings' => $settings,
]);
if ($wantsQueue && $queue->configured()) {
try {
$provisioner->provisionOrganization($organization->fresh());
} catch (\Throwable) {
// Best-effort; role pages will lazy-ensure on next use.
}
}
AuditLogger::record($owner, 'organization.updated', $organization->id, $owner, \App\Models\Organization::class, $organization->id);
return back()->with('success', 'Settings saved.');
@@ -6,9 +6,10 @@ use App\Http\Controllers\Controller;
use App\Http\Controllers\Care\Concerns\ScopesToAccount;
use App\Models\Appointment;
use App\Models\Department;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\OrganizationResolver;
use App\Services\Care\ServiceQueuePresenter;
use App\Services\Care\SpecialtyModuleService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
@@ -20,7 +21,7 @@ class SpecialtyModuleController extends Controller
Request $request,
string $module,
SpecialtyModuleService $modules,
ServiceQueuePresenter $presenter,
CareQueueBridge $queueBridge,
): View {
$definition = $modules->definition($module);
abort_unless($definition, 404);
@@ -59,13 +60,7 @@ class SpecialtyModuleController extends Controller
->limit(25)
->get();
$serviceQueuePanel = $presenter->panel(
$request,
$organization,
$member,
$module,
$request->input('counter_uuid'),
);
$branchId = (int) ($branchScope ?: $departments->first()?->branch_id);
return view('care.specialty.show', [
'organization' => $organization,
@@ -74,7 +69,37 @@ class SpecialtyModuleController extends Controller
'departments' => $departments,
'waiting' => $waiting,
'queueStubs' => $modules->queueStubsFor($organization, $module),
'serviceQueuePanel' => $serviceQueuePanel,
'branchId' => $branchId,
'queueIntegration' => $branchId
? $queueBridge->listMeta($organization, $module, $branchId)
: ['enabled' => false],
]);
}
public function callNext(
Request $request,
string $module,
SpecialtyModuleService $modules,
CareQueueBridge $queueBridge,
): RedirectResponse {
$definition = $modules->definition($module);
abort_unless($definition, 404);
$organization = $this->organization($request);
abort_unless($modules->isEnabled($organization, $module), 404);
abort_unless($queueBridge->isEnabled($organization), 404);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
abort_unless($branchId > 0, 422);
$result = $queueBridge->callNext($organization, $module, $branchId);
$ticket = $result['ticket'] ?? null;
if (! $ticket) {
return back()->with('error', 'No patients waiting in this specialty queue.');
}
return back()->with('success', 'Called '.$ticket['ticket_number'].'.');
}
}