fix(treatment): open the treatment case when confirming from the panel

confirmWithPayments — the path behind POST /appointment/{uuid}/confirm, which
is how a secretary actually confirms — created the patient session but never
called TreatmentCaseStarter. Only onConfirmed did. So an appointment on a
service with an active protocol was confirmed and paid, and no treatment case
or sessions were ever created; the staff panel had nothing to list.

Every existing test in OpenCaseOnConfirmTest drove onConfirmed, which is why
the gap survived. Added one that drives confirmWithPayments; it fails without
the fix.

Also adds app:treatment:backfill-cases, mirroring
app:appointment:backfill-sessions: it reports confirmed appointments on a
protocol service that have no case, and with --fix replays the starter and
prints the exception the logger would otherwise keep to itself.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-07 12:24:29 +03:30
co-authored by Claude Opus 5
parent b437390e06
commit a331aab2b8
4 changed files with 193 additions and 2 deletions
+6
View File
@@ -610,6 +610,12 @@ Confirm an appointment («ثبت شده» → «قطعی شده») and register
case file — status transition, case file / visit, and payments in **one atomic
transaction**. If any step fails nothing is committed.
> **پروندهٔ درمان هم اینجا باز می‌شود.** اگر سرویسِ نوبت «طول درمان» فعال داشته باشد،
> همین اندپوینت پروندهٔ چندجلسه‌ای را می‌سازد و نوبت را به اولین جلسهٔ بدون‌نوبت وصل
> می‌کند — دقیقاً مثل `PATCH /api/v1/appointment/{uuid}/status`.
> شکستِ این مرحله نوبت و پرداخت را برنمی‌گرداند؛ فقط لاگ می‌شود. پرونده‌های
> جامانده را `php bin/console app:treatment:backfill-cases --fix` می‌سازد.
**Permission:** `AUTH``appointments.update_status` per the
[single-appointment access model](#single-appointment-access-model).