Hide Specialty sidebar group for desk specialists.
Deploy Ladill Care / deploy (push) Successful in 2m34s
Deploy Ladill Care / deploy (push) Successful in 2m34s
Single-desk specialists already reach their workspace via dashboard cards; the Specialty → Dentistry nav group was redundant. GPs and multi-module roles keep the section. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -180,6 +180,32 @@ class SpecialtyModuleService
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the sidebar should show the Specialty nav group.
|
||||
*
|
||||
* Desk specialists only receive their own matching module(s), so a
|
||||
* Specialty → Dentistry (etc.) group is redundant — they use dashboard
|
||||
* cards / direct routes instead. GPs, nurses, and other multi-module
|
||||
* roles keep the group for referral and cross-module access.
|
||||
*/
|
||||
public function shouldShowSpecialtyNav(Organization $organization, ?Member $member): bool
|
||||
{
|
||||
if (! $member) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$modules = $this->enabledModulesForMember($organization, $member);
|
||||
if ($modules === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isDeskSpecialist($organization, $member)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 'general'|'limited'|'restricted'
|
||||
*/
|
||||
|
||||
@@ -78,12 +78,14 @@
|
||||
}
|
||||
|
||||
// Specialty modules — role-gated clinical surfaces for floor staff.
|
||||
// Desk specialists skip this group (redundant single-desk list); dashboard cards remain.
|
||||
if ($permissions->handlesFloorCare($member) && $organization) {
|
||||
$specialtyService = app(\App\Services\Care\SpecialtyModuleService::class);
|
||||
$specialtyService->ensureDefaultModulesProvisioned(
|
||||
$organization,
|
||||
(string) $organization->owner_ref,
|
||||
);
|
||||
if ($specialtyService->shouldShowSpecialtyNav($organization, $member)) {
|
||||
foreach ($specialtyService->enabledModulesForMember($organization, $member) as $item) {
|
||||
$key = $item['key'];
|
||||
$label = $item['definition']['nav_label'] ?? $item['definition']['label'] ?? $key;
|
||||
@@ -97,6 +99,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$adminNav = [];
|
||||
if (! empty($hasPaidPlan) && $permissions->can($member, 'lab.catalog.manage')) {
|
||||
|
||||
@@ -189,15 +189,45 @@ class CareSpecialtyAccessTest extends TestCase
|
||||
$this->assertNotContains('blood_bank', $enabledKeys);
|
||||
$this->assertNotContains('cardiology', $enabledKeys);
|
||||
|
||||
// Single-desk specialists: no Specialty sidebar group (dashboard cards remain).
|
||||
$this->assertFalse($this->modules->shouldShowSpecialtyNav($this->organization, $member));
|
||||
|
||||
$this->actingAs($doctor)
|
||||
->get(route('care.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Dentistry')
|
||||
->assertSee('Specialty modules')
|
||||
->assertDontSee('>Specialty</p>', false)
|
||||
->assertDontSee('Emergency')
|
||||
->assertDontSee('Cardiology')
|
||||
->assertDontSee('Blood Bank');
|
||||
}
|
||||
|
||||
public function test_gp_keeps_specialty_sidebar_nav(): void
|
||||
{
|
||||
[$doctor, $member] = $this->makeStaff('doctor', 'gp-nav');
|
||||
Practitioner::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'member_id' => $member->id,
|
||||
'user_ref' => $doctor->public_id,
|
||||
'name' => 'Dr GP Nav',
|
||||
'specialty' => 'General Practice',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->assertFalse($this->modules->isDeskSpecialist($this->organization, $member));
|
||||
$this->assertTrue($this->modules->shouldShowSpecialtyNav($this->organization, $member));
|
||||
|
||||
$this->actingAs($doctor)
|
||||
->get(route('care.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('>Specialty</p>', false)
|
||||
->assertSee('Emergency')
|
||||
->assertSee('Dentistry');
|
||||
}
|
||||
|
||||
public function test_dentistry_specialty_does_not_match_ent_keyword(): void
|
||||
{
|
||||
[$doctor, $member] = $this->makeStaff('doctor', 'dentist-ent-trap');
|
||||
@@ -340,10 +370,12 @@ class CareSpecialtyAccessTest extends TestCase
|
||||
$this->assertContains('infusion', $enabledForMember);
|
||||
$this->assertNotContains('cardiology', $enabledForMember);
|
||||
$this->assertNotContains('dentistry', $enabledForMember);
|
||||
$this->assertTrue($this->modules->shouldShowSpecialtyNav($this->organization, $pharmacistMember));
|
||||
|
||||
$this->actingAs($pharmacistUser)
|
||||
->get(route('care.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('>Specialty</p>', false)
|
||||
->assertSee('Emergency')
|
||||
->assertDontSee('Cardiology');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user