Allow MAR visit charts for nurses on duty outside their home branch.
Deploy Ladill Care / deploy (push) Successful in 52s
Deploy Ladill Care / deploy (push) Successful in 52s
Station could list clinic patients on a covered unit while authorizeBranch 404'd the MAR link; duty-unit census now grants access too. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -303,4 +303,76 @@ class CareOutpatientCensusTest extends TestCase
|
||||
$visits = app(CareUnitCensusService::class)->visitsForUnit($ward, $this->owner->public_id);
|
||||
$this->assertCount(0, $visits);
|
||||
}
|
||||
|
||||
public function test_nurse_rostered_on_other_branch_unit_can_open_mar(): void
|
||||
{
|
||||
$homeBranch = Branch::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'name' => 'Home Branch',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
'public_id' => 'opd-cover-nurse',
|
||||
'name' => 'Cover Nurse',
|
||||
'email' => 'opd-cover-nurse@example.com',
|
||||
]);
|
||||
$member = Member::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'user_ref' => $user->public_id,
|
||||
'role' => 'nurse',
|
||||
'branch_id' => $homeBranch->id,
|
||||
]);
|
||||
|
||||
$roster = app(RosterService::class);
|
||||
$day = $roster->ensureDefaultShifts($this->organization, $this->owner->public_id)->firstWhere('code', 'day');
|
||||
$roster->assign(
|
||||
$this->opd,
|
||||
$day,
|
||||
$member,
|
||||
now()->toDateString(),
|
||||
$this->owner->public_id,
|
||||
$this->owner->public_id,
|
||||
);
|
||||
|
||||
$patient = Patient::create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'patient_number' => 'P-OPD-MAR',
|
||||
'first_name' => 'Mansa',
|
||||
'last_name' => 'Addo',
|
||||
]);
|
||||
|
||||
$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_IN_PROGRESS,
|
||||
'checked_in_at' => now(),
|
||||
]);
|
||||
|
||||
Appointment::create([
|
||||
'uuid' => (string) Str::uuid(),
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'organization_id' => $this->organization->id,
|
||||
'branch_id' => $this->branch->id,
|
||||
'department_id' => $this->department->id,
|
||||
'patient_id' => $patient->id,
|
||||
'visit_id' => $visit->id,
|
||||
'type' => Appointment::TYPE_WALK_IN,
|
||||
'status' => Appointment::STATUS_WAITING,
|
||||
'checked_in_at' => now(),
|
||||
]);
|
||||
|
||||
// Home-branch gate alone would 404; duty on OPD must allow the chart.
|
||||
$this->actingAs($user)
|
||||
->get(route('care.visits.mar', $visit))
|
||||
->assertOk()
|
||||
->assertSee('Mansa Addo');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user