def createExaminationCo(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加电脑验光 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {left: {ds, dc, a}, right: {ds, dc, a}} :return: None """ examination_co_id_left = worker.get_id() examination_co_id_right = worker.get_id() data = jsonable_encoder(data) print(data) db_obj = [ ExaminationCo(base_info_id=base_info_id, examination_co_id=examination_co_id_left, eye_type="left", **data["left"]), ExaminationCo(base_info_id=base_info_id, examination_co_id=examination_co_id_right, eye_type="right", **data["right"]) ] return db_obj
def createExaminationCornea(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加角膜荧光 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {eye_type, examination_cornea_sp, examination_cornea_cz, examination_cornea_cz_z}\n :return: None """ examination_cornea_id_left = worker.get_id() examination_cornea_id_right = worker.get_id() data = jsonable_encoder(data) db_obj = [ ExaminationCornea(base_info_id=base_info_id, examination_cornea_id=examination_cornea_id_left, eye_type="left", **data["left"]), ExaminationCornea( base_info_id=base_info_id, examination_cornea_id=examination_cornea_id_right, eye_type="right", **data["right"]) ] return db_obj
def createExaminationEyeballsport(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加眼球运动 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {eye_type, normal, external_rectus, internal_rectus, pper_rectus, lower_rectus, upper_oblique, lower_oblique}\n :return: None """ examination_eyeballsport_id_left = worker.get_id() examination_eyeballsport_id_right = worker.get_id() data = jsonable_encoder(data) db_obj = [ ExaminationEyeballsport( base_info_id=base_info_id, examination_eyeballsport_id=examination_eyeballsport_id_left, eye_type="left", **data["left"]), ExaminationEyeballsport( base_info_id=base_info_id, examination_eyeballsport_id=examination_eyeballsport_id_right, eye_type="right", **data["right"]) ] return db_obj
def add(self, db: Session, name: str, password: str, email: str, phone: str) -> User: uid = worker.get_id() password = security.password_hash(password) db_obj = User(uid=uid, name=name, password=password, email=email, phone=phone, permission=1) db.add(db_obj) db.commit() db.close() return db_obj
def createSurgery(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加手术设计 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {surgery_history, glasses_history, amblyopia_history, home_history, born_history, surgery_history_edit, now_age, now_wt, now_fs} :return: None """ surgery_id = worker.get_id() data = jsonable_encoder(data) db_obj = Surgery(base_info_id=base_info_id, surgery_id=surgery_id, **data) return db_obj
def createExaminationSlj(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加三棱镜 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {examination_slj_zj_near, examination_slj_zj_far, examination_slj_dy_near, examination_slj_dy_far, examination_slj_cz, examination_slj_cz_z, k_method}\n :return: None """ examination_slj_id = worker.get_id() data = jsonable_encoder(data) db_obj = ExaminationSlj(base_info_id=base_info_id, examination_slj_id=examination_slj_id, **data) return db_obj
def createExaminationTsj(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加同视机 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {examination_tsj_tss, examination_tsj_tss_sp, examination_tsj_tss_cz, examination_tsj_tss_cs_z} :return: None """ examination_tsj_id = worker.get_id() data = jsonable_encoder(data) db_obj = ExaminationTsj(base_info_id=base_info_id, examination_tsj_id=examination_tsj_id, **data) return db_obj
def createExaminationLts(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加立体视 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {examination_lts_j, examination_lts_y} :return: None """ examination_lts_id = worker.get_id() data = jsonable_encoder(data) db_obj = ExaminationLts(base_info_id=base_info_id, examination_lts_id=examination_lts_id, **data) return db_obj
def createLeaveHospitalSlj(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加三棱镜(出院) :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {leave_hospital_slj_near, leave_hospital_slj_far} :return: None """ leave_hospital_slj_id = worker.get_id() data = jsonable_encoder(data) db_obj = LeaveHospitalSlj(base_info_id=base_info_id, leave_hospital_slj_id=leave_hospital_slj_id, **data) return db_obj
def createDiagnosis(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加诊断 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {latent_strabismus, Internal_strabismus, Exotropia, A_V, V, S, PS, N, other} :return: None """ diagnosis_id = worker.get_id() data = jsonable_encoder(data) db_obj = Diagnosis(base_info_id=base_info_id, diagnosis_id=diagnosis_id, **data) return db_obj
def createExaminationNv(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加裸眼视力 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {left, right} :return: None """ examination_nv_id = worker.get_id() data = jsonable_encoder(data) db_obj = ExaminationNv(base_info_id=base_info_id, examination_nv_id=examination_nv_id, **data) return db_obj
def createLeaveHospitalCornea(self, db: Session, base_info_id: str, data: dict) -> Any: """ 添加角膜映光(出院) :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: {examination_cornea_sp, examination_cornea_cz, examination_cornea_cz_z}\n :return: None """ leave_hospital_cornea_id = worker.get_id() data = jsonable_encoder(data) db_obj = LeaveHospitalCornea( base_info_id=base_info_id, leave_hospital_cornea_id=leave_hospital_cornea_id, **data) return db_obj
def createExaminationControl( self, db: Session, base_info_id: str, data: dict ) -> Any: """ 添加眼球运动 :param db: 数据库连接对象 :param base_info_id: 病例ID :param data: examination_control :return: None """ examination_control_id = worker.get_id() data = jsonable_encoder(data) db_obj = ExaminationControl( base_info_id=base_info_id, examination_control_id=examination_control_id, **data ) return db_obj
def submitCaseContent( db: Session = Depends(deps.get_db), base_info: Optional[dict] = Body(..., description="基本信息"), medical_history: Optional[dict] = Body(..., description="病史"), examination: Optional[dict] = Body(..., description="检查"), diagnosis: Optional[dict] = Body(..., description="诊断"), surgery: Optional[dict] = Body(..., description="手术设计"), leave_history: Optional[dict] = Body(..., description="出院情况"), ) -> dict: """ 提交病例信息\n :param db: 数据库对象\n :param base_info: 基本信息\n {data_type, user_name, sex, age, id_number, phone_number, order_number, suifang, beizhu}\n {数据类别,姓名,性别,年龄,身份证号,手机号,登记号,随访,备注}\n :param medical_history: \n {surgery_history, glasses_history, amblyopia_history, home_history, born_history, surgery_history_edit, now_age, now_wt, now_fs}\n {手术史,眼镜史,弱视治疗史,家族史,生产史,手术史补充,斜视年龄,歪头,复视}\n :param examination: \n {examination_nv, examination_corrected_visual, examination_co, examination_ro, examination_tsj, examination_lts, examination_cornea, examination_slj, examination_eyeballsport, examination_control}\n examination_nv: dict #裸眼视力\n {left, right}\n examination_corrected_visual: dict #矫正视力\n {left, right}\n examination_co: dict #电脑验光\n {left: {ds, dc, a}, right: {ds, dc, a}}\n examination_ro: dict #检影验光\n {left: {ds, dc, a}, right: {ds, dc, a}}\n examination_tsj: dict #同视机\n {examination_tsj_tss, examination_tsj_tss_sp, examination_tsj_tss_cz, examination_tsj_tss_cs_z}\n {同时视,同时视水平值,同时视垂直值,同时视垂直值具体数值}\n examination_lts: dict #立体视\n {examination_lts_j, examination_lts_y}\n {近方随机点立体视,远方随机点立体视}\n examination_cornea: dict #角膜映光\n {\n left: {examination_cornea_sp, examination_cornea_cz, examination_cornea_cz_z}, \n right: {examination_cornea_sp, examination_cornea_cz, examination_cornea_cz_z}\n }\n {眼别,水平值,垂直值,垂直数值}\n examination_slj: dict #三棱镜\n {examination_slj_zj_near, examination_slj_zj_far, examination_slj_dy_near, examination_slj_dy_far, examination_slj_cz, examination_slj_cz_z, k_method}\n {视近(直角),视远(直角),视近(等腰),视远(等腰),垂直三棱镜,0-50,k法}\n examination_eyeballsport: dict #眼球运动\n {\n left: {normal, external_rectus, internal_rectus, pper_rectus, lower_rectus, upper_oblique, lower_oblique},\n right: {normal, external_rectus, internal_rectus, pper_rectus, lower_rectus, upper_oblique, lower_oblique}\n }\n {眼别,正常,外直肌,内直肌,上直肌,下直肌,上斜肌,下斜肌}\n examination_control: str #控制力\n :param diagnosis: #诊断\n {latent_strabismus, Internal_strabismus, Exotropia, A_V, V, S, PS, N, other}\n {隐斜视,内斜视,外斜视,A⁃V斜视,垂直旋转性斜视,特殊类型斜视,中枢性麻痹性斜视,眼球震颤,其他}\n :param surgery: #手术设计\n {surgery_yb, muscle, way, value, beizhu}\n {手术设计眼别,肌肉,方式,量值,备注}\n :param leave_history: #出院时情况\n {leave_hospital_lts, leave_hospital_cornea, leave_hospital_slj, leave_hospital_eyeballsport}\n {立体视(出院),角膜映光(出院),三棱镜(出院),眼球运动(出院)}\n leave_hospital_lts: dict #立体视(出院)\n {examination_lts_j, examination_lts_y}\n {近方随机点立体视,远方随机点立体视}\n leave_hospital_slj: dict #三棱镜(出院)\n {leave_hospital_slj_near, leave_hospital_slj_far}\n {视近,视远}\n leave_hospital_cornea: dict #角膜映光(出院)\n {examination_cornea_sp, examination_cornea_cz, examination_cornea_cz_z}\n {水平值,垂直值,垂直数值}\n leave_hospital_eyeballsport: dict #眼球运动(出院)\n {\n left: {normal, external_rectus, internal_rectus, pper_rectus, lower_rectus, upper_oblique, lower_oblique},\n right: {normal, external_rectus, internal_rectus, pper_rectus, lower_rectus, upper_oblique, lower_oblique}\n }\n {眼别,正常,外直肌,内直肌,上直肌,下直肌,上斜肌,下斜肌}\n :return: 提交成功返回200/ok """ try: id = worker.get_id() #病例id create_case = crud_case.case.createBaseInfo(db=db, id=id, data=base_info) create_medical_history = crud_medical_history.medicalhistory.createMedicalHistory(db=db, base_info_id=id, data=medical_history) create_examination_nv = crud_examination_nv.examinationnv.createExaminationNv(db=db, base_info_id=id, data=examination['examination_nv']) create_examination_corrected_visual = crud_examination_corrected_visual.examinationcorrectedvisual.createExaminationCorrectedVisual(db=db, base_info_id=id, data=examination['examination_corrected_visual']) create_examination_co = crud_examination_co.examinationco.createExaminationCo(db=db, base_info_id=id, data=examination['examination_co']) create_examination_ro = crud_examination_ro.examinationro.createExaminationRo(db=db, base_info_id=id, data=examination['examination_ro']) create_examination_tsj = crud_examination_tsj.examinationtsj.createExaminationTsj(db=db, base_info_id=id, data=examination['examination_tsj']) create_examination_lts = crud_examination_lts.examinationlts.createExaminationLts(db=db, base_info_id=id, data=examination['examination_lts']) create_examination_cornea = crud_examination_cornea.examinationcornea.createExaminationCornea(db=db, base_info_id=id, data=examination['examination_cornea']) create_examination_slj = crud_examination_slj.examinationslj.createExaminationSlj(db=db, base_info_id=id, data=examination['examination_slj']) create_examination_eyeballsport = crud_examination_eyeballsport.examinationeyeballsport.createExaminationEyeballsport(db=db, base_info_id=id, data=examination['examination_eyeballsport']) create_examination_control = crud_examination_control.examinationcontrol.createExaminationControl(db=db, base_info_id=id, data=examination['examination_control']) create_leave_hospital_lts = crud_leave_hospital_lts.leavehospitallts.createLeaveHospitalLts(db=db, base_info_id=id, data=leave_history['leave_hospital_lts']) create_leave_hospital_slj = crud_leave_hospital_slj.leavehospitalslj.createLeaveHospitalSlj(db=db, base_info_id=id, data=leave_history['leave_hospital_slj']) create_leave_hospital_cornea = crud_leave_hospital_cornea.leavehospitalcornea.createLeaveHospitalCornea(db=db, base_info_id=id, data=leave_history['leave_hospital_cornea']) create_leave_hospital_eyeballsport = crud_leave_hospital_eyeballsport.leavehospitaleyeballsport.createLeaveHospitalEyeballsport(db=db, base_info_id=id, data=leave_history['leave_hospital_eyeballsport']) create_diagnosis = crud_diagnosis.diagnosis.createDiagnosis(db=db, base_info_id=id, data=diagnosis) create_surgery = crud_surgery.surgery.createSurgery(db=db, base_info_id=id, data=surgery) db.add_all( [ create_case, create_medical_history, create_examination_nv, create_examination_corrected_visual, create_examination_tsj, create_examination_lts, create_examination_slj, create_examination_control, create_leave_hospital_lts, create_leave_hospital_slj, create_leave_hospital_cornea, create_diagnosis, create_surgery, create_examination_co[0], create_examination_co[1], create_examination_ro[0], create_examination_ro[1], create_examination_cornea[0], create_examination_cornea[1], create_examination_eyeballsport[0], create_examination_eyeballsport[1], create_leave_hospital_eyeballsport[0], create_leave_hospital_eyeballsport[1] ] ) db.commit() db.close() except Exception as e: print(e) raise HTTPException( status.HTTP_422_UNPROCESSABLE_ENTITY, detail={ "return_code": -1, "return_msg": "病例提交失败:" + str(e) }, ) return { "return_code": 0, "return_msg": "OK" }
crud_examination_slj.examinationslj.updateExaminationSlj(db=db, id=id, data=examination['examination_slj']) crud_examination_eyeballsport.examinationeyeballsport.updateExaminationEyeballsport(db=db, id=id, data=examination['examination_eyeballsport']) crud_examination_control.examinationcontrol.updateExaminationControl(db=db, id=id, data=examination['examination_control']) crud_leave_hospital_lts.leavehospitallts.updateLeaveHospitalLts(db=db, id=id, data=leave_history['leave_hospital_lts']) crud_leave_hospital_slj.leavehospitalslj.updateLeaveHospitalSlj(db=db, id=id, data=leave_history['leave_hospital_slj']) crud_leave_hospital_cornea.leavehospitalcornea.updateLeaveHospitalCornea(db=db, id=id, data=leave_history['leave_hospital_cornea']) crud_leave_hospital_eyeballsport.leavehospitaleyeballsport.updateLeaveHospitalEyeballsport(db=db, id=id, data=leave_history['leave_hospital_eyeballsport']) crud_diagnosis.diagnosis.updateDiagnosis(db=db, id=id, data=diagnosis) crud_surgery.surgery.updateSurgery(db=db, id=id, data=surgery) db.commit() db.close() except Exception as e: print(e) raise HTTPException( status.HTTP_422_UNPROCESSABLE_ENTITY, detail={ "return_code": -1, "return_msg": "病例更新失败: " + str(e) }, ) return { "return_code": 0, "return_msg": "OK" } if __name__ == '__main__': id = worker.get_id() print(id)