Add full Oncology, Renal Care, and Surgery specialty clinical suites.
Deploy Ladill Care / deploy (push) Successful in 32s

Match Pediatrics/ENT depth with stages, workspace tabs, clinical records, reports/print, demo seed, and suite tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-19 20:16:18 +00:00
co-authored by Cursor
parent dc86b51ed5
commit b7e5a7d9ad
33 changed files with 3392 additions and 53 deletions
+233
View File
@@ -0,0 +1,233 @@
<?php
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\SpecialtyClinicalRecord;
use App\Models\User;
use App\Models\Visit;
use App\Services\Care\SpecialtyModuleService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class CareOncologySuiteTest extends TestCase
{
use RefreshDatabase;
protected User $owner;
protected Organization $organization;
protected Branch $branch;
protected Patient $patient;
protected Visit $visit;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
$this->owner = User::create([
'public_id' => 'onc-owner',
'name' => 'Owner',
'email' => 'onc-owner@example.com',
]);
$this->organization = Organization::create([
'owner_ref' => $this->owner->public_id,
'name' => 'Oncology Clinic',
'slug' => 'onc-owner-clinic',
'settings' => [
'onboarded' => true,
'facility_type' => 'clinic',
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
'queue_integration_enabled' => true,
],
]);
Member::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->owner->public_id,
'role' => 'hospital_admin',
'branch_id' => null,
]);
$this->branch = Branch::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Main',
'is_active' => true,
]);
app(SpecialtyModuleService::class)->activate(
$this->organization,
$this->owner->public_id,
'oncology',
);
$department = Department::query()
->where('branch_id', $this->branch->id)
->where('type', 'oncology')
->firstOrFail();
$this->patient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'P-ONC-SUITE',
'first_name' => 'Ama',
'last_name' => 'Cancer',
'gender' => 'female',
'date_of_birth' => '1988-09-02',
]);
$this->visit = Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'status' => Visit::STATUS_IN_PROGRESS,
'checked_in_at' => now(),
'specialty_stage' => 'check_in',
]);
Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'department_id' => $department->id,
'visit_id' => $this->visit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_IN_CONSULTATION,
'scheduled_at' => now(),
'waiting_at' => now(),
'checked_in_at' => now(),
'started_at' => now(),
]);
}
public function test_overview_and_clinical_tabs_render(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'oncology',
'visit' => $this->visit,
'tab' => 'overview',
]))
->assertOk()
->assertSee('Oncology overview')
->assertSee('data-care-stage-bar', false)
->assertSee('Start history')
->assertSee('Oncology reports');
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'oncology',
'visit' => $this->visit,
'tab' => 'staging',
]))
->assertOk()
->assertSee('Oncology diagnosis');
}
public function test_clinical_save_sets_stage_and_alerts(): void
{
$this->actingAs($this->owner)
->post(route('care.specialty.clinical.save', [
'module' => 'oncology',
'visit' => $this->visit,
]), [
'tab' => 'staging',
'payload' => [
'diagnosis' => 'Breast carcinoma',
'stage' => 'IIA',
'performance_status' => '3',
'exam_findings' => 'Palpable mass',
],
])
->assertRedirect();
$this->assertSame('staging', $this->visit->fresh()->specialty_stage);
$record = SpecialtyClinicalRecord::query()
->where('visit_id', $this->visit->id)
->firstOrFail();
$codes = collect($record->alerts)->pluck('code')->all();
$this->assertContains('onc.ecog_high', $codes);
}
public function test_stage_advance_and_terminal_completes_visit(): void
{
$this->actingAs($this->owner)
->post(route('care.specialty.oncology.stage', $this->visit), [
'stage' => 'treatment',
])
->assertRedirect(route('care.specialty.workspace', [
'module' => 'oncology',
'visit' => $this->visit,
'tab' => 'treatment',
]));
$this->assertSame('treatment', $this->visit->fresh()->specialty_stage);
$this->actingAs($this->owner)
->post(route('care.specialty.oncology.treatment', $this->visit), [
'tab' => 'treatment',
'payload' => [
'treatment' => 'AC cycle 1 day 1',
'regimen' => 'AC',
'cycle' => '1/4',
'outcome' => 'Completed uneventfully',
'post_treatment_plan' => 'Return cycle 2 in 21 days',
],
])
->assertRedirect(route('care.specialty.workspace', [
'module' => 'oncology',
'visit' => $this->visit,
'tab' => 'treatment',
]));
$this->assertSame('completed', $this->visit->fresh()->specialty_stage);
$this->assertSame(Visit::STATUS_COMPLETED, $this->visit->fresh()->status);
$this->assertDatabaseHas('care_specialty_clinical_records', [
'visit_id' => $this->visit->id,
'record_type' => 'onc_treatment',
'status' => SpecialtyClinicalRecord::STATUS_COMPLETED,
]);
}
public function test_reports_and_print(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.oncology.reports'))
->assertOk()
->assertSee('Oncology reports')
->assertSee('Arrivals today');
$this->actingAs($this->owner)
->get(route('care.specialty.oncology.print', $this->visit))
->assertOk()
->assertSee($this->patient->fullName());
}
public function test_list_index_does_not_auto_open_patient(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.show', 'oncology'))
->assertOk()
->assertDontSee('Oncology overview');
}
}
+231
View File
@@ -0,0 +1,231 @@
<?php
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\SpecialtyClinicalRecord;
use App\Models\User;
use App\Models\Visit;
use App\Services\Care\SpecialtyModuleService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class CareRenalSuiteTest extends TestCase
{
use RefreshDatabase;
protected User $owner;
protected Organization $organization;
protected Branch $branch;
protected Patient $patient;
protected Visit $visit;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
$this->owner = User::create([
'public_id' => 'renal-owner',
'name' => 'Owner',
'email' => 'renal-owner@example.com',
]);
$this->organization = Organization::create([
'owner_ref' => $this->owner->public_id,
'name' => 'Renal Clinic',
'slug' => 'renal-owner-clinic',
'settings' => [
'onboarded' => true,
'facility_type' => 'clinic',
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
'queue_integration_enabled' => true,
],
]);
Member::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->owner->public_id,
'role' => 'hospital_admin',
'branch_id' => null,
]);
$this->branch = Branch::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Main',
'is_active' => true,
]);
app(SpecialtyModuleService::class)->activate(
$this->organization,
$this->owner->public_id,
'renal',
);
$department = Department::query()
->where('branch_id', $this->branch->id)
->where('type', 'renal')
->firstOrFail();
$this->patient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'P-REN-SUITE',
'first_name' => 'Kojo',
'last_name' => 'Kidney',
'gender' => 'female',
'date_of_birth' => '1988-09-02',
]);
$this->visit = Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'status' => Visit::STATUS_IN_PROGRESS,
'checked_in_at' => now(),
'specialty_stage' => 'check_in',
]);
Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'department_id' => $department->id,
'visit_id' => $this->visit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_IN_CONSULTATION,
'scheduled_at' => now(),
'waiting_at' => now(),
'checked_in_at' => now(),
'started_at' => now(),
]);
}
public function test_overview_and_clinical_tabs_render(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'renal',
'visit' => $this->visit,
'tab' => 'overview',
]))
->assertOk()
->assertSee('Renal Care overview')
->assertSee('data-care-stage-bar', false)
->assertSee('Start history')
->assertSee('Renal reports');
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'renal',
'visit' => $this->visit,
'tab' => 'exam',
]))
->assertOk()
->assertSee('Chief complaint', false);
}
public function test_clinical_save_sets_stage_and_alerts(): void
{
$this->actingAs($this->owner)
->post(route('care.specialty.clinical.save', [
'module' => 'renal',
'visit' => $this->visit,
]), [
'tab' => 'exam',
'payload' => [
'chief_complaint' => 'Missed dialysis with oedema',
'fluid_status' => 'Overload',
'exam_findings' => 'Bilateral crackles',
],
])
->assertRedirect();
$this->assertSame('exam', $this->visit->fresh()->specialty_stage);
$record = SpecialtyClinicalRecord::query()
->where('visit_id', $this->visit->id)
->firstOrFail();
$codes = collect($record->alerts)->pluck('code')->all();
$this->assertContains('ren.fluid_overload', $codes);
}
public function test_stage_advance_and_terminal_completes_visit(): void
{
$this->actingAs($this->owner)
->post(route('care.specialty.renal.stage', $this->visit), [
'stage' => 'plan',
])
->assertRedirect(route('care.specialty.workspace', [
'module' => 'renal',
'visit' => $this->visit,
'tab' => 'plan',
]));
$this->assertSame('plan', $this->visit->fresh()->specialty_stage);
$this->actingAs($this->owner)
->post(route('care.specialty.renal.plan', $this->visit), [
'tab' => 'plan',
'payload' => [
'diagnosis' => 'CKD 5D with fluid overload',
'plan' => 'Urgent HD; adjust dry weight',
'outcome' => 'Completed — discharged',
'follow_up' => 'Next HD in 2 days',
],
])
->assertRedirect(route('care.specialty.workspace', [
'module' => 'renal',
'visit' => $this->visit,
'tab' => 'plan',
]));
$this->assertSame('completed', $this->visit->fresh()->specialty_stage);
$this->assertSame(Visit::STATUS_COMPLETED, $this->visit->fresh()->status);
$this->assertDatabaseHas('care_specialty_clinical_records', [
'visit_id' => $this->visit->id,
'record_type' => 'renal_plan',
'status' => SpecialtyClinicalRecord::STATUS_COMPLETED,
]);
}
public function test_reports_and_print(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.renal.reports'))
->assertOk()
->assertSee('Renal Care reports')
->assertSee('Arrivals today');
$this->actingAs($this->owner)
->get(route('care.specialty.renal.print', $this->visit))
->assertOk()
->assertSee($this->patient->fullName());
}
public function test_list_index_does_not_auto_open_patient(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.show', 'renal'))
->assertOk()
->assertDontSee('Renal Care overview');
}
}
+224
View File
@@ -0,0 +1,224 @@
<?php
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\SpecialtyClinicalRecord;
use App\Models\User;
use App\Models\Visit;
use App\Services\Care\SpecialtyModuleService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class CareSurgerySuiteTest extends TestCase
{
use RefreshDatabase;
protected User $owner;
protected Organization $organization;
protected Branch $branch;
protected Patient $patient;
protected Visit $visit;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
$this->owner = User::create([
'public_id' => 'surg-owner',
'name' => 'Owner',
'email' => 'surg-owner@example.com',
]);
$this->organization = Organization::create([
'owner_ref' => $this->owner->public_id,
'name' => 'Surgery Clinic',
'slug' => 'surg-owner-clinic',
'settings' => [
'onboarded' => true,
'facility_type' => 'clinic',
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
'queue_integration_enabled' => true,
],
]);
Member::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->owner->public_id,
'role' => 'hospital_admin',
'branch_id' => null,
]);
$this->branch = Branch::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'Main',
'is_active' => true,
]);
app(SpecialtyModuleService::class)->activate(
$this->organization,
$this->owner->public_id,
'surgery',
);
$department = Department::query()
->where('branch_id', $this->branch->id)
->where('type', 'surgery')
->firstOrFail();
$this->patient = Patient::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_number' => 'P-SUR-SUITE',
'first_name' => 'Efua',
'last_name' => 'Hernia',
'gender' => 'female',
'date_of_birth' => '1988-09-02',
]);
$this->visit = Visit::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'status' => Visit::STATUS_IN_PROGRESS,
'checked_in_at' => now(),
'specialty_stage' => 'check_in',
]);
Appointment::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'department_id' => $department->id,
'visit_id' => $this->visit->id,
'type' => Appointment::TYPE_WALK_IN,
'status' => Appointment::STATUS_IN_CONSULTATION,
'scheduled_at' => now(),
'waiting_at' => now(),
'checked_in_at' => now(),
'started_at' => now(),
]);
}
public function test_overview_and_clinical_tabs_render(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'surgery',
'visit' => $this->visit,
'tab' => 'overview',
]))
->assertOk()
->assertSee('Surgery overview')
->assertSee('data-care-stage-bar', false)
->assertSee('Start pre-op history')
->assertSee('Surgery reports');
$this->actingAs($this->owner)
->get(route('care.specialty.workspace', [
'module' => 'surgery',
'visit' => $this->visit,
'tab' => 'exam',
]))
->assertOk()
->assertSee('Chief complaint', false);
}
public function test_clinical_save_sets_stage_and_alerts(): void
{
$this->actingAs($this->owner)
->post(route('care.specialty.clinical.save', [
'module' => 'surgery',
'visit' => $this->visit,
]), [
'tab' => 'exam',
'payload' => [
'chief_complaint' => 'Right inguinal hernia',
'exam_findings' => 'Reducible hernia',
'asa_class' => 'II',
],
])
->assertRedirect();
$this->assertSame('exam', $this->visit->fresh()->specialty_stage);
}
public function test_stage_advance_and_terminal_completes_visit(): void
{
$this->actingAs($this->owner)
->post(route('care.specialty.surgery.stage', $this->visit), [
'stage' => 'postop',
])
->assertRedirect(route('care.specialty.workspace', [
'module' => 'surgery',
'visit' => $this->visit,
'tab' => 'postop',
]));
$this->assertSame('postop', $this->visit->fresh()->specialty_stage);
$this->actingAs($this->owner)
->post(route('care.specialty.surgery.postop', $this->visit), [
'tab' => 'postop',
'payload' => [
'review_type' => 'Immediate post-op',
'progress' => 'Stable; wound dry',
'outcome' => 'Completed — discharged',
'next_steps' => 'Wound check in 7 days',
],
])
->assertRedirect(route('care.specialty.workspace', [
'module' => 'surgery',
'visit' => $this->visit,
'tab' => 'postop',
]));
$this->assertSame('completed', $this->visit->fresh()->specialty_stage);
$this->assertSame(Visit::STATUS_COMPLETED, $this->visit->fresh()->status);
$this->assertDatabaseHas('care_specialty_clinical_records', [
'visit_id' => $this->visit->id,
'record_type' => 'surg_postop',
'status' => SpecialtyClinicalRecord::STATUS_COMPLETED,
]);
}
public function test_reports_and_print(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.surgery.reports'))
->assertOk()
->assertSee('Surgery reports')
->assertSee('Arrivals today');
$this->actingAs($this->owner)
->get(route('care.specialty.surgery.print', $this->visit))
->assertOk()
->assertSee($this->patient->fullName());
}
public function test_list_index_does_not_auto_open_patient(): void
{
$this->actingAs($this->owner)
->get(route('care.specialty.show', 'surgery'))
->assertOk()
->assertDontSee('Surgery overview');
}
}