Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 35 additions & 30 deletions appointment/app/api/appointment_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from appointment.app.db import get_db
from doctor.app.db import get_db as get_doctor_db
from patient.app.db import get_db as get_patient_db
from patient_report.app.db import get_db as get_patient_report_db
from medicine.app.db import get_db as get_medicine_db

from appointment.app.api import controller

Expand All @@ -29,13 +31,13 @@ async def create_file(file=File(None),filepath=str):
async def add_new_appointment(first_name: str = Form(), last_name: str = Form(),
mobile_number: str = Form(),
booking_time: str = Form(),
status_id: str = Form(default=''),file_data: UploadFile = Form(default=None),
file_data: UploadFile = Form(default=None),
hospital_id: str = Form(default=''),patient_id: str = Form(), doctor_id: str = Form(),time_slot: str = Form(),
staff_id: str = Form(default=''),
patient_profile_pic: UploadFile = Form(default=None),
disease :str = Form(default=''),
appointment_date: str = Form(),
db: Session = Depends(get_db),patient_db: Session = Depends(get_patient_db)):
db: Session = Depends(get_db),patient_db: Session = Depends(get_patient_db),doctor_db: Session = Depends(get_doctor_db)):
"""Function to return final response while adding new appointment data"""
# Authentication().authenticate(request.headers.get('Authorization'),db)
filename = ""
Expand All @@ -46,18 +48,25 @@ async def add_new_appointment(first_name: str = Form(), last_name: str = Form(),
if patient_profile_pic is not None:
profile_pic = patient_profile_pic.filename
await create_file(patient_profile_pic,PROFILE_DIR_PATH)
return controller.add_new_appointment(db, patient_db,first_name, last_name,
mobile_number,booking_time, status_id, hospital_id,
return controller.add_new_appointment(db, patient_db,doctor_db,first_name, last_name,
mobile_number,booking_time, hospital_id,
patient_id,doctor_id,staff_id,filename,profile_pic,time_slot,disease,appointment_date)


@appointment_router.post("/get_appointment_details")
async def get_appointment_details(request:Request, database: Session = Depends(get_db),patient_db: Session = Depends(get_patient_db),doctor_database: Session = Depends(get_doctor_db)):
async def get_appointment_details(request:Request, database: Session = Depends(get_db),patient_report_db: Session = Depends(get_patient_report_db),patient_db: Session = Depends(get_patient_db),doctor_database: Session = Depends(get_doctor_db),
medicine_database: Session = Depends(get_medicine_db)):
"""Function to return Appointment details
(specific and all Appointment data can be fetched)"""
# patient_id = Authentication().authenticate(request.headers.get('Authorization'),database)[0].id
request_json = await request.json()
return controller.get_appointment_by_id(database,patient_db,request_json["id"],request_json["date"],doctor_database)
doctor_id = ""
patient_id = ""
if "doctor_id" in request_json:
doctor_id = request_json["doctor_id"]
else:
patient_id = request_json["id"]
return controller.get_appointment_by_id(database,patient_report_db,patient_db,patient_id,doctor_id,request_json["date"],doctor_database,medicine_database)

@appointment_router.post("/get_appointment_by_date")
async def get_appointment_details_by_date(request:Request, database: Session = Depends(get_db),doctor_database: Session = Depends(get_doctor_db)):
Expand All @@ -74,27 +83,18 @@ def delete_appointment_details(request:Request,appointment_id: schemas.Appointme
# Authentication().authenticate(request.headers.get('Authorization'),database)
return controller.delete_appointment_details(database, id = appointment_id.id)

# @appointment_router.post("/update_appointment_details")
# def update_appointment_details(request:Request,appointment_details: schemas.AddNewAppointment, database: Session = Depends(get_db)):
# """Function to update particular Appointment details"""
# Authentication().authenticate(request.headers.get('Authorization'),database)
# return controller.update_appointment_details(database, appointment = appointment_details)

# @appointment_router.post("/update_appointment_details")
# def update_appointment_details(request:Request,appointment_details: schemas.AddNewAppointment, database: Session = Depends(get_db)):
# """Function to update particular Appointment details"""
# Authentication().authenticate(request.headers.get('Authorization'),database)
# return controller.update_appointment_details(database, appointment = appointment_details)

@appointment_router.post("/update_appointment_details")
async def update_appointment_details(request: Request,appointment_id: str = Form(),first_name: str = Form(), last_name: str = Form(),
mobile_number: str = Form(),
booking_time: str = Form(),
async def update_appointment_details(request: Request,appointment_id: str = Form(),first_name: str = Form(default=''), last_name: str = Form(default=''),
mobile_number: str = Form(default=''),
booking_time: str = Form(default=''),
status_id: str = Form(default=''),file_data: UploadFile = Form(default=None),patient_profile_pic: UploadFile = Form(default=None),
hospital_id: str = Form(default=''),patient_id: str = Form(default=''), doctor_id: str = Form(),
report_description: str = Form(default=''),medicine_id: str = Form(default=''),
patient_report_file: UploadFile = Form(default=None),
hospital_id: str = Form(default=''),patient_id: str = Form(default=''), doctor_id: str = Form(default=''),
staff_id: str = Form(default=''),
time_slot: str = Form(default=''),appointment_date: str = Form(default=''),
db: Session = Depends(get_db),doctor_database: Session = Depends(get_doctor_db)):
db: Session = Depends(get_db),patient_report_db: Session = Depends(get_patient_report_db),doctor_database: Session = Depends(get_doctor_db),
medicine_database: Session = Depends(get_medicine_db)):
"""Function to update particular appointment detail"""
# Authentication().authenticate(request.headers.get('Authorization'),db)
filename = ""
Expand All @@ -105,26 +105,31 @@ async def update_appointment_details(request: Request,appointment_id: str = Form
if patient_profile_pic is not None:
profile_pic = patient_profile_pic.filename
await create_file(patient_profile_pic,PROFILE_DIR_PATH)
return controller.update_appointment_details(db,doctor_database, first_name, last_name,
mobile_number,booking_time, status_id, hospital_id,
patient_id,doctor_id,staff_id,filename,profile_pic,appointment_id,time_slot,appointment_date)
return controller.update_appointment_details(db,patient_report_db,doctor_database,medicine_database, first_name, last_name,
mobile_number,booking_time, status_id, hospital_id,patient_id,doctor_id,staff_id,filename,profile_pic,
report_description,medicine_id,patient_report_file,appointment_id,time_slot,appointment_date)

@appointment_router.get("/get_appointment_by_pagination")
async def get_appointment_by_pagination(database: Session = Depends(get_db),page: int = 0, size: int = 5):
"""Function to update particular hospital details"""
return controller.get_appointment_by_pagination(database,page,size)

@appointment_router.post("/add_appointment_status", response_model=schemas.AddAppointmentStatusResponse)
def add_appointment_status(appointment_status: schemas.AppointmentStatusBase, database: Session = Depends(get_db)):
async def add_appointment_status(request:Request, database: Session = Depends(get_db)):
"""Function to return final response while adding new Appointment status details"""
return controller.add_new_appointment_status(database,appointment_status)
request_json = await request.json()
return controller.add_new_appointment_status(database,request_json["appointment_status"])


@appointment_router.post("/get_appointment_status")
def get_appointment_status(appointment_status_id: schemas.AppointmentStatusId, database: Session = Depends(get_db)):
async def get_appointment_status(request:Request, database: Session = Depends(get_db)):
"""Function to return Appointment details
(specific and all Appointment status data can be fetched)"""
return controller.get_appointment_status_by_id_or_without_id(database, id = appointment_status_id.id)
id = ""
request_json = await request.json()
if request_json['id'] != "":
id = request_json["id"]
return controller.get_appointment_status_by_id_or_without_id(database,id)


@appointment_router.post("/delete_appointment_status")
Expand Down
Loading