diff --git a/backend/routers/docOffices.py b/backend/routers/docOffices.py index 55322139..9a1e4c62 100644 --- a/backend/routers/docOffices.py +++ b/backend/routers/docOffices.py @@ -12,8 +12,8 @@ import database.dbConnection router = APIRouter() # Get Doctors Office By ID -@router.get("/docOffices/{docOffic_id}", tags="DocOffice") -async def read_docOfficeByID(docOffic_id: int, session: SessionContainer = Depends(verify_session())): +@router.get("/docOffices/{docOffic_id}", tags=["Doctor Office"]) +async def read_docOffice_By_ID(docOffic_id: int, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM doctor_offices WHERE iddoctor_offices=%s" @@ -27,8 +27,8 @@ async def read_docOfficeByID(docOffic_id: int, session: SessionContainer = Depen "office_name": item[1]} # Get Doctors Office By user -@router.get("/docOffices/user/{user}", tags="DocOffice") -async def read_docOfficeByID(user: str, session: SessionContainer = Depends(verify_session())): +@router.get("/docOffices/user/{user}", tags=["Doctor Office"]) +async def read_docOffice_By_ID(user: str, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM users WHERE email=%s" @@ -48,8 +48,8 @@ async def read_docOfficeByID(user: str, session: SessionContainer = Depends(veri } # Get List of all Doctors Office -@router.get("/docOffices/", tags="DocOffice") -async def read_All_DoctorsOffice(session: SessionContainer = Depends(verify_session())): +@router.get("/docOffices/", tags=["Doctor Office"]) +async def read_All_Doctors_Office(session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM doctor_offices" diff --git a/backend/routers/fileStorage.py b/backend/routers/fileStorage.py index c3514e24..d56b73b1 100644 --- a/backend/routers/fileStorage.py +++ b/backend/routers/fileStorage.py @@ -1,4 +1,4 @@ -from fastapi import APIRouter, HTTPException, File, UploadFile +from fastapi import APIRouter, HTTPException, File, UploadFile, Form import requests from pydantic import BaseModel from minio import Minio @@ -22,10 +22,20 @@ class medCertUploud(BaseModel): endDate: str returnDate: str -#=================understand Supertoken multirequest for file submission================================ +@router.post("/minio/upload/file/", tags=["Minio"]) +async def upload_File_to_user(file: UploadFile = File(...), app_id: str= Form(...)): + extension = file.filename.split(".") + return { + "app_id": app_id, + "file_name": file.filename, + "file_extension": extension, + "file_size": file.size, + "content":file + } + # Get List of all files by patient -@router.post("/files/upload/file/", tags="patients_files") -async def generateAndUploudMedCert( file: UploadFile = File(...)): +@router.post("/files/upload/file/", tags=["Minio"]) +async def upload_File_to_user( file: UploadFile = File(...)): extension = file.filename.split(".") print(file.file) print(file.filename) @@ -35,9 +45,11 @@ async def generateAndUploudMedCert( file: UploadFile = File(...)): return {"message": "Successfully Uploaded File"} + + # Get List of all files by patient -@router.post("/files/generate/med-cert/", tags="patients_files") -async def generateAndUploudMedCert(requestItem: medCertUploud, session: SessionContainer = Depends(verify_session())): +@router.post("/files/generate/med-cert/", tags=["Minio"]) +async def upload_File_to_user(requestItem: medCertUploud, session: SessionContainer = Depends(verify_session())): uploudMedCert(requestItem.fullName, requestItem.docfname, requestItem.startDate, @@ -45,6 +57,10 @@ async def generateAndUploudMedCert(requestItem: medCertUploud, session: SessionC requestItem.returnDate) return {"message": "Successfully Generated File"} + + + + def uploudFile(fileName, extension, content, size): client = Minio("minio:9000", access_key="user1", diff --git a/backend/routers/medicine.py b/backend/routers/medicine.py index e9cfd5c1..bb30ad6e 100644 --- a/backend/routers/medicine.py +++ b/backend/routers/medicine.py @@ -14,13 +14,13 @@ class medicine(BaseModel): unit: str #get all medicines -@router.get("/users/medicine/all", tags="medicine") +@router.get("/users/medicine/all", tags=["Medicine"]) async def read_all_medicine(session: SessionContainer = Depends(verify_session())): return getMedicineData("") #get all medicines by search -@router.get("/users/medicine/{medSearch}", tags="medicine") -async def read_all_medicine(medSearch: str, session: SessionContainer = Depends(verify_session())): +@router.get("/users/medicine/{medSearch}", tags=["Medicine"]) +async def read_medicineby_search(medSearch: str, session: SessionContainer = Depends(verify_session())): return getMedicineData(medSearch) def getMedicineData(medsearch: str): diff --git a/backend/routers/patients.py b/backend/routers/patients.py index dc3edc10..b5fcb6f4 100644 --- a/backend/routers/patients.py +++ b/backend/routers/patients.py @@ -69,8 +69,8 @@ class patientDeleteRequest(BaseModel): # Get Patient By app ID -@router.get("/patients/{app_id}", tags="patients") -async def read_patientByID(app_id: str, session: SessionContainer = Depends(verify_session())): +@router.get("/patients/{app_id}", tags=["Patients"]) +async def read_patient_By_app_ID(app_id: str, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patients WHERE app_id=%s" @@ -211,8 +211,8 @@ async def read_patientByID(app_id: str, session: SessionContainer = Depends(veri # return items # Insert Patient into table -@router.post("/patients/insert/", tags="patients", status_code=201) -async def insertPatient(itemRequest : patientInsertRequest, session: SessionContainer = Depends(verify_session())): +@router.post("/patients/insert/", tags=["Patients"], status_code=201) +async def insert_Patient(itemRequest : patientInsertRequest, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "insert into patients " @@ -244,8 +244,8 @@ async def insertPatient(itemRequest : patientInsertRequest, session: SessionCont return {"message": "Successfully Created Record"} # Update Patient on table -@router.put("/patients/update/", tags="patients") -async def UpdatePatient(itemRequest : patientUpdateRequest, session: SessionContainer = Depends(verify_session())): +@router.put("/patients/update/", tags=["Patients"]) +async def Update_Patient(itemRequest : patientUpdateRequest, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "update patients " @@ -278,8 +278,8 @@ async def UpdatePatient(itemRequest : patientUpdateRequest, session: SessionCont return {"message": "Successfully Updated Record"} # delete Patient on table -@router.delete("/patients/delete/", tags="patients") -async def DeletePatient(itemRequest : patientDeleteRequest, session: SessionContainer = Depends(verify_session())): +@router.delete("/patients/delete/", tags=["Patients"]) +async def Delete_Patient(itemRequest : patientDeleteRequest, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "delete from patients " diff --git a/backend/routers/patients_files.py b/backend/routers/patients_files.py index 16637be5..0837fb6a 100644 --- a/backend/routers/patients_files.py +++ b/backend/routers/patients_files.py @@ -42,8 +42,8 @@ class fileInsertRequest(BaseModel): # return items # Get List of all files by patient -@router.get("/files/patients/{app_id}", tags="patients_files") -async def read_all_files_by_patient(app_id: str, session: SessionContainer = Depends(verify_session())): +@router.get("/files/patients/{app_id}", tags=["Patients Files"]) +async def read_all_patient_files_by_app_id(app_id: str, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patient_files where app_id = %s ORDER BY insert_date DESC" diff --git a/backend/routers/patients_notes.py b/backend/routers/patients_notes.py index 2afbe02f..3c159219 100644 --- a/backend/routers/patients_notes.py +++ b/backend/routers/patients_notes.py @@ -47,8 +47,8 @@ class patientNoteUpdateRequest(BaseModel): # return items # Get List of all notes by patient -@router.get("/notes/patients/{app_id}", tags="patients_notes") -async def read_all_patientsby(app_id: str, session: SessionContainer = Depends(verify_session())): +@router.get("/notes/patients/{app_id}", tags=["Patients Notes"]) +async def read_all_patient_notes_by_app_id(app_id: str, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbConnect() cursor = db.cursor() query = "SELECT * FROM patient_notes where app_id = %s ORDER BY insert_date DESC" @@ -92,8 +92,8 @@ async def read_all_patientsby(app_id: str, session: SessionContainer = Depends(v # return items # Insert Patient note into table -@router.post("/notes/insert/", tags="patients_notes", status_code=201) -async def insertPatientNotes(itemRequest : patientNoteInsertRequest, session: SessionContainer = Depends(verify_session())): +@router.post("/notes/insert/", tags=["Patients Notes"], status_code=201) +async def insert_Patient_Note(itemRequest : patientNoteInsertRequest, session: SessionContainer = Depends(verify_session())): today = date.today() db = database.dbConnection.dbConnect() cursor = db.cursor() diff --git a/backend/routers/users.py b/backend/routers/users.py index 1cae1d47..b54bc9b3 100644 --- a/backend/routers/users.py +++ b/backend/routers/users.py @@ -74,12 +74,12 @@ class userUpdateRequest(BaseModel): # return items # Get List of all files -@router.get("/user/{uid}", tags="users") -async def read_all_users(uid: str, session: SessionContainer = Depends(verify_session())): +@router.get("/user/{app_id}", tags=["MIH Users"]) +async def read_users_by_app_id(app_id: str, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() query = "SELECT * FROM users where app_id = %s" - cursor.execute(query, (uid,)) + cursor.execute(query, (app_id,)) items = [ { "idUser": item[0], @@ -97,8 +97,8 @@ async def read_all_users(uid: str, session: SessionContainer = Depends(verify_se return items[0] # Insert Patient into table -@router.post("/user/insert/", tags="user", status_code=201) -async def insertPatient(itemRequest : userInsertRequest, session: SessionContainer = Depends(verify_session())): +@router.post("/user/insert/", tags=["MIH Users"], status_code=201) +async def insert_User_details(itemRequest : userInsertRequest, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() query = "insert into users " @@ -117,8 +117,8 @@ async def insertPatient(itemRequest : userInsertRequest, session: SessionContain return {"message": "Successfully Created Record"} # Update User on table -@router.put("/user/update/", tags="user") -async def UpdateUser(itemRequest : userUpdateRequest, session: SessionContainer = Depends(verify_session())): +@router.put("/user/update/", tags=["MIH Users"]) +async def Update_User_details(itemRequest : userUpdateRequest, session: SessionContainer = Depends(verify_session())): db = database.dbConnection.dbAppDataConnect() cursor = db.cursor() query = "update users "