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
@@ -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');