From 8eaa3c3059f3d5d37f92ca6b76395aaa72e38de7 Mon Sep 17 00:00:00 2001 From: yaso-meth Date: Sat, 6 Apr 2024 12:48:01 +0200 Subject: [PATCH] Add API to get user details --- backend/routers/docOffices.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/routers/docOffices.py b/backend/routers/docOffices.py index abd5bfc7..e148badd 100644 --- a/backend/routers/docOffices.py +++ b/backend/routers/docOffices.py @@ -19,6 +19,23 @@ async def read_docOfficeByID(docOffic_id: int): return {"iddoctor_offices": item[0], "office_name": item[1]} +# Get Doctors Office By user +@router.get("/docOffices/user/{user}", tags="DocOffice") +async def read_docOfficeByID(user: str): + db = dbConnection.dbConnect() + cursor = db.cursor() + query = "SELECT * FROM users WHERE email=%s" + cursor.execute(query, (user,)) + item = cursor.fetchone() + cursor.close() + db.close() + if item is None: + raise HTTPException(status_code=404, detail="Item not found") + return {"idusers": item[0], + "email": item[1], + "docOffice_id": item[2], + } + # Get List of all Doctors Office @router.get("/docOffices/", tags="DocOffice") async def read_All_DoctorsOffice():