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
@@ -367,6 +367,53 @@ class CareAssessmentCaptureTest extends TestCase
->assertOk();
}
public function test_consultation_assessments_allow_patient_home_branch_mismatch(): void
{
$this->setMemberRole('doctor');
$homeBranch = Branch::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'name' => 'Home Branch',
'code' => 'HOME',
'is_active' => true,
]);
$this->patient->update(['branch_id' => $homeBranch->id]);
$visit = Visit::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'status' => Visit::STATUS_OPEN,
'checked_in_at' => now(),
]);
$consultation = Consultation::create([
'owner_ref' => $this->user->public_id,
'visit_id' => $visit->id,
'patient_id' => $this->patient->id,
'status' => Consultation::STATUS_DRAFT,
'started_at' => now(),
]);
$this->assertNotSame($homeBranch->id, $this->branch->id);
$this->actingAs($this->user)
->get(route('care.consultations.assessments.index', $consultation))
->assertOk();
$this->actingAs($this->user)
->post(route('care.consultations.assessments.store', $consultation), [
'template_code' => 'universal_intake',
])
->assertRedirect();
$assessment = Assessment::first();
$this->assertNotNull($assessment);
$this->assertSame($this->branch->id, $assessment->branch_id);
}
public function test_consultation_scoped_start_links_consultation_and_visit(): void
{
$this->setMemberRole('doctor');