Lock doctors to their assigned patients and hide branch filters.
Deploy Ladill Care / deploy (push) Successful in 1m2s

Doctors no longer see branch/practitioner pickers; queue, appointments, patients, and dashboard only include visits on their linked desk.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 06:28:07 +00:00
co-authored by Cursor
parent 5264035705
commit dcbc62d1d3
11 changed files with 361 additions and 89 deletions
+56 -7
View File
@@ -8,6 +8,7 @@ use App\Models\Branch;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Patient;
use App\Models\Practitioner;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@@ -16,7 +17,7 @@ class CareStaffTenantScopeTest extends TestCase
{
use RefreshDatabase;
public function test_staff_doctor_sees_employer_queue_and_patients(): void
public function test_staff_doctor_sees_only_assigned_patients_without_branch_filter(): void
{
$this->withoutMiddleware(EnsurePlatformSession::class);
@@ -59,7 +60,7 @@ class CareStaffTenantScopeTest extends TestCase
'is_active' => true,
]);
Member::create([
$doctorMember = Member::create([
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
'user_ref' => $doctor->public_id,
@@ -67,7 +68,25 @@ class CareStaffTenantScopeTest extends TestCase
'branch_id' => $branch->id,
]);
$patient = Patient::create([
$mine = Practitioner::create([
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
'branch_id' => $branch->id,
'member_id' => $doctorMember->id,
'user_ref' => $doctor->public_id,
'name' => 'Demo Pro Doctor',
'is_active' => true,
]);
$other = Practitioner::create([
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
'branch_id' => $branch->id,
'name' => 'Other Doctor',
'is_active' => true,
]);
$assignedPatient = Patient::create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
@@ -77,12 +96,23 @@ class CareStaffTenantScopeTest extends TestCase
'last_name' => 'Mensah',
]);
$otherPatient = Patient::create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
'branch_id' => $branch->id,
'patient_number' => 'DEMO-8883-00002',
'first_name' => 'Kofi',
'last_name' => 'Boateng',
]);
Appointment::create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
'branch_id' => $branch->id,
'patient_id' => $patient->id,
'patient_id' => $assignedPatient->id,
'practitioner_id' => $mine->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_WAITING,
'scheduled_at' => now(),
@@ -92,18 +122,37 @@ class CareStaffTenantScopeTest extends TestCase
'created_by' => $owner->public_id,
]);
Appointment::create([
'uuid' => (string) \Illuminate\Support\Str::uuid(),
'owner_ref' => $owner->public_id,
'organization_id' => $organization->id,
'branch_id' => $branch->id,
'patient_id' => $otherPatient->id,
'practitioner_id' => $other->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_WAITING,
'scheduled_at' => now(),
'waiting_at' => now(),
'queue_position' => 2,
'reason' => 'Fever',
'created_by' => $owner->public_id,
]);
$this->actingAs($doctor)
->get(route('care.queue.index'))
->assertOk()
->assertSee('East Legon Care')
->assertSee('Showing patients assigned to you')
->assertDontSee('All practitioners')
->assertDontSee('name="branch_id"', false)
->assertSee('Ama Mensah')
->assertSee('Toothache')
->assertDontSee('No patients waiting.');
->assertDontSee('Kofi Boateng')
->assertDontSee('Fever');
$this->actingAs($doctor)
->get(route('care.patients.index'))
->assertOk()
->assertSee('Ama Mensah')
->assertSee('DEMO-8883-00001');
->assertDontSee('Kofi Boateng');
}
}