Spaces:
Sleeping
Sleeping
Update api/routes.py
Browse files- api/routes.py +17 -0
api/routes.py
CHANGED
|
@@ -53,6 +53,23 @@ async def create_doctor(data: DoctorCreate):
|
|
| 53 |
await users_collection.insert_one(user_doc)
|
| 54 |
return {"success": True, "message": "Doctor account created"}
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
# --- LOGIN ---
|
| 57 |
@router.post("/login", response_model=TokenResponse)
|
| 58 |
async def login(form_data: OAuth2PasswordRequestForm = Depends()):
|
|
|
|
| 53 |
await users_collection.insert_one(user_doc)
|
| 54 |
return {"success": True, "message": "Doctor account created"}
|
| 55 |
|
| 56 |
+
# --- GET ALL DOCTORS ---
|
| 57 |
+
@router.get("/doctors")
|
| 58 |
+
async def list_doctors():
|
| 59 |
+
cursor = users_collection.find({"role": "doctor"})
|
| 60 |
+
doctors = []
|
| 61 |
+
async for doc in cursor:
|
| 62 |
+
doctors.append({
|
| 63 |
+
"id": str(doc["_id"]),
|
| 64 |
+
"full_name": doc.get("full_name", ""),
|
| 65 |
+
"email": doc.get("email", ""),
|
| 66 |
+
"matricule": doc.get("matricule", ""),
|
| 67 |
+
"specialty": doc.get("specialty", ""),
|
| 68 |
+
"created_at": doc.get("created_at"),
|
| 69 |
+
})
|
| 70 |
+
return doctors
|
| 71 |
+
|
| 72 |
+
|
| 73 |
# --- LOGIN ---
|
| 74 |
@router.post("/login", response_model=TokenResponse)
|
| 75 |
async def login(form_data: OAuth2PasswordRequestForm = Depends()):
|