Add GET /consultations/{uuid}/assessments for consultation-scoped forms.
Deploy Ladill Care / deploy (push) Successful in 50s

Only POST existed on that path, so navigating to the natural collection URL 404'd. Serve the patient assessments index with consultation return context, and cover it with a doctor feature test.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-18 20:39:02 +00:00
co-authored by Cursor
parent b077467c4b
commit 1128ea31cc
4 changed files with 67 additions and 3 deletions
@@ -59,6 +59,22 @@ class AssessmentController extends Controller
]);
}
/**
* Consultation-scoped assessments list (same patient forms UI with return context).
* Supports GET /consultations/{uuid}/assessments previously only POST existed.
*/
public function indexForConsultation(Request $request, Consultation $consultation): View
{
$this->authorizeConsultation($request, $consultation);
$consultation->loadMissing('patient');
$return = app(ConsultationReturnContext::class);
$return->remember($consultation);
$request->query->set(ConsultationReturnContext::QUERY_KEY, $consultation->uuid);
return $this->index($request, $consultation->patient);
}
public function create(Request $request, Patient $patient): View
{
$this->assertEngineEnabled($request);
@@ -202,7 +202,7 @@
<section class="mt-6 rounded-2xl border border-slate-200 bg-white p-6">
<div class="flex flex-wrap items-center justify-between gap-2">
<h2 class="text-sm font-semibold uppercase tracking-wide text-slate-500">Clinical forms this visit</h2>
<a href="{{ route('care.assessments.index', [$consultation->patient, 'from_consultation' => $consultation->uuid]) }}" class="text-sm text-sky-600 hover:text-sky-700">All patient forms</a>
<a href="{{ route('care.consultations.assessments.index', $consultation) }}" class="text-sm text-sky-600 hover:text-sky-700">All patient forms</a>
</div>
@if (($consultationAssessments ?? collect())->isNotEmpty())
+1
View File
@@ -219,6 +219,7 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
Route::get('/patients/{patient}/assessments', [AssessmentController::class, 'index'])->name('care.assessments.index');
Route::get('/patients/{patient}/assessments/create', [AssessmentController::class, 'create'])->name('care.assessments.create');
Route::post('/patients/{patient}/assessments', [AssessmentController::class, 'store'])->name('care.assessments.store');
Route::get('/consultations/{consultation}/assessments', [AssessmentController::class, 'indexForConsultation'])->name('care.consultations.assessments.index');
Route::post('/consultations/{consultation}/assessments', [AssessmentController::class, 'storeForConsultation'])->name('care.consultations.assessments.store');
Route::get('/assessments/{assessment}', [AssessmentController::class, 'show'])->name('care.assessments.show');
Route::put('/assessments/{assessment}', [AssessmentController::class, 'update'])->name('care.assessments.update');
+49 -2
View File
@@ -11,6 +11,7 @@ use App\Models\Consultation;
use App\Models\Member;
use App\Models\Organization;
use App\Models\Patient;
use App\Models\Practitioner;
use App\Models\User;
use App\Models\Visit;
use App\Services\Care\CareFeatures;
@@ -60,17 +61,30 @@ class CareAssessmentCaptureTest extends TestCase
],
]);
$this->branch = Branch::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'name' => 'Main',
'is_active' => true,
]);
$this->member = Member::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->user->public_id,
'role' => 'doctor',
'branch_id' => $this->branch->id,
]);
$this->branch = Branch::create([
// Doctors are branch-scoped via linked practitioner desks.
Practitioner::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'name' => 'Main',
'branch_id' => $this->branch->id,
'member_id' => $this->member->id,
'user_ref' => $this->user->public_id,
'name' => 'Dr Capture',
'specialty' => 'General Practice',
'is_active' => true,
]);
@@ -320,6 +334,39 @@ class CareAssessmentCaptureTest extends TestCase
$this->assertDatabaseHas('care_audit_logs', ['action' => 'assessment.cancelled']);
}
public function test_doctor_can_view_consultation_scoped_assessments_index(): void
{
$this->setMemberRole('doctor');
$visit = Visit::create([
'owner_ref' => $this->user->public_id,
'organization_id' => $this->organization->id,
'branch_id' => $this->branch->id,
'patient_id' => $this->patient->id,
'status' => Visit::STATUS_OPEN,
'checked_in_at' => now(),
]);
$consultation = Consultation::create([
'owner_ref' => $this->user->public_id,
'visit_id' => $visit->id,
'patient_id' => $this->patient->id,
'status' => Consultation::STATUS_DRAFT,
'started_at' => now(),
]);
$this->actingAs($this->user)
->get(route('care.consultations.assessments.index', $consultation))
->assertOk()
->assertSee('Clinical assessments')
->assertSee($this->patient->fullName());
// Path shape matches care.ladill.com/consultations/{uuid}/assessments
$this->actingAs($this->user)
->get('/consultations/'.$consultation->uuid.'/assessments')
->assertOk();
}
public function test_consultation_scoped_start_links_consultation_and_visit(): void
{
$this->setMemberRole('doctor');