Spaces:
Sleeping
Sleeping
Update api/routes.py
Browse files- api/routes.py +10 -5
api/routes.py
CHANGED
|
@@ -161,13 +161,18 @@ async def delete_patient(patient_id: str, current_user: dict = Depends(get_curre
|
|
| 161 |
@router.get("/patients/count")
|
| 162 |
async def count_patients(current_user: dict = Depends(get_current_user)):
|
| 163 |
try:
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
return {"count": count}
|
| 169 |
except Exception as e:
|
| 170 |
-
print("❌
|
| 171 |
raise HTTPException(status_code=500, detail="Failed to count patients")
|
| 172 |
|
| 173 |
|
|
|
|
| 161 |
@router.get("/patients/count")
|
| 162 |
async def count_patients(current_user: dict = Depends(get_current_user)):
|
| 163 |
try:
|
| 164 |
+
email = current_user["email"]
|
| 165 |
+
print("🧪 Counting patients for email:", email)
|
| 166 |
+
|
| 167 |
+
filter_query = { "created_by": email }
|
| 168 |
+
print("🔍 Mongo filter:", filter_query)
|
| 169 |
+
|
| 170 |
+
count = await patients_collection.count_documents(filter_query)
|
| 171 |
+
print("✅ Count result:", count)
|
| 172 |
+
|
| 173 |
return {"count": count}
|
| 174 |
except Exception as e:
|
| 175 |
+
print("❌ Exception in /patients/count:", repr(e))
|
| 176 |
raise HTTPException(status_code=500, detail="Failed to count patients")
|
| 177 |
|
| 178 |
|