Files
clinicpro/docs/tasks/task-16-representation/database.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

71 lines
2.9 KiB
Markdown

# پایگاه داده — تسک ۱۶: ماژول Representation
## جدول: representations
_(entity_type=clinic_pro, bundle=representation — از DB backup تأیید شده)_
| ستون | نوع | نام Drupal | توضیح |
|------|-----|-----------|-------|
| id | INT UNSIGNED AUTO_INCREMENT PK | id | |
| uuid | CHAR(36) UNIQUE NOT NULL | uuid | |
| domain_name | VARCHAR(255) UNIQUE NULL | field_domain_name | دامنه سایت نماینده |
| city_id | INT FK → categories.id NULL | field_city | entity ref → category (city bundle) |
| state_id | INT FK → categories.id NULL | field_state | entity ref → category (state bundle) |
| active | TINYINT(1) DEFAULT 1 | field_active | فعال/غیرفعال |
| commission_percent | INT NULL | field_commission_percent | درصد کمیسیون (نوع INT نه decimal) |
| address | LONGTEXT NULL | field_address | آدرس نماینده |
| bank_account | LONGTEXT NULL | field_bank_account | اطلاعات حساب بانکی (JSON/text) |
| created_at | INT NOT NULL | created | Unix timestamp |
| updated_at | INT NOT NULL | changed | Unix timestamp |
## نمونه داده واقعی (از DB backup)
```
id=41, bundle='representation', uid=33
uuid='bc2a0518-f20d-4542-9376-c2b4fd264706'
```
## ایندکس‌ها
```sql
CREATE UNIQUE INDEX idx_representations_domain ON representations(domain_name);
CREATE INDEX idx_representations_city ON representations(city_id);
```
## روابط با جداول دیگر
- `doctors.representation_id``representations.id` (تسک ۰۵)
- `appointments.representation_id``representations.id` (تسک ۱۰)
- `payments.representation_id``representations.id` (تسک ۱۵)
## کوئری‌های آماری (بر اساس ماه شمسی)
### پرداخت‌های یک ماه شمسی (از RepresentationService.php)
```sql
-- startTimestamp و endTimestamp از JalaliDateService می‌آیند
SELECT SUM(p.amount) as total_price, COUNT(p.id) as count
FROM payments p
WHERE p.representation_id = :id
AND p.status = 'received' -- نه 'paid'!
AND p.created_at >= :startTimestamp
AND p.created_at < :endTimestamp
```
### بیماران یک نماینده (total_patients)
```sql
SELECT COUNT(DISTINCT a.patient_id)
FROM appointments a
WHERE a.representation_id = :id
```
### نوبت‌های امروز
```sql
SELECT COUNT(*)
FROM appointments a
WHERE a.representation_id = :id
AND a.start_time >= :todayStartTimestamp
AND a.start_time < :tomorrowStartTimestamp
```
## نکات مهم
- **domain_name** شامل scheme و slash انتها است: `http://yasuj-nobat.localhost:3000/`
- آمار مالی از `payments` با `status='received'` است، نه `paid`
- محاسبه ماه/سال با تقویم **شمسی** انجام می‌شود (نه میلادی)
- `JalaliDateService` باید قبل از این تسک پیاده‌سازی شده باشد