Spaces:
Sleeping
Sleeping
Update api/routes.py
Browse files- api/routes.py +19 -1
api/routes.py
CHANGED
|
@@ -192,7 +192,25 @@ async def list_doctor_appointments(current_user: dict = Depends(get_current_user
|
|
| 192 |
raise HTTPException(status_code=403, detail="Only doctors can view this")
|
| 193 |
|
| 194 |
cursor = appointments_collection.find({"doctor_id": {"$exists": True}})
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
# --- LIST PATIENT'S APPOINTMENTS ---
|
| 198 |
@router.get("/appointments/patient")
|
|
|
|
| 192 |
raise HTTPException(status_code=403, detail="Only doctors can view this")
|
| 193 |
|
| 194 |
cursor = appointments_collection.find({"doctor_id": {"$exists": True}})
|
| 195 |
+
appointments = []
|
| 196 |
+
|
| 197 |
+
async for a in cursor:
|
| 198 |
+
patient = await users_collection.find_one({"_id": a["patient_id"]})
|
| 199 |
+
patient_info = {
|
| 200 |
+
"full_name": patient.get("full_name", ""),
|
| 201 |
+
"email": patient.get("email", ""),
|
| 202 |
+
} if patient else {}
|
| 203 |
+
|
| 204 |
+
appointments.append({
|
| 205 |
+
"_id": str(a["_id"]),
|
| 206 |
+
"doctor_id": str(a["doctor_id"]),
|
| 207 |
+
"patient": patient_info,
|
| 208 |
+
"date": a["date"].strftime("%Y-%m-%d") if isinstance(a["date"], datetime) else a["date"],
|
| 209 |
+
"time": a["time"],
|
| 210 |
+
"reason": a["reason"]
|
| 211 |
+
})
|
| 212 |
+
|
| 213 |
+
return appointments
|
| 214 |
|
| 215 |
# --- LIST PATIENT'S APPOINTMENTS ---
|
| 216 |
@router.get("/appointments/patient")
|