Section 7 of the design document, and the reason the whole resource layer exists. A laser session is not one block: numbing cream (5 min, room + operator), waiting for it to work (30 min, room only), the laser itself (20 min, room + operator + device), aftercare (5 min, room + operator). Under the single-interval model the operator is locked for all 60 minutes while actually working 30 — half the capacity thrown away. AppointmentPlanBuilder turns (service, selected items, branch, patient) into a plan: segments with offsets, durations and resource requirements. It deliberately assigns no absolute time and no specific resource — that is the next task. This only produces the *shape* of the appointment. Segment duration comes from one of two sources. A fixed segment carries its own number; an item-driven one gets its duration from task 04's DurationCalculator, so "the laser itself" grows with two treated areas while "waiting for the cream" does not. One number could not have expressed that. Three contracts worth stating: - A service with no segment templates falls back to a single continuous segment requiring the doctor resource — exactly today's behaviour. Without it every existing service would have become unplannable overnight. - A segment with no requirements is valid: "waiting at home" consumes time but occupies nothing. - same_gender_as_patient with an unknown patient gender is a 422, not a silently dropped requirement. Dropping it quietly would route the patient to a resource the clinic said must not serve them. When no resource qualifies, the error names the role, the skill and the branch — "no female operator with the skill «Alexandrite laser» is available at «Central»" — rather than an empty result the caller has to interpret (section 10). occupancy_offset carries each requirement's setup/cleanup minutes for the availability engine. It is taken as the maximum across candidates, because the builder does not yet know which resource will be picked and under-reserving means the next appointment lands on top of the cleanup. 11 tests covering the document's reference example (offsets 0/5/35/55, total 60), item-driven scaling, the no-template fallback, all three gender-constraint outcomes, merging and both caps. 1186 tests overall. phpstan back at its 14-error baseline; slot-mode frozen contract green. The admin segments page is not built; the checklist records it with a target. The backend and preview endpoint are complete and consumable without it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
30 lines
833 B
PHP
30 lines
833 B
PHP
<?php
|
|
|
|
namespace App\Appointment\Plan\ValueObject;
|
|
|
|
/**
|
|
* برنامهٔ یک نوبت: بخشهای پشتسرهم با آفست، مدت و نیازمندی منبع.
|
|
*
|
|
* هنوز هیچ زمان مطلق و هیچ منبع مشخصی ندارد — آن کارِ تسک ۰۶ است. این فقط «شکل»
|
|
* نوبت است.
|
|
*/
|
|
final readonly class AppointmentPlan
|
|
{
|
|
/** @param list<PlannedSegment> $segments */
|
|
public function __construct(
|
|
public array $segments,
|
|
public int $totalMinutes,
|
|
) {}
|
|
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'total_minutes' => $this->totalMinutes,
|
|
'segments' => array_map(
|
|
static fn (PlannedSegment $s): array => $s->toArray(),
|
|
$this->segments,
|
|
),
|
|
];
|
|
}
|
|
}
|