Reuse the GP consultation prescribe modal, gate with prescriptions.manage, and return to the specialty workspace after create. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Tests\Feature;
|
||||
use App\Http\Middleware\EnsurePlatformSession;
|
||||
use App\Models\Appointment;
|
||||
use App\Models\Branch;
|
||||
use App\Models\Consultation;
|
||||
use App\Models\Department;
|
||||
use App\Models\Member;
|
||||
use App\Models\Organization;
|
||||
@@ -864,4 +865,126 @@ class CareSpecialtyAccessTest extends TestCase
|
||||
->post(route('care.specialty.emergency.stage', $visit), ['stage' => 'treatment'])
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_doctor_with_prescriptions_manage_sees_prescribe_on_specialty_workspace(): void
|
||||
{
|
||||
[$doctorUser, $doctorMember, $visit] = $this->dentistryVisitForRole('doctor', 'den-rx');
|
||||
$appointment = $visit->appointment()->firstOrFail();
|
||||
$appointment->update([
|
||||
'status' => Appointment::STATUS_IN_CONSULTATION,
|
||||
'started_at' => now(),
|
||||
'queue_ticket_status' => 'serving',
|
||||
]);
|
||||
$consultation = Consultation::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'visit_id' => $visit->id,
|
||||
'appointment_id' => $appointment->id,
|
||||
'patient_id' => $visit->patient_id,
|
||||
'status' => Consultation::STATUS_DRAFT,
|
||||
'started_at' => now(),
|
||||
]);
|
||||
|
||||
$permissions = app(\App\Services\Care\CarePermissions::class);
|
||||
$this->assertTrue($permissions->can($doctorMember, 'prescriptions.manage'));
|
||||
$this->assertTrue($this->modules->memberCanManage($this->organization, $doctorMember, 'dentistry'));
|
||||
|
||||
$html = $this->actingAs($doctorUser)
|
||||
->get(route('care.specialty.workspace', [
|
||||
'module' => 'dentistry',
|
||||
'visit' => $visit,
|
||||
'tab' => 'overview',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSee('Prescribe')
|
||||
->assertSee('New prescription')
|
||||
->getContent();
|
||||
|
||||
$this->assertStringContainsString(
|
||||
route('care.prescriptions.store', $consultation, absolute: false),
|
||||
$html,
|
||||
);
|
||||
$this->assertStringContainsString('name="return_to" value="specialty"', $html);
|
||||
$this->assertStringContainsString('name="specialty_module" value="dentistry"', $html);
|
||||
}
|
||||
|
||||
public function test_nurse_without_prescriptions_manage_does_not_see_prescribe_cta(): void
|
||||
{
|
||||
[$nurseUser, $nurseMember, $visit] = $this->dentistryVisitForRole('nurse', 'den-no-rx');
|
||||
$appointment = $visit->appointment()->firstOrFail();
|
||||
$appointment->update([
|
||||
'status' => Appointment::STATUS_IN_CONSULTATION,
|
||||
'started_at' => now(),
|
||||
'queue_ticket_status' => 'serving',
|
||||
]);
|
||||
Consultation::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'visit_id' => $visit->id,
|
||||
'appointment_id' => $appointment->id,
|
||||
'patient_id' => $visit->patient_id,
|
||||
'status' => Consultation::STATUS_DRAFT,
|
||||
'started_at' => now(),
|
||||
]);
|
||||
|
||||
$permissions = app(\App\Services\Care\CarePermissions::class);
|
||||
$this->assertTrue($this->modules->memberCanManage($this->organization, $nurseMember, 'dentistry'));
|
||||
$this->assertFalse($permissions->can($nurseMember, 'prescriptions.manage'));
|
||||
|
||||
$this->actingAs($nurseUser)
|
||||
->get(route('care.specialty.workspace', [
|
||||
'module' => 'dentistry',
|
||||
'visit' => $visit,
|
||||
'tab' => 'overview',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertDontSee('Prescribe')
|
||||
->assertDontSee('New prescription')
|
||||
->assertDontSee(route('care.prescriptions.store', Consultation::query()->where('visit_id', $visit->id)->first(), absolute: false));
|
||||
}
|
||||
|
||||
public function test_specialty_prescribe_store_returns_to_workspace(): void
|
||||
{
|
||||
[$doctorUser, , $visit] = $this->dentistryVisitForRole('doctor', 'den-rx-store');
|
||||
$appointment = $visit->appointment()->firstOrFail();
|
||||
$appointment->update([
|
||||
'status' => Appointment::STATUS_IN_CONSULTATION,
|
||||
'started_at' => now(),
|
||||
'queue_ticket_status' => 'serving',
|
||||
]);
|
||||
$consultation = Consultation::create([
|
||||
'owner_ref' => $this->owner->public_id,
|
||||
'visit_id' => $visit->id,
|
||||
'appointment_id' => $appointment->id,
|
||||
'patient_id' => $visit->patient_id,
|
||||
'status' => Consultation::STATUS_DRAFT,
|
||||
'started_at' => now(),
|
||||
]);
|
||||
|
||||
$this->actingAs($doctorUser)
|
||||
->post(route('care.prescriptions.store', $consultation), [
|
||||
'activate' => true,
|
||||
'return_to' => 'specialty',
|
||||
'specialty_module' => 'dentistry',
|
||||
'specialty_visit_id' => $visit->id,
|
||||
'from_consultation' => $consultation->uuid,
|
||||
'items' => [
|
||||
[
|
||||
'name' => 'Amoxicillin 500mg',
|
||||
'dosage' => '1 capsule',
|
||||
'frequency' => 'TDS',
|
||||
'duration' => '5 days',
|
||||
'route' => 'oral',
|
||||
],
|
||||
],
|
||||
])
|
||||
->assertRedirect(route('care.specialty.workspace', [
|
||||
'module' => 'dentistry',
|
||||
'visit' => $visit,
|
||||
]));
|
||||
|
||||
$this->assertDatabaseHas('care_prescriptions', [
|
||||
'consultation_id' => $consultation->id,
|
||||
'visit_id' => $visit->id,
|
||||
'patient_id' => $visit->patient_id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user