feat: enhance DoctorAddress entity to support clinic addresses and types
- Added `clinic_id` and `type` fields to `DoctorAddress` entity to differentiate between personal and clinic addresses. - Updated constructor to support creation of addresses for both doctors and clinics. - Modified repository methods to handle new address types and added methods for counting and finding addresses by clinic. - Implemented migration to update the database schema accordingly. - Removed deprecated endpoint for creating addresses from clinics and updated related controller methods. - Added new endpoints for managing clinic addresses, including CRUD operations. - Updated frontend components to handle new address types and display accordingly.
This commit is contained in:
@@ -538,3 +538,61 @@ The `SlotCalculatorService` calculates available slots in this priority order:
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Available Locations
|
||||
|
||||
### `GET /api/v1/appointment-settings/available-locations/{doctorUuid}`
|
||||
|
||||
**Permission:** Public
|
||||
|
||||
Returns all locations a doctor can assign as `location_id` in their schedule sessions. Includes both the doctor's personal addresses and the addresses of all clinics they belong to.
|
||||
|
||||
#### Response `200`
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"id": "5",
|
||||
"uuid": "...",
|
||||
"type": "personal",
|
||||
"clinic_id": null,
|
||||
"clinic_name": null,
|
||||
"name": "مطب شخصی",
|
||||
"address": "تهران، ...",
|
||||
"telephone": "09121234567",
|
||||
"map": { "latitude": "35.7", "longitude": "51.4" },
|
||||
"city": { "id": "1", "name": "تهران" },
|
||||
"province": { "id": "8", "name": "تهران" }
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
"uuid": "...",
|
||||
"type": "clinic",
|
||||
"clinic_id": "3",
|
||||
"clinic_name": "کلینیک نور",
|
||||
"name": "شعبه مرکزی",
|
||||
"address": "تهران، خیابان ولیعصر...",
|
||||
"telephone": "02112345678",
|
||||
"map": { "latitude": "35.699", "longitude": "51.337" },
|
||||
"city": { "id": "1", "name": "تهران" },
|
||||
"province": { "id": "8", "name": "تهران" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
|-------|-------------|
|
||||
| `type` | `personal` = doctor's own address; `clinic` = clinic address |
|
||||
| `clinic_id` | ID of the clinic (only for type=clinic) |
|
||||
| `clinic_name` | Name of the clinic (only for type=clinic) |
|
||||
|
||||
> Use `id` as the `location_id` value in weekly schedule sessions or date override sessions.
|
||||
|
||||
#### Errors
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_VALIDATION_002` | 404 | Doctor not found |
|
||||
|
||||
@@ -308,3 +308,111 @@ Upload clinic gallery image.
|
||||
|------|------|-------------|
|
||||
| `ERR_FILE_001` | 422 | Invalid file type |
|
||||
| `ERR_AUTH_001` | 401 | Missing token |
|
||||
|
||||
---
|
||||
|
||||
## Clinic Address Management
|
||||
|
||||
### `GET /api/v1/clinic/{clinicUuid}/addresses`
|
||||
|
||||
**Permission:** Public
|
||||
|
||||
Returns all addresses registered for a clinic (type=clinic entries).
|
||||
|
||||
#### Response `200`
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"id": "12",
|
||||
"uuid": "abc-123",
|
||||
"type": "clinic",
|
||||
"clinic_id": "5",
|
||||
"name": "شعبه مرکزی",
|
||||
"address": "تهران، خیابان ولیعصر...",
|
||||
"telephone": "02112345678",
|
||||
"map": { "latitude": "35.699", "longitude": "51.337" },
|
||||
"city": { "id": "1", "name": "تهران" },
|
||||
"province": { "id": "8", "name": "تهران" }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/clinic/{clinicUuid}/address`
|
||||
|
||||
**Permission:** Clinic owner or `ROLE_ADMIN`
|
||||
|
||||
Creates a new address for the clinic. The address will appear in `available-locations` for doctors belonging to this clinic.
|
||||
|
||||
#### Request
|
||||
```json
|
||||
{
|
||||
"name": "شعبه مرکزی",
|
||||
"address": "تهران، خیابان ولیعصر...",
|
||||
"telephone": "02112345678",
|
||||
"latitude": 35.699,
|
||||
"longitude": 51.337,
|
||||
"city_id": 123,
|
||||
"province_id": 7
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Required |
|
||||
|-------|------|----------|
|
||||
| `name` | string | ❌ |
|
||||
| `address` | string | ❌ |
|
||||
| `telephone` | string | ❌ |
|
||||
| `latitude` | float | ❌ |
|
||||
| `longitude` | float | ❌ |
|
||||
| `city_id` | integer | ❌ |
|
||||
| `province_id` | integer | ❌ |
|
||||
|
||||
#### Response `201`
|
||||
```json
|
||||
{ "success": true, "data": { "id": "12", "uuid": "...", "type": "clinic", ... } }
|
||||
```
|
||||
|
||||
#### Errors
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_AUTH_006` | 403 | Not the clinic owner |
|
||||
| `ERR_VALIDATION_002` | 404 | Clinic not found |
|
||||
|
||||
---
|
||||
|
||||
### `PATCH /api/v1/clinic/{clinicUuid}/address/{addressUuid}`
|
||||
|
||||
**Permission:** Clinic owner or `ROLE_ADMIN`
|
||||
|
||||
Updates an existing clinic address. Same body fields as POST (all optional).
|
||||
|
||||
#### Response `200`
|
||||
```json
|
||||
{ "success": true, "data": { ... } }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `DELETE /api/v1/clinic/{clinicUuid}/address/{addressUuid}`
|
||||
|
||||
**Permission:** Clinic owner or `ROLE_ADMIN`
|
||||
|
||||
Deletes a clinic address.
|
||||
|
||||
> A clinic must retain at least one address — attempting to delete the last address returns `409`.
|
||||
|
||||
#### Errors
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_CONFLICT_001` | 409 | Cannot delete the last address |
|
||||
| `ERR_VALIDATION_002` | 404 | Address or clinic not found |
|
||||
| `ERR_AUTH_006` | 403 | Not the clinic owner |
|
||||
|
||||
---
|
||||
|
||||
### Removed endpoint
|
||||
`POST /api/v1/clinic-pro/doctor-address/from-clinic/{clinicUuid}` — **removed**. Use clinic address management endpoints instead.
|
||||
|
||||
Reference in New Issue
Block a user