package controllers import ( "XT_New/enums" "XT_New/models" "XT_New/service" "XT_New/utils" "encoding/json" "fmt" "reflect" "strconv" "strings" "time" "github.com/astaxie/beego" ) func PatientDataConfigAPIControllerRegistRouters() { beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses") beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse") beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse") beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse") beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues") beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue") beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue") beego.Router("/api/patient/sickhistory", &PatientDataConfigAPIController{}, "get:GetSickHistorys") beego.Router("/api/patient/sickhistory/create", &PatientDataConfigAPIController{}, "get:CreateSickHistory") beego.Router("/api/patient/sickhistory/delete", &PatientDataConfigAPIController{}, "post:DeleteSickHistory") beego.Router("/api/patient/sickhistory/modify", &PatientDataConfigAPIController{}, "get:ModifySickHistory") beego.Router("/api/patient/physiquecheck", &PatientDataConfigAPIController{}, "get:GetPhysiqueChecks") beego.Router("/api/patient/physiquecheck/create", &PatientDataConfigAPIController{}, "get:CreatePhysiqueCheck") beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck") beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck") beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints") beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints") beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList") beego.Router("/api/patient/getcontextschedulelist", &PatientDataConfigAPIController{}, "Get:GetContextScheduleList") beego.Router("/api/patient/getpatientallagic", &PatientDataConfigAPIController{}, "Get:GetPatientAllagicList") beego.Router("/api/patient/savesitemap", &PatientDataConfigAPIController{}, "Post:SaveSiteMap") beego.Router("/api/patient/getpatientsitemap", &PatientDataConfigAPIController{}, "Get:GetPatientSitemap") beego.Router("/api/patient/getpatientdetailinformedconsent", &PatientDataConfigAPIController{}, "Get:GetPatientDetailInformedConsent") } type PatientDataConfigAPIController struct { BaseAuthAPIController } func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() { patientID, _ := this.GetInt64("patient_id") idsStr := this.GetString("ids") if patientID <= 0 || len(idsStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } recordIDStrs := strings.Split(idsStr, ",") patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID) sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs) this.ServeSuccessJSON(map[string]interface{}{ "patient": patient, "sickhistorys": sickHostory, }) } func (this *PatientDataConfigAPIController) GetSickhistoryPrints() { patientID, _ := this.GetInt64("patient_id") idsStr := this.GetString("ids") if patientID <= 0 || len(idsStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } recordIDStrs := strings.Split(idsStr, ",") patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID) sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs) for _, item := range sickHostory { pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate) item.XtPatientPhysiqueCheck = pc } this.ServeSuccessJSON(map[string]interface{}{ "patient": patient, "sickhistorys": sickHostory, }) } func (this *PatientDataConfigAPIController) GetSickHistorys() { patientID, _ := this.GetInt64("patient_id") startTimeYMDStr := this.GetString("start_time") endTimeYMDStr := this.GetString("end_time") if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59" startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr) endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr) if parseStartTimeErr != nil || parseEndTimeErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } records, getRecordsErr := service.GetPatientSickHistory(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix()) if getRecordsErr != nil { this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId) if getAllAdminsErr != nil { this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "records": records, "doctors": admins, }) } func (this *PatientDataConfigAPIController) CreateSickHistory() { patientID, _ := this.GetInt64("patient_id") content := this.GetString("content") record_time_str := this.GetString("record_time") title := this.GetString("title") is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi") is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi") is_guominyaowu, _ := this.GetInt64("is_guominyaowu") guominyaowu_desc := this.GetString("guominyaowu_desc") doctor_id, _ := this.GetInt64("doctor_id") if patientID <= 0 || len(content) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } if len(record_time_str) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } record_date := strings.Split(record_time_str, " ") checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str) checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0]) adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } now := time.Now().Unix() record := models.XtPatientSickHistory{ OrgId: adminUserInfo.CurrentOrgId, PatientId: patientID, Recorder: adminUserInfo.AdminUser.Id, RecordTime: checkDate.Unix(), Content: content, Status: 1, Title: title, IsShenyizhiHistory: is_shenyizhishi, IsFumoDialysisHistory: is_fumotouxishi, HypersusceptibilityDesc: guominyaowu_desc, IsHypersusceptibility: is_guominyaowu, Ctime: now, Mtime: now, DoctorId: doctor_id, RecordDate: checkDate_two.Unix(), } createErr := service.CreatePatientSickHistory(&record) if createErr != nil { this.ErrorLog("创建患者病史记录失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } func (this *PatientDataConfigAPIController) DeleteSickHistory() { patientID, _ := this.GetInt64("patient_id") idsStr := this.GetString("ids") if patientID <= 0 || len(idsStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } recordIDStrs := strings.Split(idsStr, ",") recordIDs := make([]int64, 0, len(recordIDStrs)) for _, idStr := range recordIDStrs { id, parseErr := strconv.Atoi(idStr) if parseErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } recordIDs = append(recordIDs, int64(id)) } deleteErr := service.DeletePatientSickHistoryInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs) if deleteErr != nil { this.ErrorLog("删除患者病程记录失败:%v", deleteErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(nil) } func (this *PatientDataConfigAPIController) ModifySickHistory() { patientID, _ := this.GetInt64("patient_id") content := this.GetString("content") id, _ := this.GetInt64("id", 0) record_time_str := this.GetString("record_time") title := this.GetString("title") is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi") is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi") is_guominyaowu, _ := this.GetInt64("is_guominyaowu") guominyaowu_desc := this.GetString("guominyaowu_desc") doctor_id, _ := this.GetInt64("doctor_id") if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } //timeLayout := "2006-01-02" //loc, _ := time.LoadLocation("Local") checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str) fmt.Println("checkDate--------------", checkDate) adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } now := time.Now().Unix() record := models.XtPatientSickHistory{ ID: id, OrgId: adminUserInfo.CurrentOrgId, PatientId: patientID, Recorder: adminUserInfo.AdminUser.Id, Content: content, Status: 1, Ctime: now, Mtime: now, Title: title, RecordTime: checkDate.Unix(), IsShenyizhiHistory: is_shenyizhishi, IsFumoDialysisHistory: is_fumotouxishi, HypersusceptibilityDesc: guominyaowu_desc, IsHypersusceptibility: is_guominyaowu, DoctorId: doctor_id, } createErr := service.ModifyPatientSickHistory(&record) if createErr != nil { this.ErrorLog("创建患者抢救记录失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } func (this *PatientDataConfigAPIController) GetPhysiqueChecks() { patientID, _ := this.GetInt64("patient_id") startTimeYMDStr := this.GetString("start_time") endTimeYMDStr := this.GetString("end_time") if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59" startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr) endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr) if parseStartTimeErr != nil || parseEndTimeErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } records, getRecordsErr := service.GetPatientPhysiqueCheck(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix()) if getRecordsErr != nil { this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId) if getAllAdminsErr != nil { this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "records": records, "doctors": admins, }) } func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() { patientID, _ := this.GetInt64("patient_id") doctor_id, _ := this.GetInt64("doctor_id") record_time_str := this.GetString("record_time") t := this.GetString("t") p := this.GetString("p") r := this.GetString("r") bp_left := this.GetString("bp_left") bp_right := this.GetString("bp_right") pinxuerongmao, _ := this.GetInt64("pinxuerongmao") tiwei, _ := this.GetInt64("tiwei") fuzhong, _ := this.GetInt64("fuzhong") chuxuedian, _ := this.GetInt64("chuxuedian") fayu, _ := this.GetInt64("fayu") yinyang, _ := this.GetInt64("yinyang") shenzhi, _ := this.GetInt64("shenzhi") pifunianmo, _ := this.GetInt64("pifunianmo") buwei := this.GetString("buwei") chengdu := this.GetString("chengdu") pixiachuxue, _ := this.GetInt64("pixiachuxue") zidian, _ := this.GetInt64("zidian") pifuwendu, _ := this.GetInt64("pifuwendu") qita := this.GetString("qita") linbazhongda, _ := this.GetInt64("linbazhongda") linbabuwei := this.GetString("linbabuwei") yanlian, _ := this.GetInt64("yanlian") tongkong, _ := this.GetInt64("tongkong") zuo := this.GetString("zuo") you := this.GetString("you") duiguangfanshe := this.GetString("duiguangfanshe") biantaoti := this.GetString("biantaoti") yanbu := this.GetString("yanbu") toubuqita := this.GetString("toubuqita") huxiyin := this.GetString("huxiyin") xiongmomocayin, _ := this.GetInt64("xiongmomocayin") feizhangbuwei, _ := this.GetInt64("feizhangbuwei") luoyin, _ := this.GetInt64("luoyin") desc := this.GetString("desc") xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao") xinlv, _ := this.GetInt64("xinlv") xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng") zayin, _ := this.GetInt64("zayin") fujiayin, _ := this.GetInt64("fujiayin") xinzangdesc := this.GetString("xinzangdesc") fushuizheng, _ := this.GetInt64("fushuizheng") ganjingjingmai := this.GetString("ganjingjingmai") gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong") gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong") pizhang_yatong, _ := this.GetInt64("pizhang_yatong") pizhang_koutong, _ := this.GetInt64("pizhang_koutong") shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong") shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong") fubu_desc := this.GetString("fubu_desc") oth_desc := this.GetString("oth_desc") if patientID <= 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } if len(record_time_str) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } record_date := strings.Split(record_time_str, " ") checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str) checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0]) adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } now := time.Now().Unix() record := models.XtPatientPhysiqueCheck{ DoctorId: doctor_id, OrgId: adminUserInfo.CurrentOrgId, PatientId: patientID, Recorder: adminUserInfo.AdminUser.Id, RecordTime: checkDate.Unix(), Status: 1, Ctime: now, Mtime: now, T: t, P: p, R: r, BpRight: bp_right, BpLeft: bp_left, Pinxuerongmao: pinxuerongmao, Tiwei: tiwei, Fuzhong: fuzhong, Chuxuedian: chuxuedian, Fayu: fayu, Yinyang: yinyang, Shenzhi: shenzhi, Pifunianmo: pifunianmo, Buwei: buwei, Chengdu: chengdu, Pixiachuxue: pixiachuxue, Zidian: zidian, Pifuwendu: pifuwendu, Qita: qita, Linbazhongda: linbazhongda, Linbabuwei: linbabuwei, Yanlian: yanlian, Tongkong: tongkong, Zuo: zuo, You: you, Duiguangfanshe: duiguangfanshe, Biantaoti: biantaoti, Yanbu: yanbu, Toubuqita: toubuqita, Huxiyin: huxiyin, Xiongmomocayin: xiongmomocayin, Feizhangbuwei: feizhangbuwei, Luoyin: luoyin, Desc: desc, Xinzangdaxiao: xinzangdaxiao, Xinlv: xinlv, Xinbaomocasheng: xinbaomocasheng, Zayin: zayin, Fujiayin: fujiayin, Xinzangdesc: xinzangdesc, Fushuizheng: fushuizheng, Ganjingjingmai: ganjingjingmai, GangzhangYatong: gangzhang_yatong, GangzhangKoutong: gangzhang_koutong, PizhangKoutong: pizhang_koutong, PizhangYatong: pizhang_yatong, ShenzhangKoutong: shenzhang_koutong, ShenzhangYatong: shenzhang_yatong, FubuDesc: fubu_desc, OthDesc: oth_desc, RecordDate: checkDate_two.Unix(), } createErr := service.CreatePatientPhysiqueCheck(&record) if createErr != nil { this.ErrorLog("创建患者病史记录失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } func (this *PatientDataConfigAPIController) DeletePhysiqueCheck() { patientID, _ := this.GetInt64("patient_id") idsStr := this.GetString("ids") if patientID <= 0 || len(idsStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } recordIDStrs := strings.Split(idsStr, ",") recordIDs := make([]int64, 0, len(recordIDStrs)) for _, idStr := range recordIDStrs { id, parseErr := strconv.Atoi(idStr) if parseErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } recordIDs = append(recordIDs, int64(id)) } deleteErr := service.DeletePatientPhysiqueCheckInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs) if deleteErr != nil { this.ErrorLog("删除患者病程记录失败:%v", deleteErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(nil) } func (this *PatientDataConfigAPIController) ModifyPhysiqueCheck() { patientID, _ := this.GetInt64("patient_id") id, _ := this.GetInt64("id", 0) doctor_id, _ := this.GetInt64("doctor_id", 0) record_time_str := this.GetString("record_time") if patientID <= 0 || id == 0 || len(record_time_str) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } t := this.GetString("t") p := this.GetString("p") r := this.GetString("r") bp_left := this.GetString("bp_left") bp_right := this.GetString("bp_right") pinxuerongmao, _ := this.GetInt64("pinxuerongmao") tiwei, _ := this.GetInt64("tiwei") fuzhong, _ := this.GetInt64("fuzhong") chuxuedian, _ := this.GetInt64("chuxuedian") fayu, _ := this.GetInt64("fayu") yinyang, _ := this.GetInt64("yinyang") shenzhi, _ := this.GetInt64("shenzhi") pifunianmo, _ := this.GetInt64("pifunianmo") buwei := this.GetString("buwei") chengdu := this.GetString("chengdu") pixiachuxue, _ := this.GetInt64("pixiachuxue") zidian, _ := this.GetInt64("zidian") pifuwendu, _ := this.GetInt64("pifuwendu") qita := this.GetString("qita") linbazhongda, _ := this.GetInt64("linbazhongda") linbabuwei := this.GetString("linbabuwei") yanlian, _ := this.GetInt64("yanlian") tongkong, _ := this.GetInt64("tongkong") zuo := this.GetString("zuo") you := this.GetString("you") duiguangfanshe := this.GetString("duiguangfanshe") biantaoti := this.GetString("biantaoti") yanbu := this.GetString("yanbu") toubuqita := this.GetString("toubuqita") huxiyin := this.GetString("huxiyin") xiongmomocayin, _ := this.GetInt64("xiongmomocayin") feizhangbuwei, _ := this.GetInt64("feizhangbuwei") luoyin, _ := this.GetInt64("luoyin") desc := this.GetString("desc") xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao") xinlv, _ := this.GetInt64("xinlv") xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng") zayin, _ := this.GetInt64("zayin") fujiayin, _ := this.GetInt64("fujiayin") xinzangdesc := this.GetString("xinzangdesc") fushuizheng, _ := this.GetInt64("fushuizheng") ganjingjingmai := this.GetString("ganjingjingmai") gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong") gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong") pizhang_yatong, _ := this.GetInt64("pizhang_yatong") pizhang_koutong, _ := this.GetInt64("pizhang_koutong") shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong") shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong") fubu_desc := this.GetString("fubu_desc") oth_desc := this.GetString("oth_desc") checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str) adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } now := time.Now().Unix() record := models.XtPatientPhysiqueCheck{ ID: id, OrgId: adminUserInfo.CurrentOrgId, PatientId: patientID, Recorder: adminUserInfo.AdminUser.Id, RecordTime: checkDate.Unix(), DoctorId: doctor_id, Status: 1, Ctime: now, Mtime: now, T: t, P: p, R: r, BpRight: bp_right, BpLeft: bp_left, Pinxuerongmao: pinxuerongmao, Tiwei: tiwei, Fuzhong: fuzhong, Chuxuedian: chuxuedian, Fayu: fayu, Yinyang: yinyang, Shenzhi: shenzhi, Pifunianmo: pifunianmo, Buwei: buwei, Chengdu: chengdu, Pixiachuxue: pixiachuxue, Zidian: zidian, Pifuwendu: pifuwendu, Qita: qita, Linbazhongda: linbazhongda, Linbabuwei: linbabuwei, Yanlian: yanlian, Tongkong: tongkong, Zuo: zuo, You: you, Duiguangfanshe: duiguangfanshe, Biantaoti: biantaoti, Yanbu: yanbu, Toubuqita: toubuqita, Huxiyin: huxiyin, Xiongmomocayin: xiongmomocayin, Feizhangbuwei: feizhangbuwei, Luoyin: luoyin, Desc: desc, Xinzangdaxiao: xinzangdaxiao, Xinlv: xinlv, Xinbaomocasheng: xinbaomocasheng, Zayin: zayin, Fujiayin: fujiayin, Xinzangdesc: xinzangdesc, Fushuizheng: fushuizheng, Ganjingjingmai: ganjingjingmai, GangzhangYatong: gangzhang_yatong, GangzhangKoutong: gangzhang_koutong, PizhangKoutong: pizhang_koutong, PizhangYatong: pizhang_yatong, ShenzhangKoutong: shenzhang_koutong, ShenzhangYatong: shenzhang_yatong, FubuDesc: fubu_desc, OthDesc: oth_desc, } createErr := service.ModifyPatientPhysiqueCheck(&record) if createErr != nil { this.ErrorLog("修改患者体格检查失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } // /api/patient/courses [get] // @param patient_id:int // @param start_time:string (yyyy-MM-dd) // @param end_time:string (yyyy-MM-dd) func (this *PatientDataConfigAPIController) Courses() { patientID, _ := this.GetInt64("patient_id") startTimeYMDStr := this.GetString("start_time") endTimeYMDStr := this.GetString("end_time") if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59" startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr) endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr) if parseStartTimeErr != nil || parseEndTimeErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong) return } adminUserInfo := this.GetAdminUserInfo() //patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) //if getPatientErr != nil { // this.ErrorLog("获取患者信息失败:%v", getPatientErr) // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return //} else if patient == nil { // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) // return //} records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix()) if getRecordsErr != nil { this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId) if getAllAdminsErr != nil { this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "records": records, "doctors": admins, }) } // /api/patient/course/create [post] // @param patient_id:int // @param content:string func (this *PatientDataConfigAPIController) CreateCourse() { patientID, _ := this.GetInt64("patient_id") fmt.Println(patientID) content := this.GetString("content") record_time_str := this.GetString("record_time") title := this.GetString("title") if patientID <= 0 || len(content) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } if len(record_time_str) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str) adminUserInfo := this.GetAdminUserInfo() //patient, _ := service.GetPatientByIDOne(adminUserInfo.CurrentOrgId, patientID) //if getPatientErr != nil { // this.ErrorLog("获取患者信息失败:%v", getPatientErr) // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return //} else if patient == nil { // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) // return //} now := time.Now().Unix() record := models.PatientDiseaseCourse{ OrgID: adminUserInfo.CurrentOrgId, PatientID: patientID, Recorder: adminUserInfo.AdminUser.Id, RecordTime: checkDate.Unix(), Content: content, Status: 1, CreateTime: now, ModifyTime: now, Title: title, } createErr := service.CreatePatientCourseOfDisease(&record) if createErr != nil { this.ErrorLog("创建患者病程记录失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } // /api/patient/course/delete // @param patient_id:int // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7") func (this *PatientDataConfigAPIController) DeleteCourse() { patientID, _ := this.GetInt64("patient_id") idsStr := this.GetString("ids") if patientID <= 0 || len(idsStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } recordIDStrs := strings.Split(idsStr, ",") recordIDs := make([]int64, 0, len(recordIDStrs)) for _, idStr := range recordIDStrs { id, parseErr := strconv.Atoi(idStr) if parseErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } recordIDs = append(recordIDs, int64(id)) } deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs) if deleteErr != nil { this.ErrorLog("删除患者病程记录失败:%v", deleteErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(nil) } // /api/patient/rescues [get] // @param patient_id:int // @param start_time:string (yyyy-MM-dd) // @param end_time:string (yyyy-MM-dd) func (this *PatientDataConfigAPIController) Rescues() { patientID, _ := this.GetInt64("patient_id") startTimeYMDStr := this.GetString("start_time") endTimeYMDStr := this.GetString("end_time") if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59" startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr) endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr) if parseStartTimeErr != nil || parseEndTimeErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix()) if getRecordsErr != nil { this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId) if getAllAdminsErr != nil { this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "records": records, "doctors": admins, }) } // /api/patient/rescue/create [post] // @param patient_id:int // @param content:string func (this *PatientDataConfigAPIController) CreateRescue() { patientID, _ := this.GetInt64("patient_id") content := this.GetString("content") if patientID <= 0 || len(content) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } now := time.Now().Unix() record := models.PatientRescueRecord{ OrgID: adminUserInfo.CurrentOrgId, PatientID: patientID, Recorder: adminUserInfo.AdminUser.Id, RecordTime: now, Content: content, Status: 1, CreateTime: now, ModifyTime: now, } createErr := service.CreatePatientRescueRecord(&record) if createErr != nil { this.ErrorLog("创建患者抢救记录失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } // /api/patient/rescue/delete // @param patient_id:int // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7") func (this *PatientDataConfigAPIController) DeleteRescue() { patientID, _ := this.GetInt64("patient_id") idsStr := this.GetString("ids") if patientID <= 0 || len(idsStr) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } recordIDStrs := strings.Split(idsStr, ",") recordIDs := make([]int64, 0, len(recordIDStrs)) for _, idStr := range recordIDStrs { id, parseErr := strconv.Atoi(idStr) if parseErr != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } recordIDs = append(recordIDs, int64(id)) } deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs) if deleteErr != nil { this.ErrorLog("删除患者抢救记录失败:%v", deleteErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(nil) } func (this *PatientDataConfigAPIController) ModifyCourse() { patientID, _ := this.GetInt64("patient_id") content := this.GetString("content") id, _ := this.GetInt64("id", 0) record_time_str := this.GetString("record_time") title := this.GetString("title") if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } //timeLayout := "2006-01-02" //loc, _ := time.LoadLocation("Local") checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str) adminUserInfo := this.GetAdminUserInfo() patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID) if getPatientErr != nil { this.ErrorLog("获取患者信息失败:%v", getPatientErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } else if patient == nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist) return } now := time.Now().Unix() record := models.PatientDiseaseCourse{ ID: id, OrgID: adminUserInfo.CurrentOrgId, PatientID: patientID, Recorder: adminUserInfo.AdminUser.Id, Content: content, Status: 1, CreateTime: now, ModifyTime: now, Title: title, RecordTime: checkDate.Unix(), } createErr := service.ModifyPatientCourses(&record) if createErr != nil { this.ErrorLog("创建患者抢救记录失败:%v", createErr) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) return } this.ServeSuccessJSON(map[string]interface{}{ "record": record, }) } func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() { patientID, _ := this.GetInt64("patient_id") record_date := this.GetString("record_date") timeLayout := "2006-01-02" loc, _ := time.LoadLocation("Local") var startTime int64 if len(record_date) > 0 { theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } startTime = theTime.Unix() } //获取患者姓名 patient, _ := service.GetPatientName(patientID) orgId := this.GetAdminUserInfo().CurrentOrgId //获取透析处方 prescription, _ := service.GetDialysisPrescription(patientID, orgId, startTime) //获取透前评估 assessmentBefor, _ := service.GetAssessmentBefor(orgId, patientID, startTime) //透析上机 order, _ := service.GetDialysisOrder(orgId, patientID, startTime) //透析监测 monitor, _ := service.GetFistMonitorSix(orgId, patientID, startTime) //透析医嘱 advice, _ := service.GetBloodDoctorAdvice(startTime, orgId, patientID) //透后评估 afterDislysis, _ := service.GetAssessmentAfterDissData(patientID, orgId, startTime) this.ServeSuccessJSON(map[string]interface{}{ "patient": patient, "prescription": prescription, "assessmentBefor": assessmentBefor, "order": order, "monitor": monitor, "advice": advice, "afterDislysis": afterDislysis, }) } func (this *PatientDataConfigAPIController) GetContextScheduleList() { limit, _ := this.GetInt64("limit") page, _ := this.GetInt64("page") start_time := this.GetString("start_time") end_time := this.GetString("end_time") timeLayout := "2006-01-02" loc, _ := time.LoadLocation("Local") var startTime int64 if len(start_time) > 0 { theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } startTime = theTime.Unix() } var endTime int64 if len(end_time) > 0 { theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc) if err != nil { this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } startTime = theTime.Unix() } org_id := this.GetAdminUserInfo().CurrentOrgId schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id) list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id) patients, _ := service.GetAllpatientThirty(org_id) devicenumber, _ := service.GetAllBedNumber(org_id) this.ServeSuccessJSON(map[string]interface{}{ "schedule": schedule, "total": total, "list": list, "patients": patients, "devicenumber": devicenumber, }) } func (this *PatientDataConfigAPIController) GetPatientAllagicList() { id, _ := this.GetInt64("id") orgId := this.GetAdminUserInfo().CurrentOrgId list, _ := service.GetPatientAllagicList(id, orgId) this.ServeSuccessJSON(map[string]interface{}{ "list": list, }) } func (this *PatientDataConfigAPIController) SaveSiteMap() { dataBody := make(map[string]interface{}, 0) err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody) if err != nil { utils.ErrorLog(err.Error()) this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) return } patient_id := int64(dataBody["patient_id"].(float64)) user_org_id := this.GetAdminUserInfo().CurrentOrgId id := int64(dataBody["id"].(float64)) if dataBody["a_left"] != nil && reflect.TypeOf(dataBody["a_left"]).String() == "[]interface {}" { prescriptions, _ := dataBody["a_left"].([]interface{}) service.UpdateValsualAleft(patient_id, user_org_id) for _, item := range prescriptions { var a_num float64 var mark_num float64 if item.(map[string]interface{})["a_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_num"]).String() == "float64" { a_num = item.(map[string]interface{})["a_num"].(float64) } if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" { mark_num = item.(map[string]interface{})["markNum"].(float64) } fmt.Println(a_num, mark_num) valsualALeft := models.XtDeviceValsualALeft{ ANum: a_num, MarkNum: mark_num, UserOrgId: user_org_id, PatientId: patient_id, Ctime: time.Now().Unix(), Mtime: time.Now().Unix(), MapId: 0, Status: 1, } service.CreateValsualAleft(valsualALeft) } } is_append := int64(dataBody["is_append"].(float64)) is_img_v := int64(dataBody["is_img_v"].(float64)) is_img_a := int64(dataBody["is_img_a"].(float64)) a_top := dataBody["a_top"].(float64) av_bkx := dataBody["av_bkx"].(float64) av_bky := dataBody["av_bky"].(float64) if dataBody["fangxiang_a"] != nil && reflect.TypeOf(dataBody["fangxiang_a"]).String() == "[]interface {}" { prescriptions, _ := dataBody["fangxiang_a"].([]interface{}) service.ValsualMapFangxiangA(patient_id, user_org_id) for _, item := range prescriptions { var a_num float64 var mark_num float64 var mark_top float64 if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" { a_num = item.(map[string]interface{})["left"].(float64) } if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" { mark_num = item.(map[string]interface{})["markNum"].(float64) } if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" { mark_top = item.(map[string]interface{})["top"].(float64) } ValsualMapFangxiangA := models.XtDeviceValsualMapFangxiangA{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, Left: a_num, MarkNum: mark_num, Top: mark_top, MapId: 0, Ctime: time.Now().Unix(), Mtime: time.Now().Unix(), } service.CreateValsualMapFangxiangA(ValsualMapFangxiangA) } } fangxiang_a_num := dataBody["fangxiang_a_num"].(float64) fangxiang_a_top := dataBody["fangxiang_a_top"].(float64) fangxiang_v_left := dataBody["fangxiang_v_left"].(float64) fangxiang_v_num := dataBody["fangxiang_v_num"].(float64) fangxiang_v_top := dataBody["fangxiang_v_top"].(float64) if dataBody["fangxiang_v"] != nil && reflect.TypeOf(dataBody["fangxiang_v"]).String() == "[]interface {}" { prescriptions, _ := dataBody["fangxiang_v"].([]interface{}) service.UpdateValsualMapFangxiangV(patient_id, user_org_id) for _, item := range prescriptions { var a_num float64 var mark_num float64 var mark_top float64 if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" { a_num = item.(map[string]interface{})["left"].(float64) } if item.(map[string]interface{})["markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["markNum"]).String() == "float64" { mark_num = item.(map[string]interface{})["markNum"].(float64) } if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" { mark_top = item.(map[string]interface{})["top"].(float64) } ValsualMapFangxiangV := models.XtDeviceValsualMapFangxiangV{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, Left: a_num, MarkNum: mark_num, Top: mark_top, MapId: 0, Ctime: time.Now().Unix(), Mtime: time.Now().Unix(), } service.CreateValsualMapFangxiangV(ValsualMapFangxiangV) } } fangxiang_a_left := dataBody["fangxiang_a_left"].(float64) if dataBody["fuzhu_a"] != nil && reflect.TypeOf(dataBody["fuzhu_a"]).String() == "[]interface {}" { prescriptions, _ := dataBody["fuzhu_a"].([]interface{}) service.UpdateValSualFuzhA(patient_id, user_org_id) for _, item := range prescriptions { var a_left float64 var a_markNum float64 var a_top float64 if item.(map[string]interface{})["a_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_left"]).String() == "float64" { a_left = item.(map[string]interface{})["a_left"].(float64) } if item.(map[string]interface{})["a_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_markNum"]).String() == "float64" { a_markNum = item.(map[string]interface{})["a_markNum"].(float64) } if item.(map[string]interface{})["a_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["a_top"]).String() == "float64" { a_top = item.(map[string]interface{})["a_top"].(float64) } valsualFuzhuA := models.XtDeviceValsualFuzhuA{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, Ctime: time.Now().Unix(), Mtime: time.Now().Unix(), ALeft: a_left, AMarkNum: a_markNum, ATop: a_top, MapId: 0, } service.CreateValSualFuzhA(valsualFuzhuA) } } fuzhu_a_left := dataBody["fuzhu_a_left"].(float64) fuzhu_a_num := dataBody["fuzhu_a_num"].(float64) fuzhu_a_top := dataBody["fuzhu_a_top"].(float64) left_a := dataBody["left_a"].(float64) left_v := dataBody["left_v"].(float64) if dataBody["fuzhu_v"] != nil && reflect.TypeOf(dataBody["fuzhu_v"]).String() == "[]interface {}" { prescriptions, _ := dataBody["fuzhu_v"].([]interface{}) service.UpdateVasuaLfuzhuV(patient_id, user_org_id) for _, item := range prescriptions { var v_left float64 var v_markNum float64 var v_top float64 if item.(map[string]interface{})["v_left"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_left"]).String() == "float64" { v_left = item.(map[string]interface{})["v_left"].(float64) } if item.(map[string]interface{})["v_markNum"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_markNum"]).String() == "float64" { v_markNum = item.(map[string]interface{})["v_markNum"].(float64) } if item.(map[string]interface{})["v_top"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_top"]).String() == "float64" { v_top = item.(map[string]interface{})["v_top"].(float64) } fuzhuV := models.XtDeviceValsualFuzhuV{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, Ctime: time.Now().Unix(), Mtime: 1, VMarkNum: v_markNum, VLeft: v_left, VTop: v_top, MapId: 0, } service.CreateVasuaLfuzhuV(fuzhuV) } } fuzhu_v_left := dataBody["fuzhu_v_left"].(float64) fuzhu_v_num := dataBody["fuzhu_v_num"].(float64) fuzhu_v_top := dataBody["fuzhu_v_top"].(float64) scalea_num := dataBody["scalea_num"].(float64) scalev_num := dataBody["scalev_num"].(float64) if dataBody["text_arr"] != nil && reflect.TypeOf(dataBody["text_arr"]).String() == "[]interface {}" { prescriptions, _ := dataBody["text_arr"].([]interface{}) service.UpdateTextArr(patient_id, user_org_id) for _, item := range prescriptions { var left float64 var text_markNum string var v_top float64 var width float64 if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" { left = item.(map[string]interface{})["left"].(float64) } if item.(map[string]interface{})["text"] != nil || reflect.TypeOf(item.(map[string]interface{})["text"]).String() == "string" { text_markNum = item.(map[string]interface{})["text"].(string) } if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" { v_top = item.(map[string]interface{})["top"].(float64) } if item.(map[string]interface{})["width"] != nil || reflect.TypeOf(item.(map[string]interface{})["width"]).String() == "float64" { width = item.(map[string]interface{})["width"].(float64) } textArr := models.XtDeviceValsualTextArr{ PatientId: patient_id, UserOrgId: user_org_id, Ctime: time.Now().Unix(), Mtime: 0, Status: 1, Left: left, Text: text_markNum, Top: v_top, Width: width, MapId: 0, } service.CreateTextArr(textArr) } text_left := dataBody["text_left"].(float64) text_num := dataBody["text_num"].(float64) text_top := dataBody["text_top"].(float64) if dataBody["v_left"] != nil && reflect.TypeOf(dataBody["v_left"]).String() == "[]interface {}" { prescriptions, _ := dataBody["v_left"].([]interface{}) service.UpdateValsualVleft(patient_id, user_org_id) for _, item := range prescriptions { var v_num float64 var markNum float64 if item.(map[string]interface{})["v_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["v_num"]).String() == "float64" { v_num = item.(map[string]interface{})["v_num"].(float64) } if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" { markNum = item.(map[string]interface{})["mark_num"].(float64) } valsualVLeft := models.XtDeviceValsualVLeft{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, Ctime: time.Now().Unix(), Mtime: time.Now().Unix(), MarkNum: markNum, VNum: v_num, MapId: 0, } service.CreateValsualVleft(valsualVLeft) } } if dataBody["aarr"] != nil && reflect.TypeOf(dataBody["aarr"]).String() == "[]interface {}" { prescriptions, _ := dataBody["aarr"].([]interface{}) service.UpdateValusalMapArr(patient_id, user_org_id) for _, item := range prescriptions { var mark_num float64 var is_status float64 var left float64 var top float64 if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" { mark_num = item.(map[string]interface{})["mark_num"].(float64) } if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" { is_status = item.(map[string]interface{})["is_status"].(float64) } if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" { left = item.(map[string]interface{})["left"].(float64) } if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" { top = item.(map[string]interface{})["top"].(float64) } mapArr := models.XtDeviceValusalMapArr{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, MarkNum: mark_num, Left: left, Top: top, IsStatus: is_status, Ctime: time.Now().Unix(), Mtime: 0, } service.CreateDeviceValusalMapArr(mapArr) } } if dataBody["varr"] != nil && reflect.TypeOf(dataBody["varr"]).String() == "[]interface {}" { prescriptions, _ := dataBody["varr"].([]interface{}) service.UpdateDeviceValusalMapVrr(patient_id, user_org_id) for _, item := range prescriptions { var mark_num float64 var is_status float64 var left float64 var top float64 if item.(map[string]interface{})["mark_num"] != nil || reflect.TypeOf(item.(map[string]interface{})["mark_num"]).String() == "float64" { mark_num = item.(map[string]interface{})["mark_num"].(float64) } if item.(map[string]interface{})["is_status"] != nil || reflect.TypeOf(item.(map[string]interface{})["is_status"]).String() == "float64" { is_status = item.(map[string]interface{})["is_status"].(float64) } if item.(map[string]interface{})["left"] != nil || reflect.TypeOf(item.(map[string]interface{})["left"]).String() == "float64" { left = item.(map[string]interface{})["left"].(float64) } if item.(map[string]interface{})["top"] != nil || reflect.TypeOf(item.(map[string]interface{})["top"]).String() == "float64" { top = item.(map[string]interface{})["top"].(float64) } mapVrr := models.XtDeviceValusalMapVrr{ PatientId: patient_id, UserOrgId: user_org_id, Status: 1, MarkNum: mark_num, Left: left, Top: top, IsStatus: is_status, Ctime: time.Now().Unix(), Mtime: 0, } service.CreateDeviceValusalMapVrr(mapVrr) } } v_num := dataBody["v_num"].(float64) v_top := dataBody["v_top"].(float64) xuanzhuan_a := dataBody["xuanzhuan_a"].(float64) xuanzhuan_v := dataBody["xuanzhuan_v"].(float64) img_url := dataBody["img_url"].(string) deviceValsualMap := models.XtDeviceValsualMap{ ID: id, PatientId: patient_id, IsAppend: is_append, IsImgV: is_img_v, IsImgA: is_img_a, VNum: v_num, Status: 1, UserOrgId: user_org_id, ATop: a_top, AvBkx: av_bkx, AvBky: av_bky, FangxiangALeft: fangxiang_a_left, FangxiangANum: fangxiang_a_num, FangxiangATop: fangxiang_a_top, FangxiangVLeft: fangxiang_v_left, FangxiangVNum: fangxiang_v_num, FangxiangVTop: fangxiang_v_top, FuzhuALeft: fuzhu_a_left, FuzhuANum: fuzhu_a_num, FuzhuATop: fuzhu_a_top, FuzhuVLeft: fuzhu_v_left, FuzhuVNum: fuzhu_v_num, FuzhuVTop: fuzhu_v_top, ScaleaNum: scalea_num, ScalevNum: scalev_num, TextLeft: text_left, TextNum: text_num, TextTop: text_top, VTop: v_top, XuanzhuanA: xuanzhuan_a, XuanzhuanV: xuanzhuan_v, ALeft: left_a, VLeft: left_v, ImgUrl: img_url, } err = service.CreateDeviceValsualMap(deviceValsualMap) this.ServeSuccessJSON(map[string]interface{}{ "deviceValsualMap": deviceValsualMap, }) } } func (this *PatientDataConfigAPIController) GetPatientSitemap() { patient_id, _ := this.GetInt64("patient_id") orgId := this.GetAdminUserInfo().CurrentOrgId sitemap, _ := service.GetPatientSitemap(patient_id, orgId) patients, _ := service.GetPatientByIDOne(orgId, patient_id) this.ServeSuccessJSON(map[string]interface{}{ "sitemap": sitemap, "patients": patients, }) } func (this *PatientDataConfigAPIController) GetPatientDetailInformedConsent() { patient_id, _ := this.GetInt64("patient_id") orgId := this.GetAdminUserInfo().CurrentOrgId patients, _ := service.GetPatientDetailInformedConsent(patient_id, orgId) this.ServeSuccessJSON(map[string]interface{}{ "patients": patients, }) }