Ali2206 commited on
Commit
7aba3e5
·
verified ·
1 Parent(s): 848bdfb

Update api/routes.py

Browse files
Files changed (1) hide show
  1. 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
- count = await patients_collection.count_documents({
164
- "created_by": current_user["email"]
165
- })
166
- return {"count": count}
 
 
 
 
 
 
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