async def create_form( form: Form, current_doctor: UserInDB = Depends(get_current_active_user)): try: Doctor(**current_doctor.dict()).create_form(form) except ValidationError as e: logger.exception(e) raise HTTPException(status_code=500, detail=f"Form Structure could not be created") except Exception as e: logger.exception(e)
async def create_model( file: UploadFile = File(...), current_doctor: UserInDB = Depends(get_current_active_user)): try: Doctor(**current_doctor.dict()).create_model(file) except ValidationError as e: logger.exception(e) raise HTTPException(status_code=500, detail=f"Model could not be created") except Exception as e: logger.exception(e)
async def prediction(file: UploadFile = File(...), current_doctor: UserInDB = Depends( get_current_active_user)) -> List[int]: try: prediction = Doctor(**current_doctor.dict()).prediction(file) except ValidationError as e: logger.exception(e) raise HTTPException(status_code=500, detail=f"Alforithm could not be executed") except Exception as e: logger.exception(e) prediction_list: List[int] = prediction.tolist() return prediction_list
async def delete_patient( id_patient: str, current_doctor: UserInDB = Depends(get_current_active_user)): print(id_patient) try: patient = Doctor(**current_doctor.dict()).delete(id_patient) logger.debug(patient) except ValidationError as e: logger.exception(e) raise HTTPException(status_code=500, detail=f"Patient could not be deleted") except Exception as e: logger.exception(e)
async def see_form( current_doctor: UserInDB = Depends(get_current_active_user)): form = None try: form = Doctor(**current_doctor.dict()).get_data_structure() except ValidationError as e: logger.exception(e) raise HTTPException(status_code=500, detail=f"Form Structure doesn`t exist") except Exception as e: logger.exception(e) return form
async def patients( id_patient, current_doctor: UserInDB = Depends(get_current_active_user)): patient = None # print(id_patient) try: patient = Doctor(**current_doctor.dict()).search_by_id(id_patient) except Exception as e: logger.exception(e) if not patient: raise HTTPException(status_code=404, detail=f"No patients found for current user") return patient.clinical_information
async def patients(current_doctor: UserInDB = Depends( get_current_active_user)) -> List[Patients]: # print("Devuelvo todos los pacientes") patients = [] try: patients = Doctor(**current_doctor.dict()).all_patients() except Exception as e: logger.exception(e) # if not patients: # raise HTTPException(status_code=404, detail=f"No patients found for current user") return patients
async def register( patient: dict, current_doctor: UserInDB = Depends(get_current_active_user) ) -> Patients: try: patient = Doctor(**current_doctor.dict()).new_patient( patient, current_doctor.dict()) logger.debug(patient) except ValidationError as e: logger.exception(e) raise HTTPException(status_code=500, detail=f"Patient could not be created") except Exception as e: logger.exception(e) return patient