feat: implement doctor invitation acceptance logic to add doctors to clinic_doctors
This commit is contained in:
@@ -261,7 +261,9 @@ View invitation details by token (used on the doctor-facing landing page).
|
||||
|
||||
## POST `/api/v1/clinic-invitation/{token}/accept`
|
||||
|
||||
Doctor accepts the invitation. If a doctor profile exists for this mobile, they are automatically linked to the clinic.
|
||||
Doctor accepts the invitation via SMS link.
|
||||
|
||||
**Side-effect:** If a doctor profile exists for this mobile, they are added to `clinic_doctors`. If the invitation's doctor FK was null (doctor registered after invite), the match is resolved at accept time using the mobile number.
|
||||
|
||||
**Permission:** `PUBLIC`
|
||||
|
||||
@@ -282,7 +284,7 @@ Doctor accepts the invitation. If a doctor profile exists for this mobile, they
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_NOT_FOUND_001` | 404 | Token not found |
|
||||
| `ERR_VALIDATION_001` | 422 | Token expired or already used |
|
||||
| `ERR_NOT_FOUND_001` | 410 | Token expired or already used |
|
||||
|
||||
---
|
||||
|
||||
@@ -309,4 +311,77 @@ Doctor rejects the invitation.
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_NOT_FOUND_001` | 404 | Token not found |
|
||||
| `ERR_VALIDATION_001` | 422 | Token expired or already used |
|
||||
| `ERR_NOT_FOUND_001` | 410 | Token expired or already used |
|
||||
|
||||
---
|
||||
|
||||
## GET `/api/v1/doctor/invitations`
|
||||
|
||||
Returns all pending invitations for the authenticated doctor.
|
||||
|
||||
**Permission:** `ROLE_DOCTOR`
|
||||
|
||||
### Response `200`
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": [
|
||||
{
|
||||
"uuid": "...",
|
||||
"mobile": "09xxxxxxxxx",
|
||||
"invited_name": "دکتر علی",
|
||||
"invited_specialty": "قلب",
|
||||
"status": "pending",
|
||||
"token_used": false,
|
||||
"invited_at": 1718000000,
|
||||
"expires_at": 1718259200,
|
||||
"responded_at": null,
|
||||
"doctor": { "uuid": "...", "name": "علی احمدی" },
|
||||
"clinic": { "uuid": "...", "name": "کلینیک نور", "logo": null }
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Errors
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_NOT_FOUND_001` | 404 | Doctor profile not found for user |
|
||||
|
||||
---
|
||||
|
||||
## POST `/api/v1/doctor/invitation/{invUuid}/respond`
|
||||
|
||||
Doctor accepts or rejects an invitation from their panel (no SMS token needed).
|
||||
|
||||
**Permission:** `ROLE_DOCTOR`
|
||||
|
||||
**Side-effect on accept:** Doctor is added to `clinic_doctors`. If doctor FK was null at invite time, it is resolved via mobile number at respond time.
|
||||
|
||||
### Path Parameters
|
||||
| Param | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `invUuid` | string | UUID of the invitation |
|
||||
|
||||
### Request Body
|
||||
```json
|
||||
{ "action": "accept" }
|
||||
```
|
||||
| Field | Type | Values |
|
||||
|-------|------|--------|
|
||||
| `action` | string | `accept` \| `reject` |
|
||||
|
||||
### Response `200`
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": { "message": "دعوتنامه پذیرفته شد" }
|
||||
}
|
||||
```
|
||||
|
||||
### Errors
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `ERR_NOT_FOUND_001` | 404 | Invitation not found or not owned by doctor |
|
||||
| `ERR_NOT_FOUND_001` | 410 | Invitation expired or already used |
|
||||
| `ERR_VALIDATION_001` | 422 | action is not accept or reject |
|
||||
|
||||
Reference in New Issue
Block a user