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
@@ -136,6 +136,12 @@ class AppointmentConfirmationService
);
}
// همان کاری که onConfirmed می‌کند. نبودنش یعنی نوبتی که از پنل و با
// پرداخت قطعی شده — یعنی مسیر عادیِ منشی — هرگز پروندهٔ درمان نمی‌گیرد و
// جلسه‌ای هم ساخته نمی‌شود که در پنل پرسنل دیده شود.
// starter خودش خطا را می‌گیرد و لاگ می‌کند، پس تراکنش پرداخت را نمی‌شکند.
$this->treatmentCases->onAppointmentConfirmed($appointment, $session);
return $session;
});
}