Add API to get patients by user email
This commit is contained in:
@@ -55,6 +55,65 @@ async def read_patientByID(id_no: str):
|
|||||||
"address": item[9],
|
"address": item[9],
|
||||||
"doc_office_id": item[10]}
|
"doc_office_id": item[10]}
|
||||||
|
|
||||||
|
# # Get Patient By ID Number
|
||||||
|
# @router.get("/patients/user/{email}", tags="patients")
|
||||||
|
# async def read_patientByID(email: str):
|
||||||
|
# db = dbConnection.dbConnect()
|
||||||
|
# cursor = db.cursor()
|
||||||
|
# #query = "SELECT * FROM patients WHERE id_no=%s"
|
||||||
|
# query = "Select * from patients "
|
||||||
|
# query += "inner join users "
|
||||||
|
# query += "on doc_office_id = docOffice_id "
|
||||||
|
# query += "where users.email= %s"
|
||||||
|
# cursor.execute(query, (email,))
|
||||||
|
# item = cursor.fetchone()
|
||||||
|
# cursor.close()
|
||||||
|
# db.close()
|
||||||
|
# if item is None:
|
||||||
|
# raise HTTPException(status_code=404, detail="Item not found")
|
||||||
|
# return {"idpatients": item[0],
|
||||||
|
# "id_no": item[1],
|
||||||
|
# "first_name": item[2],
|
||||||
|
# "last_name": item[3],
|
||||||
|
# "email": item[4],
|
||||||
|
# "cell_no": item[5],
|
||||||
|
# "medical_aid_name": item[6],
|
||||||
|
# "medical_aid_no": item[7],
|
||||||
|
# "medical_aid_scheme": item[8],
|
||||||
|
# "address": item[9],
|
||||||
|
# "doc_office_id": item[10]}
|
||||||
|
|
||||||
|
# Get List of all patients
|
||||||
|
@router.get("/patients/user/{email}", tags="patients")
|
||||||
|
async def read_all_patientsByUser(email: str):
|
||||||
|
db = dbConnection.dbConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
#query = "SELECT * FROM patients"
|
||||||
|
query = "Select * from patients "
|
||||||
|
query += "inner join users "
|
||||||
|
query += "on doc_office_id = docOffice_id "
|
||||||
|
query += "where users.email= %s"
|
||||||
|
cursor.execute(query, (email,))
|
||||||
|
items = [
|
||||||
|
{
|
||||||
|
"idpatients": item[0],
|
||||||
|
"id_no": item[1],
|
||||||
|
"first_name": item[2],
|
||||||
|
"last_name": item[3],
|
||||||
|
"email": item[4],
|
||||||
|
"cell_no": item[5],
|
||||||
|
"medical_aid_name": item[6],
|
||||||
|
"medical_aid_no": item[7],
|
||||||
|
"medical_aid_scheme": item[8],
|
||||||
|
"address": item[9],
|
||||||
|
"doc_office_id": item[10]
|
||||||
|
}
|
||||||
|
for item in cursor.fetchall()
|
||||||
|
]
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return items
|
||||||
|
|
||||||
# Get List of all patients
|
# Get List of all patients
|
||||||
@router.get("/patients/", tags="patients")
|
@router.get("/patients/", tags="patients")
|
||||||
async def read_all_patients():
|
async def read_all_patients():
|
||||||
|
|||||||
Reference in New Issue
Block a user