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:
@@ -17,6 +17,7 @@ use App\Treatment\Repository\TreatmentSessionRepository;
|
||||
use App\Treatment\Service\NextSessionSlotFinder;
|
||||
use App\Treatment\Service\TreatmentCaseEditor;
|
||||
use App\Treatment\Service\TreatmentCaseOpener;
|
||||
use App\Treatment\Service\TreatmentPlanProjector;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -37,6 +38,7 @@ class TreatmentCaseController extends BaseController
|
||||
private readonly AddressResolver $branches,
|
||||
private readonly TreatmentCaseOpener $opener,
|
||||
private readonly TreatmentCaseEditor $editor,
|
||||
private readonly TreatmentPlanProjector $planner,
|
||||
) {}
|
||||
|
||||
#[Route('/api/v1/treatment-cases', name: 'treatment_case_list', methods: ['GET'])]
|
||||
@@ -142,6 +144,32 @@ class TreatmentCaseController extends BaseController
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* تقویمِ کل دوره + جزئیات آنچه انجام شده.
|
||||
*
|
||||
* جدا از `GET /treatment-case/{uuid}` است نه اضافه به آن: آن پاسخ مصرفکنندهٔ
|
||||
* دیگری دارد (مودال ویرایش) که نه تقویم لازم دارد نه نواحی، و بزرگترش کردن یعنی
|
||||
* هزینهٔ بیمصرف روی همان مسیر.
|
||||
*
|
||||
* `planned_at` تخمین است نه دادهٔ ذخیرهشده — `is_estimate` تکلیفش را روشن میکند.
|
||||
*/
|
||||
#[Route('/api/v1/treatment-case/{uuid}/plan', name: 'treatment_case_plan', methods: ['GET'])]
|
||||
public function plan(#[CurrentUser] User $user, string $uuid): JsonResponse
|
||||
{
|
||||
$case = $this->requireCase($user, $uuid);
|
||||
|
||||
return $this->success([
|
||||
'case' => $case->toArray(),
|
||||
'sessions' => array_map(
|
||||
static fn (array $row): array => $row['session']->toArray(withAreas: true) + [
|
||||
'planned_at' => $row['planned_at'],
|
||||
'is_estimate' => $row['is_estimate'],
|
||||
],
|
||||
$this->planner->project($case),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* یک جلسه بهتنهایی — برای فرمِ «ثبت نوبت این جلسه».
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user