Spaces:
Sleeping
Sleeping
Update api/routes.py
Browse files- api/routes.py +10 -4
api/routes.py
CHANGED
|
@@ -160,8 +160,14 @@ async def delete_patient(patient_id: str, current_user: dict = Depends(get_curre
|
|
| 160 |
# --- COUNT PATIENTS BY DOCTOR ---
|
| 161 |
@router.get("/patients/count")
|
| 162 |
async def count_patients(current_user: dict = Depends(get_current_user)):
|
| 163 |
-
|
| 164 |
-
"
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
|
|
|
| 160 |
# --- COUNT PATIENTS BY DOCTOR ---
|
| 161 |
@router.get("/patients/count")
|
| 162 |
async def count_patients(current_user: dict = Depends(get_current_user)):
|
| 163 |
+
try:
|
| 164 |
+
print("👤 Counting patients for:", current_user["email"])
|
| 165 |
+
count = await patients_collection.count_documents({
|
| 166 |
+
"created_by": current_user["email"]
|
| 167 |
+
})
|
| 168 |
+
return {"count": count}
|
| 169 |
+
except Exception as e:
|
| 170 |
+
print("❌ Error in count_documents:", str(e))
|
| 171 |
+
raise HTTPException(status_code=500, detail="Failed to count patients")
|
| 172 |
+
|
| 173 |
|