feat(treatment): endpoint for a course's calendar and its recorded work

GET /api/v1/treatment-case/{uuid}/plan returns every session with a date and an
is_estimate flag, plus each session's area records — the device readings a staff
member actually logged. Until now nothing exposed either: due_at existed only
for the next session, and TreatmentCase::toArray() serialised sessions without
their areas, so 'what was done' was unreachable outside the staff panel.

Kept separate from GET /treatment-case/{uuid}; that response feeds the edit
modal, which needs neither the calendar nor the areas.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-07 16:12:55 +03:30
co-authored by Claude Opus 5
parent 50d82279d6
commit fc50ac4b3b
3 changed files with 117 additions and 0 deletions
+56
View File
@@ -282,6 +282,62 @@ single-session again. Idempotent: deleting a service that has no protocol still
---
## GET `/api/v1/treatment-case/{uuid}/plan`
تقویمِ **کل** دوره به‌علاوهٔ آنچه در هر جلسه انجام شده. مصرف‌کننده‌اش تب «نوبت‌های
بعدی» در پروندهٔ بیمار است.
جدا از `GET /treatment-case/{uuid}` است نه اضافه به آن: آن پاسخ مصرف‌کنندهٔ دیگری
دارد (مودال ویرایش) که نه تقویم لازم دارد نه نواحی.
| فیلد هر جلسه | توضیح |
|---|---|
| `planned_at` | زمان جلسه — قطعی یا تخمینی |
| `is_estimate` | `false` یعنی به واقعیتی گره خورده، `true` یعنی محاسبهٔ لحظهٔ نمایش |
| `areas[]` | نواحی با `parameters` (خوانده‌های دستگاه)، `resource`، `note`، زمان‌ها |
**`planned_at` ذخیره نمی‌شود.** `TreatmentScheduler` فقط سررسید جلسهٔ بعدی را
می‌نویسد؛ بقیهٔ زنجیره را `TreatmentPlanProjector` در لحظهٔ خواندن می‌سازد. لنگرِ هر
جلسه به‌ترتیب: زمان اتمام، زمان نوبت، `due_at` نوشته‌شده. دوره‌ای که هیچ‌کدام را
ندارد از `opened_at` شروع می‌شود.
یعنی تاریخ‌های تخمینی ممکن است بین دو بار خواندن عوض شوند — این عمدی است و در UI با
برچسب «تخمینی» اعلام می‌شود.
### Response `200` (خروجی واقعی)
```json
{
"success": true,
"data": {
"case": { "uuid": "2a8b1e28-…", "status": "active", "patient": { "name": "محمد رستمی" } },
"sessions": [
{
"session_number": 1,
"status": "done",
"planned_at": 1786106340,
"is_estimate": false,
"areas": [
{ "area": { "name": "دست" }, "status": "completed",
"parameters": { "energy": 8, "pulse": 3, "shots": 23 } }
]
},
{ "session_number": 2, "status": "planned", "planned_at": 1787402340, "is_estimate": false, "areas": [] },
{ "session_number": 3, "status": "planned", "planned_at": 1789994340, "is_estimate": true, "areas": [] }
]
}
}
```
**Errors:**
| Code | HTTP | شرط |
|---|---|---|
| ERR_NOT_FOUND_001 | 404 | پرونده یافت نشد یا مال محیط دیگری است |
| ERR_AUTH_001 | 401 | بدون توکن |
---
## GET `/api/v1/treatment-session/{uuid}`
یک جلسه به‌تنهایی، به‌علاوهٔ `case_uuid`، `service` و `patient` — برای فرمِ «ثبت نوبت این