Restrict specialty modules to doctors assigned to that specialty.
Deploy Ladill Care / deploy (push) Successful in 1m10s
Deploy Ladill Care / deploy (push) Successful in 1m10s
Nav and pages require a linked practitioner desk in the module department; demo seeds specialty doctors and stops overwriting their assigned waiters. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,16 +27,13 @@ class SpecialtyModuleController extends Controller
|
||||
abort_unless($definition, 404);
|
||||
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->isEnabled($organization, $module), 404);
|
||||
|
||||
$roles = $definition['roles'] ?? [];
|
||||
$member = $this->member($request);
|
||||
if (is_array($roles) && $roles !== [] && $member && ! in_array($member->role, $roles, true)) {
|
||||
abort(403);
|
||||
}
|
||||
abort_unless($modules->memberCanAccess($organization, $member, $module), 403);
|
||||
|
||||
$owner = $this->ownerRef($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
||||
$resolver = app(OrganizationResolver::class);
|
||||
$branchScope = $resolver->branchScope($member);
|
||||
$practitionerScope = $resolver->practitionerScope($organization, $member);
|
||||
|
||||
$departments = Department::owned($owner)
|
||||
->where('type', $definition['department_type'] ?? 'general')
|
||||
@@ -54,6 +51,10 @@ class SpecialtyModuleController extends Controller
|
||||
->when($departmentIds !== [], fn ($q) => $q->whereIn('department_id', $departmentIds))
|
||||
->when($departmentIds === [], fn ($q) => $q->whereRaw('1 = 0'))
|
||||
->when($branchScope, fn ($q) => $q->where('branch_id', $branchScope))
|
||||
->when(
|
||||
$practitionerScope !== null,
|
||||
fn ($q) => $q->whereIn('practitioner_id', $practitionerScope ?: [0]),
|
||||
)
|
||||
->with(['patient', 'practitioner', 'department'])
|
||||
->orderBy('queue_position')
|
||||
->orderBy('checked_in_at')
|
||||
@@ -61,6 +62,14 @@ class SpecialtyModuleController extends Controller
|
||||
->get();
|
||||
|
||||
$branchId = (int) ($branchScope ?: $departments->first()?->branch_id);
|
||||
if ($practitionerScope !== null && $practitionerScope !== []) {
|
||||
$pracBranch = (int) \App\Models\Practitioner::owned($owner)
|
||||
->whereKey($practitionerScope[0])
|
||||
->value('branch_id');
|
||||
if ($pracBranch > 0) {
|
||||
$branchId = $pracBranch;
|
||||
}
|
||||
}
|
||||
|
||||
return view('care.specialty.show', [
|
||||
'organization' => $organization,
|
||||
@@ -86,15 +95,30 @@ class SpecialtyModuleController extends Controller
|
||||
abort_unless($definition, 404);
|
||||
|
||||
$organization = $this->organization($request);
|
||||
abort_unless($modules->isEnabled($organization, $module), 404);
|
||||
$member = $this->member($request);
|
||||
abort_unless($modules->memberCanAccess($organization, $member, $module), 403);
|
||||
abort_unless($queueBridge->isEnabled($organization), 404);
|
||||
|
||||
$member = $this->member($request);
|
||||
$branchScope = app(OrganizationResolver::class)->branchScope($member);
|
||||
$resolver = app(OrganizationResolver::class);
|
||||
$branchScope = $resolver->branchScope($member);
|
||||
$practitionerScope = $resolver->practitionerScope($organization, $member);
|
||||
$branchId = (int) ($request->input('branch_id') ?: $branchScope);
|
||||
$practitionerId = null;
|
||||
|
||||
if ($practitionerScope !== null) {
|
||||
abort_unless($practitionerScope !== [], 422);
|
||||
$practitionerId = $practitionerScope[0];
|
||||
$pracBranch = (int) \App\Models\Practitioner::owned($this->ownerRef($request))
|
||||
->whereKey($practitionerId)
|
||||
->value('branch_id');
|
||||
if ($pracBranch > 0) {
|
||||
$branchId = $pracBranch;
|
||||
}
|
||||
}
|
||||
|
||||
abort_unless($branchId > 0, 422);
|
||||
|
||||
$result = $queueBridge->callNext($organization, $module, $branchId);
|
||||
$result = $queueBridge->callNext($organization, $module, $branchId, $member, $practitionerId);
|
||||
$ticket = $result['ticket'] ?? null;
|
||||
if (! $ticket) {
|
||||
return back()->with('info', 'No patients waiting in this specialty queue.');
|
||||
|
||||
Reference in New Issue
Block a user