add api to fetch patient via email
This commit is contained in:
@@ -93,6 +93,31 @@ 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/{email}", tags="patients")
|
||||||
|
async def read_patientByID(id_no: str):
|
||||||
|
db = database.dbConnection.dbConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "SELECT * FROM patients WHERE email=%s"
|
||||||
|
cursor.execute(query, (id_no,))
|
||||||
|
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
|
# Get List of all patients
|
||||||
@router.get("/patients/user/{email}", tags="patients")
|
@router.get("/patients/user/{email}", tags="patients")
|
||||||
async def read_all_patientsByUser(email: str, session: SessionContainer = Depends(verify_session())):
|
async def read_all_patientsByUser(email: str, session: SessionContainer = Depends(verify_session())):
|
||||||
|
|||||||
Reference in New Issue
Block a user