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:
@@ -27,19 +27,34 @@ class PatientController extends Controller
|
||||
{
|
||||
$this->authorizeAbility($request, 'patients.view');
|
||||
$organization = $this->organization($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($this->member($request));
|
||||
$member = $this->member($request);
|
||||
$resolver = app(OrganizationResolver::class);
|
||||
$branchScope = $resolver->branchScope($member);
|
||||
$practitionerScope = $resolver->practitionerScope($organization, $member);
|
||||
|
||||
$patients = $this->patients->search(
|
||||
$this->ownerRef($request),
|
||||
$organization->id,
|
||||
$request->only(['q', 'patient_number', 'phone', 'national_id', 'date_of_birth']),
|
||||
$branchScope,
|
||||
$practitionerScope === null ? $branchScope : null,
|
||||
$practitionerScope,
|
||||
);
|
||||
|
||||
$owner = $this->ownerRef($request);
|
||||
$patientQuery = Patient::owned($owner)
|
||||
->where('organization_id', $organization->id)
|
||||
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope));
|
||||
->where('organization_id', $organization->id);
|
||||
if ($practitionerScope !== null) {
|
||||
if ($practitionerScope === []) {
|
||||
$patientQuery->whereRaw('1 = 0');
|
||||
} else {
|
||||
$patientQuery->whereHas(
|
||||
'appointments',
|
||||
fn ($q) => $q->whereIn('practitioner_id', $practitionerScope),
|
||||
);
|
||||
}
|
||||
} elseif ($branchScope) {
|
||||
$patientQuery->where('branch_id', $branchScope);
|
||||
}
|
||||
|
||||
$heroStats = [
|
||||
'total' => (clone $patientQuery)->count(),
|
||||
|
||||
Reference in New Issue
Block a user