Restrict specialty modules to doctors assigned to that specialty.
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:
isaacclad
2026-07-18 08:37:06 +00:00
co-authored by Cursor
parent dcbc62d1d3
commit bb4dbee81a
7 changed files with 285 additions and 20 deletions
@@ -268,4 +268,78 @@ class CareSpecialtyModulesTest extends TestCase
->assertSee('Dentistry')
->assertSee('Departments');
}
public function test_unassigned_doctor_cannot_open_specialty_module(): void
{
Http::fake();
app(SpecialtyModuleService::class)->activate($this->organization, $this->owner->public_id, 'dentistry');
$doctor = User::create([
'public_id' => 'unassigned-doc',
'name' => 'General Doctor',
'email' => 'general-doc@example.com',
]);
Member::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $doctor->public_id,
'role' => 'doctor',
'branch_id' => $this->branch->id,
]);
$this->actingAs($doctor)
->get(route('care.specialty.show', 'dentistry'))
->assertForbidden();
}
public function test_assigned_specialty_doctor_can_open_module(): void
{
Http::fake();
app(SpecialtyModuleService::class)->activate($this->organization, $this->owner->public_id, 'dentistry');
$department = Department::query()->where('type', 'dental')->firstOrFail();
$doctor = User::create([
'public_id' => 'dental-doc',
'name' => 'Dental Doctor',
'email' => 'dental-doc@example.com',
]);
$member = Member::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $doctor->public_id,
'role' => 'doctor',
'branch_id' => $this->branch->id,
]);
\App\Models\Practitioner::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'department_id' => $department->id,
'member_id' => $member->id,
'user_ref' => $doctor->public_id,
'name' => 'Dental Doctor',
'specialty' => 'Dentistry',
'is_active' => true,
]);
$this->actingAs($doctor)
->get(route('care.specialty.show', 'dentistry'))
->assertOk()
->assertSee('Dentistry');
$this->assertTrue(
app(SpecialtyModuleService::class)->memberCanAccess(
$this->organization->fresh(),
$member,
'dentistry',
),
);
$this->assertFalse(
app(SpecialtyModuleService::class)->memberCanAccess(
$this->organization->fresh(),
$member,
'maternity',
),
);
}
}