Allow consultation assessments when patient home branch differs.
Deploy Ladill Care / deploy (push) Successful in 40s

Doctors scoped to the visit branch were getting app 404s on nested
assessment routes because authorizePatient compared the patient's home
branch, unlike consultation/prescription auth which uses the visit.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 21:26:58 +00:00
co-authored by Cursor
parent 3854fc6471
commit 847d63c1c2
2 changed files with 59 additions and 0 deletions
@@ -72,6 +72,10 @@ class AssessmentController extends Controller
$return->remember($consultation);
$request->query->set(ConsultationReturnContext::QUERY_KEY, $consultation->uuid);
// Visit branch may differ from the patient's home branch; consultation
// auth already enforced visit-branch scope (same as prescriptions).
$request->attributes->set('care.assessments.skip_patient_branch', true);
return $this->index($request, $consultation->patient);
}
@@ -92,6 +96,8 @@ class AssessmentController extends Controller
}
$request->query->set(ConsultationReturnContext::QUERY_KEY, $consultation->uuid);
$request->attributes->set('care.assessments.skip_patient_branch', true);
return $this->create($request, $consultation->patient);
}
@@ -200,6 +206,8 @@ class AssessmentController extends Controller
]);
$consultation->loadMissing(['patient', 'visit']);
// Org/owner only — branch was checked via authorizeConsultation (visit).
$request->attributes->set('care.assessments.skip_patient_branch', true);
$this->authorizePatient($request, $consultation->patient);
$assessment = $this->assessments->start(
@@ -430,6 +438,10 @@ class AssessmentController extends Controller
$this->authorizeOwner($request, $patient);
abort_unless($patient->organization_id === $this->organization($request)->id, 404);
if ($request->attributes->get('care.assessments.skip_patient_branch')) {
return;
}
$branchId = app(OrganizationResolver::class)->branchScope($this->member($request));
if ($branchId !== null && $patient->branch_id !== $branchId) {
abort(404);