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
+19 -2
View File
@@ -30,9 +30,15 @@ class PatientService
/**
* @param array<string, mixed> $filters
* @param list<int>|null $practitionerIds When set, only patients with appointments on these desks.
*/
public function search(string $ownerRef, int $organizationId, array $filters = [], ?int $branchId = null): LengthAwarePaginator
{
public function search(
string $ownerRef,
int $organizationId,
array $filters = [],
?int $branchId = null,
?array $practitionerIds = null,
): LengthAwarePaginator {
$query = $this->queryForOrganization($ownerRef, $organizationId)
->with(['branch'])
->orderByDesc('created_at');
@@ -41,6 +47,17 @@ class PatientService
$query->where('branch_id', $branchId);
}
if ($practitionerIds !== null) {
if ($practitionerIds === []) {
$query->whereRaw('1 = 0');
} else {
$query->whereHas(
'appointments',
fn (Builder $inner) => $inner->whereIn('practitioner_id', $practitionerIds),
);
}
}
if ($q = trim((string) ($filters['q'] ?? ''))) {
$query->where(function (Builder $inner) use ($q) {
$inner->where('patient_number', 'like', "%{$q}%")