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:
+2
-1
@@ -280,7 +280,7 @@ GET /api/v1/patient/{uuid}/sessions
|
||||
|
||||
Returns paginated sessions for a patient record.
|
||||
|
||||
**Query params:** `page`, `limit` (same as list)
|
||||
**Query params:** `page`, `limit`, و `filter` = `active` (پیشفرض — آرشیوها مخفی) | `all` | `archived`. مقادیر نامعتبر به `active` برمیگردند. هر session کلیدهای `archived` (bool) و `archived_at` (unix|null) را هم دارد.
|
||||
|
||||
**Response 200:**
|
||||
|
||||
@@ -488,6 +488,7 @@ Updates mutable fields on a session.
|
||||
- **تخفیف تسویه (دستی):** `discount_type` = `percent` (۰..۱۰۰) یا `fixed` (ریال، حداکثر برابر مبلغ نهایی) یا `null` (حذف تخفیف). مبلغ محاسبهشده در `discount_rials` برمیگردد. تخفیف نمیتواند از «مبلغ نهایی منهای پرداختهای ثبتشده» بیشتر شود. تخفیفی که مانده را صفر کند مراجعه را تسویهشده میکند (`is_paid`, `paid_at`).
|
||||
- **تخفیف بر اساس قانون:** `discount_rule_uuid` (رشته) → قانون تخفیف (owner-scoped) اعمال میشود؛ مقدار ریالی از خود قانون توسط موتور محاسبه میگردد (نوع/مبنا بر اساس قانون). `''`/`null` → حذف تخفیف. اولویت بر `discount_type` دستی. قانونِ نامعتبر → `404`. منبع اعمالشده در پاسخ بهصورت `applied_discount_rule_id` و `applied_discount_rule_label` (audit) برمیگردد. قوانین قابلاعمال از `GET /api/v1/session/{uuid}/discount-suggestions` (نگاه کنید به `discount.md`).
|
||||
- `paid_at`: unix timestamp زمان تسویه.
|
||||
- **آرشیو:** `archived` (bool) → آرشیو نرم مراجعه؛ `true` آن را از لیست پیشفرض (`filter=active`) مخفی میکند و `archived_at` را ست میکند، `false` بازمیگرداند. سابقه (فاکتور/پرداختها) حذف نمیشود.
|
||||
|
||||
**Response 200:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user