docs: settle every remaining row, and add the third occupancy mode

The last structural gap from task 05 was the third occupancy mode. It is
passive: the resource is genuinely held — nobody else can take that room while
the patient waits for the anaesthetic — but the time is not work done. It
blocks exactly like exclusive; the difference is in the report, where without
it a room that spends half its day waiting reads as fully utilised. The mode is
validated, offered in the segment editor and carried through to the plan.

Everything else that was still marked as a deviation is now recorded in
docs/architecture/deviations.md, one row each, in the form "what the plan said
/ what was built / why". That includes the ones I would defend (five plan
services collapsed into one builder that only build() calls; a Skill foreign
key instead of a JSON array, because a deleted skill in JSON fails silently)
and the ones that are simply facts about the product (service_option does not
exist here, so a column for it would sit empty until someone read it as a bug).

The i18n section says plainly that the product is single-language and describes
the order to migrate in if that changes — a translation layer with one language
is an indirection, not an abstraction.

All sixteen checklists now read zero pending and zero unresolved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-01 16:40:55 +03:30
co-authored by Claude Opus 5
parent bab7b57a9d
commit e5b74ebab4
14 changed files with 221 additions and 33 deletions
+84
View File
@@ -511,6 +511,90 @@ class TreatmentCourseTest extends ApiTestCase
}
}
/**
* ⭐ مسیر **موفق** `book-all`: لنگر بعد از هر رزرو جلو می‌رود.
*
* تست شکست از قبل بود؛ این یکی همان چیزی را می‌سنجد که کار می‌کند. لنگر ثابت یعنی
* هر هشت جلسه دور همان تاریخ جمع می‌شوند و پروتکل عملاً بی‌اثر است.
*/
public function testBookAllMovesTheAnchorForwardBetweenSessions(): void
{
[$user, $section, $address, $doctor, $patient] = $this->clinicWithPatient();
$service = $this->service($section);
$type = $this->authJson('POST', '/api/v1/resource-types', $user, [
'address_uuid' => $address->getUuid(),
'code' => 'room',
'name' => 'اتاق',
]);
self::assertSame(201, $this->responseCode(), json_encode($type, JSON_UNESCAPED_UNICODE));
$resource = $this->authJson('POST', '/api/v1/resource', $user, [
'address_uuid' => $address->getUuid(),
'type_uuid' => $type['data']['uuid'],
'name' => 'اتاق دوره',
]);
self::assertSame(201, $this->responseCode());
// هر روز باز — تا جلسات فقط با فاصلهٔ پروتکل جدا شوند، نه با تعطیلی.
$this->authJson('PUT', "/api/v1/resource/{$resource['data']['uuid']}/calendar", $user, [
'days' => array_fill_keys(range(0, 6), [['start_minute' => 480, 'end_minute' => 1200]]),
]);
self::assertSame(200, $this->responseCode());
$this->authJson('PUT', "/api/v1/service-item/{$service->getUuid()}/segments", $user, [
'segments' => [
['sequence' => 1, 'name' => 'جلسه', 'duration_minutes' => 30, 'requirements' => [['type_uuid' => $type['data']['uuid']]]],
],
]);
self::assertSame(200, $this->responseCode());
$protocol = $this->protocol($user, $service, [
'session_count' => 3,
'min_days' => 7,
'ideal_days' => 7,
'max_days' => 14,
'steps' => [
['session_number' => 1, 'params' => ['energy' => 12]],
['session_number' => 2, 'params' => ['energy' => 14]],
['session_number' => 3, 'params' => ['energy' => 16]],
],
]);
$started = $this->startCourse($user, $patient, $protocol['uuid']);
$body = $this->authJson('POST', "/api/v1/treatment-course/{$started['uuid']}/book-all", $user, [
'branch_uuid' => $address->getUuid(),
'doctor_uuid' => $doctor->getUuid(),
]);
self::assertSame(200, $this->responseCode(), json_encode($body, JSON_UNESCAPED_UNICODE));
self::assertSame(3, $body['data']['booked']);
$this->em->clear();
$sessions = $this->courseEntity($started['uuid'])->getSessions()->toArray();
usort($sessions, static fn (CourseSession $a, CourseSession $b): int
=> $a->getSessionNumber() <=> $b->getSessionNumber());
$starts = array_map(
static fn (CourseSession $s): ?int => $s->getAppointment()?->getSlotStart(),
$sessions,
);
self::assertNotContains(null, $starts, 'هر سه جلسه باید نوبت گرفته باشند');
// لنگر متحرک: هر جلسه دست‌کم هفت روز بعد از جلسهٔ قبلی است.
for ($i = 1; $i < count($starts); $i++) {
$gapDays = (int) floor(($starts[$i] - $starts[$i - 1]) / 86400);
self::assertGreaterThanOrEqual(7, $gapDays, sprintf(
'فاصلهٔ جلسهٔ %d با قبلی %d روز شد',
$i + 1,
$gapDays,
));
}
}
public function testAnotherClinicCannotSeeTheCourse(): void
{
[$owner, $section, , , $patient] = $this->clinicWithPatient();