# معماری — تسک ۱۰: ماژول نوبت‌دهی ## ساختار فایل‌ها ``` src/Module/Appointment/ ├── Controller/ │ └── AppointmentController.php ├── Service/ │ ├── AppointmentService.php │ └── SlotCalculatorService.php ← محاسبه اسلات‌های خالی ├── Repository/ │ └── AppointmentRepository.php ├── Entity/ │ └── Appointment.php ├── DTO/ │ ├── Request/ │ │ └── CreateAppointmentRequest.php │ └── Response/ │ ├── AppointmentResponse.php │ └── SlotResponse.php └── Voter/ └── AppointmentVoter.php ``` ## Entity: Appointment ```php #[ORM\Entity] #[ORM\Table(name: 'appointments')] class Appointment { #[ORM\Id, ORM\GeneratedValue, ORM\Column] private int $id; #[ORM\Column(type: UuidType::NAME, unique: true)] private Uuid $uuid; #[ORM\ManyToOne(targetEntity: User::class)] private User $patient; #[ORM\ManyToOne(targetEntity: Doctor::class)] private Doctor $doctor; #[ORM\Column(type: 'date')] private \DateTimeInterface $appointmentDate; #[ORM\Column(length: 10)] private string $appointmentTime; // HH:MM // pending, confirmed, cancelled, completed #[ORM\Column(length: 20, default: 'pending')] private string $status; #[ORM\Column(length: 30, nullable: true)] private ?string $insuranceType; #[ORM\Column(type: 'text', nullable: true)] private ?string $notes; #[ORM\OneToOne(targetEntity: Payment::class, mappedBy: 'appointment')] private ?Payment $payment; // TimestampableTrait } ``` ## SlotCalculatorService این سرویس با استفاده از WeeklySchedule، DateOverride و Holiday اسلات‌های خالی را برای یک دکتر در یک تاریخ مشخص محاسبه می‌کند: ``` calculateAvailableSlots(Doctor $doctor, \DateTimeInterface $date): array ```