Persist admin branch filter across Patient, Pharmacy, Lab, and Bills queues.
Deploy Ladill Care / deploy (push) Successful in 57s

Admins pick a working branch once; session keeps Pharmacy Call Next and lists scoped to that site so ticket numbers no longer collide across branches.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 05:49:24 +00:00
co-authored by Cursor
parent 88f84a4f96
commit 6cfecc1763
9 changed files with 365 additions and 55 deletions
+8 -10
View File
@@ -8,6 +8,7 @@ use App\Models\Bill;
use App\Models\Consultation;
use App\Models\Visit;
use App\Services\Care\BillService;
use App\Services\Care\BranchContext;
use App\Services\Care\CareQueueBridge;
use App\Services\Care\CareQueueContexts;
use App\Services\Care\ConsultationReturnContext;
@@ -26,6 +27,7 @@ class BillController extends Controller
protected BillService $bills,
protected MerchantGatewayService $gateway,
protected CareQueueBridge $queueBridge,
protected BranchContext $branchContext,
) {}
public function index(Request $request): View
@@ -33,26 +35,23 @@ class BillController extends Controller
$this->authorizeAbility($request, 'bills.view');
$organization = $this->organization($request);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$branches = $this->branchContext->branches($request, $organization, $member);
$branchId = $this->branchContext->resolve($request, $organization, $member);
$bills = $this->bills->list(
$this->ownerRef($request),
$organization->id,
$request->only(['status', 'patient_id']),
$branchScope,
$branchId > 0 ? $branchId : null,
);
$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'),
'branches' => $branches,
'branchId' => $branchId,
'canSwitchBranch' => $this->branchContext->canSwitch($member),
'queueIntegration' => $branchId
? $this->queueBridge->listMeta($organization, CareQueueContexts::BILLING, $branchId)
: ['enabled' => false],
@@ -66,8 +65,7 @@ class BillController extends Controller
$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);
$branchId = $this->branchContext->resolve($request, $organization, $member);
abort_unless($branchId > 0, 422);
abort_unless($this->queueBridge->isEnabled($organization), 404);