Files
clinicpro/docs/tasks/task-05-doctor/implementation_notes.md
T
hamed de1a78a235 feat: Implement SMS sending functionality with KavehNegar and Rangineh providers
- Add SendSmsMessage class for encapsulating SMS message data.
- Create KavehNegarProvider and RanginehProvider classes implementing SmsProviderInterface for sending SMS.
- Implement SmsLogRepository and SmsTemplateRepository for managing SMS logs and templates.
- Develop SendSmsHandler for handling SMS sending messages.
- Create SmsService to manage SMS dispatching and logging.
- Add UserProfileController for managing user profiles with CRUD operations.
- Implement UserProfile entity and repository for user profile data management.
- Update symfony.lock and bootstrap.php for project dependencies and environment setup.
2026-06-09 22:00:34 +03:30

2.3 KiB

نکات پیاده‌سازی — تسک ۰۵: ماژول دکتر

فیلتر لیست دکترها

لیست دکترها باید فیلترهای زیر را پشتیبانی کند:

// DoctorRepository.php
public function findFiltered(DoctorFilterRequest $filter): array
{
    $qb = $this->createQueryBuilder('d')
        ->join('d.user', 'u');

    if ($filter->specialty) {
        $qb->andWhere('d.specialty = :specialty')
           ->setParameter('specialty', $filter->specialty);
    }
    if ($filter->city) {
        $qb->join('d.addresses', 'a')
           ->andWhere('a.city = :city')
           ->setParameter('city', $filter->city);
    }
    if ($filter->name) {
        $qb->andWhere('u.firstName LIKE :name OR u.lastName LIKE :name')
           ->setParameter('name', '%'.$filter->name.'%');
    }
    if ($filter->insurance) {
        $qb->andWhere('JSON_CONTAINS(d.insurances, :ins) = 1')
           ->setParameter('ins', json_encode([$filter->insurance]));
    }

    return $qb->getQuery()->getResult();
}

آپدیت میانگین امتیاز

وقتی یک rating جدید ثبت می‌شود (تسک ۱۲)، average_rating را آپدیت کن:

// در RatingService (تسک ۱۲)
$this->em->createQuery(
    'UPDATE Doctor d SET d.averageRating = (
        SELECT AVG(r.score) FROM Rating r WHERE r.doctor = d
    ), d.reviewCount = (
        SELECT COUNT(r.id) FROM Rating r WHERE r.doctor = d
    ) WHERE d.id = :id'
)->setParameter('id', $doctor->getId())->execute();

آدرس مطب

  • یک دکتر می‌تواند چندین آدرس مطب داشته باشد
  • {doctorId} در endpoint لیست آدرس‌ها، UUID دکتر است (نه ID)
  • دکتر می‌تواند آدرس‌های خودش را ویرایش/حذف کند

مجوزها

POST /api/v1/doctor               → ROLE_ADMIN
PATCH /api/v1/doctor/{uuid}       → owner (دکتر خودش) یا ROLE_ADMIN
GET /api/v1/doctor/{uuid}         → عمومی
GET /api/v1/doctors               → عمومی

POST   doctor-address             → دکتر احراز هویت‌شده (برای خودش)
PATCH  doctor-address/{id}        → owner یا ROLE_ADMIN
DELETE doctor-address/{id}        → owner یا ROLE_ADMIN
GET    doctor-address/{id}        → عمومی
GET    doctor-addresses/{doctorId} → عمومی