feat(admin): name the tab for what it shows, prefill the patient, paginate and search

The tab was called 'نوبت‌های بعدی' but shows the whole course — finished sessions
with their recorded readings as much as upcoming ones. It is 'دوره‌های درمان' now.

Booking from a session still made the user search for a patient the page already
had open. The plan response carries the patient's national code (from the
profile, falling back to the user — the same COALESCE PatientController uses,
because users.national_code is routinely empty), and the modal takes a patient
prop that seeds the lookup and hides the search step. The old 'بیمار یافت شد'
card is suppressed in that mode; saying it twice is noise.

Sessions are now searchable and paged. A protocol allows up to 60 steps and a
patient can hold several courses, so an unbounded list was only ever going to
work for the small cases. Search filters on what the card actually shows —
service, staff, status, session number, area names — and runs in the page,
since /plan already returns the whole course and a round trip would add latency
and nothing else.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-07 16:43:34 +03:30
co-authored by Claude Opus 5
parent 02fdfd13cb
commit 288919339e
5 changed files with 134 additions and 21 deletions
@@ -39,6 +39,7 @@ class TreatmentCaseController extends BaseController
private readonly TreatmentCaseOpener $opener,
private readonly TreatmentCaseEditor $editor,
private readonly TreatmentPlanProjector $planner,
private readonly \App\UserProfile\Repository\UserProfileRepository $profiles,
) {}
#[Route('/api/v1/treatment-cases', name: 'treatment_case_list', methods: ['GET'])]
@@ -166,8 +167,19 @@ class TreatmentCaseController extends BaseController
*/
$resource = $this->slotFinder->preferredResource($case);
/**
* کد ملی برای پیش‌پرکردنِ فرم ثبت نوبت لازم است و روی پروفایل می‌نشیند، نه
* روی کاربر — همان COALESCE که `PatientController` هم می‌کند. بدونش منشی
* بیماری را دوباره جستجو می‌کند که همین‌جا معلوم است کیست.
*/
$patientUser = $case->getPatientRecord()->getUser();
$nationalCode = $this->profiles->findOneBy(['user' => $patientUser])?->getNationalCode()
?? $patientUser->getNationalCode();
return $this->success([
'case' => $case->toArray(),
'case' => $case->toArray() + [
'patient_national_code' => $nationalCode,
],
'resource' => $resource === null ? null : [
'uuid' => $resource->getUuid(),
'name' => $resource->getName(),