Gate Queue to doctors and land specialty modules on list indexes.
Deploy Ladill Care / deploy (push) Successful in 34s
Deploy Ladill Care / deploy (push) Successful in 34s
Hide the patient-flow Queue board from nurses, reception, and other non-doctors; specialty home routes now render the queue board list instead of auto-opening the first open visit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,11 +3,16 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Department;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Patient;
|
||||
use App\Models\User;
|
||||
use App\Models\Visit;
|
||||
use App\Services\Care\CarePermissions;
|
||||
use App\Services\Care\SpecialtyModuleService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -100,15 +105,36 @@ class CarePatientQueueAccessTest extends TestCase
|
||||
->assertDontSee('href="'.e(route('care.queue.index')).'"', false);
|
||||
}
|
||||
|
||||
public function test_doctor_and_receptionist_can_open_redesigned_queue_board(): void
|
||||
public function test_receptionist_and_other_non_doctors_cannot_open_patient_queue(): void
|
||||
{
|
||||
[$receptionistUser, $receptionistMember] = $this->makeStaff('receptionist', 'rec1');
|
||||
[$pharmacistUser, $pharmacistMember] = $this->makeStaff('pharmacist', 'rx1');
|
||||
$permissions = app(CarePermissions::class);
|
||||
|
||||
$this->assertFalse($permissions->canAccessPatientQueue($receptionistMember));
|
||||
$this->assertFalse($permissions->canAccessPatientQueue($pharmacistMember));
|
||||
$this->assertTrue($permissions->can($receptionistMember, 'queue.manage'));
|
||||
|
||||
$this->actingAs($receptionistUser)
|
||||
->get(route('care.queue.index'))
|
||||
->assertForbidden();
|
||||
|
||||
$this->actingAs($receptionistUser)
|
||||
->get(route('care.dashboard'))
|
||||
->assertOk()
|
||||
->assertDontSee('href="'.e(route('care.queue.index')).'"', false);
|
||||
|
||||
$this->actingAs($pharmacistUser)
|
||||
->get(route('care.queue.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_doctor_can_open_redesigned_queue_board(): void
|
||||
{
|
||||
[$doctorUser, $doctorMember] = $this->makeStaff('doctor', 'doc1');
|
||||
[$receptionistUser, $receptionistMember] = $this->makeStaff('receptionist', 'rec1');
|
||||
$permissions = app(CarePermissions::class);
|
||||
|
||||
$this->assertTrue($permissions->canAccessPatientQueue($doctorMember));
|
||||
$this->assertTrue($permissions->canAccessPatientQueue($receptionistMember));
|
||||
$this->assertTrue($permissions->can($receptionistMember, 'queue.manage'));
|
||||
|
||||
$this->actingAs($doctorUser)
|
||||
->get(route('care.queue.index'))
|
||||
@@ -118,29 +144,101 @@ class CarePatientQueueAccessTest extends TestCase
|
||||
->assertSee('Called')
|
||||
->assertSee('Done');
|
||||
|
||||
$this->actingAs($receptionistUser)
|
||||
->get(route('care.queue.index'))
|
||||
->assertOk()
|
||||
->assertSee('Patient flow')
|
||||
->assertSee('Call next');
|
||||
|
||||
$this->actingAs($doctorUser)
|
||||
->get(route('care.dashboard'))
|
||||
->assertOk()
|
||||
->assertSee('Queue', false);
|
||||
}
|
||||
|
||||
public function test_nurse_specialty_show_redirects_to_workspace_not_queue(): void
|
||||
public function test_hospital_admin_does_not_get_patient_queue_board(): void
|
||||
{
|
||||
$adminMember = Member::query()
|
||||
->where('user_ref', $this->owner->public_id)
|
||||
->firstOrFail();
|
||||
$permissions = app(CarePermissions::class);
|
||||
|
||||
$this->assertFalse($permissions->canAccessPatientQueue($adminMember));
|
||||
$this->assertFalse($permissions->handlesFloorCare($adminMember));
|
||||
|
||||
$this->actingAs($this->owner)
|
||||
->get(route('care.queue.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_nurse_specialty_show_renders_list_not_auto_open_visit(): void
|
||||
{
|
||||
[$nurseUser] = $this->makeStaff('nurse', 'nurse-spec');
|
||||
|
||||
app(\App\Services\Care\SpecialtyModuleService::class)
|
||||
$modules = app(SpecialtyModuleService::class);
|
||||
$modules->ensureDefaultModulesProvisioned($this->organization, $this->owner->public_id);
|
||||
$modules->activate($this->organization->fresh(), $this->owner->public_id, 'blood_bank');
|
||||
|
||||
$department = Department::query()
|
||||
->where('branch_id', $this->branch->id)
|
||||
->where('type', 'blood_bank')
|
||||
->firstOrFail();
|
||||
|
||||
$patient = Patient::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'patient_number' => 'P-BB-LIST',
|
||||
'first_name' => 'Kwame',
|
||||
'last_name' => 'Donor',
|
||||
'gender' => 'male',
|
||||
'date_of_birth' => '1988-01-01',
|
||||
]);
|
||||
|
||||
$visit = Visit::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'patient_id' => $patient->id,
|
||||
'status' => Visit::STATUS_OPEN,
|
||||
'checked_in_at' => now(),
|
||||
]);
|
||||
|
||||
Appointment::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'patient_id' => $patient->id,
|
||||
'department_id' => $department->id,
|
||||
'visit_id' => $visit->id,
|
||||
'type' => Appointment::TYPE_WALK_IN,
|
||||
'status' => Appointment::STATUS_WAITING,
|
||||
'scheduled_at' => now(),
|
||||
'waiting_at' => now(),
|
||||
'checked_in_at' => now(),
|
||||
]);
|
||||
|
||||
$this->actingAs($nurseUser)
|
||||
->get(route('care.specialty.show', 'blood_bank'))
|
||||
->assertOk()
|
||||
->assertSee('Blood Bank')
|
||||
->assertSee('Patient flow')
|
||||
->assertSee('Waiting')
|
||||
->assertSee('Kwame Donor')
|
||||
->assertDontSee('No open visit selected');
|
||||
|
||||
$this->actingAs($nurseUser)
|
||||
->get(route('care.specialty.workspace', 'blood_bank'))
|
||||
->assertRedirect(route('care.specialty.show', 'blood_bank'));
|
||||
}
|
||||
|
||||
public function test_nurse_specialty_show_redirects_to_workspace_not_queue(): void
|
||||
{
|
||||
[$nurseUser] = $this->makeStaff('nurse', 'nurse-spec-er');
|
||||
|
||||
app(SpecialtyModuleService::class)
|
||||
->ensureDefaultModulesProvisioned($this->organization, $this->owner->public_id);
|
||||
app(\App\Services\Care\SpecialtyModuleService::class)
|
||||
app(SpecialtyModuleService::class)
|
||||
->activate($this->organization->fresh(), $this->owner->public_id, 'emergency');
|
||||
|
||||
$this->actingAs($nurseUser)
|
||||
->get(route('care.specialty.show', 'emergency'))
|
||||
->assertRedirect(route('care.specialty.workspace', 'emergency'));
|
||||
->assertOk()
|
||||
->assertSee('Patient flow')
|
||||
->assertDontSee('href="'.e(route('care.queue.index')).'"', false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user