fix(appointment): one weekly schedule per doctor, place chosen per shift
A doctor working both at their own practice and at a clinic had to write two independent schedules and neither panel could see the other, so the clinic showed an empty form even though the doctor had configured their practice. The schedule is now a single record owned by the doctor. What varies between days is the place: the context of a shift is read from its location_id, not from the record it lives in. Booking in a context therefore sees only that context's days, so a personal-practice secretary still cannot book a clinic day. The caller's own context decides which addresses they may assign: the doctor gets every place of theirs, a clinic manager only its own, and shifts outside their reach are returned for display but preserved verbatim on save. Existing per-clinic rows are merged by migration; location_id was already stored on every shift, so no context information is lost. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,10 +43,9 @@ class BookingLocationsScanTest extends ApiTestCase
|
||||
$this->em->persist($personalAddress);
|
||||
$this->em->flush();
|
||||
|
||||
$this->em->persist($this->newWeeklySchedule(
|
||||
$doctor,
|
||||
$this->weekOfSessions($personalAddress->getId(), '09:00', '13:00')
|
||||
));
|
||||
// برنامه یکی است و شیفتِ همهٔ محلها داخل همان مینشیند؛ محیطِ هر شیفت از
|
||||
// آدرسش خوانده میشود، نه از رکورد جدا.
|
||||
$setting = $this->weekOfSessions($personalAddress->getId(), '09:00', '13:00');
|
||||
|
||||
for ($i = 0; $i < $clinicCount; $i++) {
|
||||
$clinic = new Clinic($this->createUser(['ROLE_USER', 'ROLE_CLINIC']));
|
||||
@@ -61,13 +60,13 @@ class BookingLocationsScanTest extends ApiTestCase
|
||||
$this->em->persist($address);
|
||||
$this->em->flush();
|
||||
|
||||
$this->em->persist($this->newWeeklySchedule(
|
||||
$doctor,
|
||||
$this->weekOfSessions($address->getId(), '16:00', '20:00'),
|
||||
$clinic
|
||||
));
|
||||
$clinicWeek = $this->weekOfSessions($address->getId(), '16:00', '20:00');
|
||||
foreach ($clinicWeek as $dayKey => $day) {
|
||||
$setting[$dayKey]['sessions'] = array_merge($setting[$dayKey]['sessions'], $day['sessions']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->em->persist($this->newWeeklySchedule($doctor, $setting));
|
||||
$this->em->flush();
|
||||
|
||||
return $doctor;
|
||||
|
||||
Reference in New Issue
Block a user