Lock doctors to their assigned patients and hide branch filters.
Deploy Ladill Care / deploy (push) Successful in 1m2s
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:
@@ -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}%")
|
||||
|
||||
Reference in New Issue
Block a user