feat(patient): soft-archive sessions with active/all/archived filter

Add archived + archived_at columns to PatientSession (setArchived stamps the
time). findByRecord/countByRecord accept an archived filter (default all to
keep existing callers, incl. the discount visit-count, unchanged); the
sessions GET reads ?filter=active|all|archived, defaulting to active so
archived visits are hidden. updateSession accepts { archived }. Records are
kept, only hidden. Verified end-to-end; docs updated.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-17 14:44:23 +03:30
co-authored by Claude Fable 5
parent 53bd87e807
commit 666833fc69
5 changed files with 70 additions and 13 deletions
+7 -2
View File
@@ -922,8 +922,10 @@ class PatientController extends BaseController
$page = max(1, (int) $request->query->get('page', 1));
$limit = min(50, max(10, (int) $request->query->get('limit', 20)));
$sessions = $this->sessionRepo->findByRecord($record, $page, $limit);
$total = $this->sessionRepo->countByRecord($record);
// فیلتر آرشیو: active (پیش‌فرض — آرشیوها مخفی) | all | archived
$filter = in_array($request->query->get('filter'), ['all', 'archived'], true) ? $request->query->get('filter') : 'active';
$sessions = $this->sessionRepo->findByRecord($record, $page, $limit, $filter);
$total = $this->sessionRepo->countByRecord($record, $filter);
return $this->paginated(
array_map(fn($s) => $this->sessionWithBilling($s), $sessions),
@@ -1047,6 +1049,9 @@ class PatientController extends BaseController
if (isset($data['notes'])) { $session->setNotes($data['notes']); }
// آرشیو نرم: مخفی‌سازی مراجعه‌ی اشتباه بدون حذف سابقه.
if (array_key_exists('archived', $data)) { $session->setArchived((bool) $data['archived']); }
// تخفیف بر اساس قانون (discount_rule_uuid): مقدار از خود قانون، با ثبت منبع.
// '' یا null → حذف تخفیف. اولویت بر تخفیف دستی.
if (array_key_exists('discount_rule_uuid', $data)) {