Lock doctors to their assigned patients and hide branch filters.
Deploy Ladill Care / deploy (push) Successful in 1m2s

Doctors no longer see branch/practitioner pickers; queue, appointments, patients, and dashboard only include visits on their linked desk.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 06:28:07 +00:00
co-authored by Cursor
parent 5264035705
commit dcbc62d1d3
11 changed files with 361 additions and 89 deletions
@@ -34,21 +34,35 @@ class AppointmentController extends Controller
$this->authorizeAbility($request, 'appointments.view');
$organization = $this->organization($request);
$member = $this->member($request);
$branchScope = app(OrganizationResolver::class)->branchScope($member);
$resolver = app(OrganizationResolver::class);
$branchScope = $resolver->branchScope($member);
$practitionerScope = $resolver->practitionerScope($organization, $member);
$filters = $request->only(['status', 'practitioner_id', 'date', 'patient_id']);
if ($practitionerScope !== null) {
unset($filters['practitioner_id']);
}
$appointments = $this->appointments->list(
$this->ownerRef($request),
$organization->id,
$request->only(['status', 'practitioner_id', 'date', 'patient_id']),
$branchScope,
$filters,
$practitionerScope === null ? $branchScope : null,
$practitionerScope,
);
$practitioners = $this->activePractitioners($request, $organization->id);
$practitioners = $practitionerScope === null
? $this->activePractitioners($request, $organization->id)
: collect();
$owner = $this->ownerRef($request);
$appointmentQuery = Appointment::owned($owner)
->where('organization_id', $organization->id)
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope));
->where('organization_id', $organization->id);
if ($practitionerScope !== null) {
$appointmentQuery->whereIn('practitioner_id', $practitionerScope ?: [0]);
} elseif ($branchScope) {
$appointmentQuery->where('branch_id', $branchScope);
}
$heroStats = [
'today' => (clone $appointmentQuery)->whereDate('scheduled_at', today())->count(),
@@ -63,6 +77,7 @@ class AppointmentController extends Controller
'organization' => $organization,
'appointments' => $appointments,
'practitioners' => $practitioners,
'lockToPractitioner' => $practitionerScope !== null,
'statuses' => config('care.appointment_statuses'),
'heroStats' => $heroStats,
]);