- Added StaffController for managing clinic staff, including listing, creating, updating, and toggling staff status. - Created ClinicStaff entity and repository for staff data handling. - Developed SubscriptionController to manage subscription plans and periods, including trial subscriptions. - Introduced SubscriptionPlan, SubscriptionPeriod, and ClinicSubscription entities for subscription management. - Implemented SubscriptionService for handling subscription logic, including trial activation and subscription creation from payments. - Added necessary repositories for subscription entities to facilitate data access and manipulation.
6.0 KiB
6.0 KiB
Dashboard API
Role-specific dashboard endpoints. Each endpoint requires the corresponding role JWT.
GET /api/v1/dashboard/clinic
Returns stats and today's schedule for the authenticated clinic owner.
Auth: ROLE_CLINIC required
Query params
| Param | Type | Default | Description |
|---|---|---|---|
from |
int (unix) | start of current month | Period start for patient/revenue stats |
to |
int (unix) | now | Period end for patient/revenue stats |
Response 200
{
"success": true,
"data": {
"clinic": {
"uuid": "string",
"name": "string",
"is_active": true,
"logo": "string | null"
},
"stats": {
"total_doctors": 5,
"today_appointments": 12,
"this_month_appointments": 87,
"pending_invitations": 2,
"sms_wallet_balance": 50000,
"unique_patients_count": 34,
"revenue_period_rials": 12500000
},
"period": { "from": 1717200000, "to": 1719792000 },
"today_appointments": [
{
"uuid": "string",
"patient_name": "string | null",
"doctor_name": "string",
"slot_start": 1700000000,
"status": "reserved"
}
],
"doctors": [
{
"uuid": "string",
"name": "string",
"today_count": 3
}
]
}
}
Field notes:
sms_wallet_balance— current SMS wallet balance in Rials (0 if wallet not yet created)unique_patients_count— distinct patients with at least one session in thefrom–toperiodrevenue_period_rials— sum offinal_price_rialsfrom all patient sessions in the periodtoday_appointments— up to 5 records, ordered byslot_start ASCdoctors— all doctors belonging to this clinic; each includes their appointment count for today
Errors
| Code | HTTP | Description |
|---|---|---|
ERR_NOT_FOUND_001 |
404 | Clinic not found for this user |
GET /api/v1/dashboard/doctor
Returns stats and today's schedule for the authenticated doctor.
Auth: ROLE_DOCTOR required
Query params
| Param | Type | Default | Description |
|---|---|---|---|
from |
int (unix) | start of current month | Period start for patient/revenue stats |
to |
int (unix) | now | Period end for patient/revenue stats |
Response 200
{
"success": true,
"data": {
"doctor": {
"uuid": "string",
"name": "string",
"degree": "string | null"
},
"stats": {
"today_appointments": 8,
"tomorrow_appointments": 5,
"this_month_appointments": 62,
"avg_rating": 4.6,
"total_ratings": 34,
"sms_wallet_balance": 25000,
"unique_patients_count": 18,
"revenue_period_rials": 6800000
},
"period": { "from": 1717200000, "to": 1719792000 },
"today_appointments": [
{
"uuid": "string",
"patient_name": "string | null",
"patient_mobile": "string",
"slot_start": 1700000000,
"status": "reserved"
}
],
"clinics": [
{
"uuid": "string",
"name": "string",
"logo": "string | null"
}
]
}
}
Field notes:
today_appointments— up to 10 records, ordered byslot_start ASCavg_rating— rounded to 1 decimal;nullif no ratings yetclinics— all clinics the doctor belongs tosms_wallet_balance,unique_patients_count,revenue_period_rials— same semantics as clinic dashboard
Errors
| Code | HTTP | Description |
|---|---|---|
ERR_NOT_FOUND_001 |
404 | Doctor profile not found for this user |
GET /api/v1/dashboard/secretary
Returns stats for the authenticated secretary and (conditionally) today's appointments.
Auth: ROLE_SECRETARY required
Response 200
{
"success": true,
"data": {
"doctor": {
"uuid": "string",
"name": "string",
"degree": "string | null"
},
"permissions": {
"resources": {
"appointments": {
"view": true,
"edit": false
}
}
},
"stats": {
"today_appointments": 8,
"tomorrow_appointments": 5
},
"today_appointments": [
{
"uuid": "string",
"patient_name": "string | null",
"patient_mobile": "string",
"slot_start": 1700000000,
"status": "reserved"
}
]
}
}
today_appointments — only populated when permissions.resources.appointments.view === true; up to 10 records when visible.
Errors
| Code | HTTP | Description |
|---|---|---|
ERR_FORBIDDEN_001 |
403 | Secretary relation not configured or inactive |
GET /api/v1/admin/dashboard/charts
Returns time-series chart data for admin dashboard. All series are filtered to the given from–to window.
Auth: ROLE_ADMIN required
Query params
| Param | Type | Default | Description |
|---|---|---|---|
from |
int (unix) | 30 days ago | Period start |
to |
int (unix) | now | Period end |
Response 200
{
"success": true,
"data": {
"appointments_by_day": [
{ "date": "06/01", "count": 12 }
],
"revenue_by_day": [
{ "date": "06/01", "amount": 3500000 }
],
"appointment_status": [
{ "status": "confirmed", "count": 320 }
],
"top_specialties": [
{ "name": "قلب و عروق", "count": 85 }
],
"subscription_sales_by_plan": [
{ "plan": "basic", "count": 14, "revenue": 4060000 }
],
"period": { "from": 1717200000, "to": 1719792000 }
}
}
Field notes:
appointments_by_day/revenue_by_day— one entry per calendar day in the period; days with no data appear ascount: 0/amount: 0appointment_status— all-time counts, not filtered by periodtop_specialties— top 8 by appointment volume, all-timesubscription_sales_by_plan— subscriptions created in period, grouped by plan;revenuesums only payments with statusreceived