add revoke date & add a update access api
This commit is contained in:
@@ -11,8 +11,11 @@ from fastapi import Depends
|
|||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
# class fileDeleteRequest(BaseModel):
|
class accessUpdateRequest(BaseModel):
|
||||||
# idpatient_files: int
|
business_id: str
|
||||||
|
app_id: str
|
||||||
|
date_time: str
|
||||||
|
access: str
|
||||||
|
|
||||||
# class queueInsertRequest(BaseModel):
|
# class queueInsertRequest(BaseModel):
|
||||||
# business_id: str
|
# business_id: str
|
||||||
@@ -21,13 +24,13 @@ router = APIRouter()
|
|||||||
# time: str
|
# time: str
|
||||||
# access: str
|
# access: str
|
||||||
|
|
||||||
@router.get("/access/requests/{app_id}", tags=["Access Requests"])
|
@router.get("/access-requests/{app_id}", tags=["Access Requests"])
|
||||||
async def read_all_access_request_by_app_id(app_id: str): #, session: SessionContainer = Depends(verify_session())
|
async def read_all_access_request_by_app_id(app_id: str, session: SessionContainer = Depends(verify_session())): #, session: SessionContainer = Depends(verify_session())
|
||||||
db = database.dbConnection.dbPatientManagerConnect()
|
db = database.dbConnection.dbPatientManagerConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "SELECT patient_queue.idpatient_queue, patient_queue.business_id, "
|
query = "SELECT patient_queue.idpatient_queue, patient_queue.business_id, "
|
||||||
query += "patient_queue.app_id, patient_queue.date_time, patient_queue.access, "
|
query += "patient_queue.app_id, patient_queue.date_time, patient_queue.access, patient_queue.revoke_date, "
|
||||||
query += "business.Name, business.type, business.logo_path "
|
query += "business.Name, business.type, business.logo_path, business.contact_no "
|
||||||
query += "from patient_manager.patient_queue "
|
query += "from patient_manager.patient_queue "
|
||||||
query += "inner join app_data.business "
|
query += "inner join app_data.business "
|
||||||
query += "on patient_queue.business_id = business.business_id "
|
query += "on patient_queue.business_id = business.business_id "
|
||||||
@@ -40,9 +43,11 @@ async def read_all_access_request_by_app_id(app_id: str): #, session: SessionCon
|
|||||||
"app_id": item[2],
|
"app_id": item[2],
|
||||||
"date_time": item[3],
|
"date_time": item[3],
|
||||||
"access": item[4],
|
"access": item[4],
|
||||||
"Name": item[5],
|
"revoke_date": item[5],
|
||||||
"type": item[6],
|
"Name": item[6],
|
||||||
"logo_path": item[7],
|
"type": item[7],
|
||||||
|
"logo_path": item[8],
|
||||||
|
"contact_no": item[9],
|
||||||
}
|
}
|
||||||
for item in cursor.fetchall()
|
for item in cursor.fetchall()
|
||||||
]
|
]
|
||||||
@@ -50,6 +55,29 @@ async def read_all_access_request_by_app_id(app_id: str): #, session: SessionCon
|
|||||||
db.close()
|
db.close()
|
||||||
return items
|
return items
|
||||||
|
|
||||||
|
@router.put("/access-requests/update/", tags=["Access Requests"])
|
||||||
|
async def Update_access_request_approcal(itemRequest : accessUpdateRequest): #, session: SessionContainer = Depends(verify_session())
|
||||||
|
db = database.dbConnection.dbPatientManagerConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "update patient_queue "
|
||||||
|
query += "set access=%s"
|
||||||
|
query += "where business_id=%s "
|
||||||
|
query += "and app_id=%s "
|
||||||
|
query += "and date_time=%s "
|
||||||
|
userData = (itemRequest.access,
|
||||||
|
itemRequest.business_id,
|
||||||
|
itemRequest.app_id,
|
||||||
|
itemRequest.date_time)
|
||||||
|
try:
|
||||||
|
cursor.execute(query, userData)
|
||||||
|
except Exception as error:
|
||||||
|
raise HTTPException(status_code=404, detail=error)
|
||||||
|
#return {"query": query, "message": error}
|
||||||
|
db.commit()
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return {"message": "Successfully Updated Record"}
|
||||||
|
|
||||||
# # Get List of all files
|
# # Get List of all files
|
||||||
# @router.get("/files/patients/", tags="patients_files")
|
# @router.get("/files/patients/", tags="patients_files")
|
||||||
# async def read_all_files(session: SessionContainer = Depends(verify_session())):
|
# async def read_all_files(session: SessionContainer = Depends(verify_session())):
|
||||||
|
|||||||
Reference in New Issue
Block a user