123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- package xcx_mobile_api_controller_go
-
- import (
- "Xcx_New/controllers/mobile_api_controllers"
- "Xcx_New/enums"
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "fmt"
- "github.com/astaxie/beego"
- "github.com/jinzhu/gorm"
- "strconv"
- "time"
- )
-
- func XcxApiControllersRegisterRouters() {
- ////传送codeinit
- beego.Router("/xcx/m/api/code", &XcxApiController{}, "Get:GetCodeInit")
- //获取验证码
- beego.Router("/xcx/api/mobile/code", &XcxApiController{}, "Get:GetCodeInfo")
- //用户绑定
- beego.Router("/xcx/api/mobile/register", &XcxApiController{}, "Get:GetUserRegister")
- //登录
- beego.Router("/xcx/api/mobile/login", &XcxApiController{}, "Get:GetLoginInfor")
-
- //获取二维码信息
- beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
-
- //获取登录后的信息
- beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
-
- //获取排班数据
- beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
-
- //获取透析记录
- beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
-
- //获取患者的电子病历
- beego.Router("/xcx/api/mobile/getpatientinfo", &XcxApiController{}, "Get:GetPatientInfo")
-
- //获取机构名称
- beego.Router("/xcx/api/mobile/getorginfo", &XcxApiController{}, "Get:GetOrgInfo")
- }
-
- type XcxApiController struct {
- mobile_api_controllers.MobileBaseAPIController
- }
-
- func (this *XcxApiController) GetCodeInit() {
- redisClient := service.RedisClient()
- defer redisClient.Close()
- req := this.Ctx.Request
- addr := utils.GetIP(req)
- cur_time := time.Now().Format("2006-01-02")
- _, err := redisClient.Get("ip:host_" + cur_time + "_" + addr).Result()
- if err != nil {
- redisClient.Set("ip:host_"+cur_time+"_"+addr, 0, time.Second*24*60*60)
- }
- //将客户端的ip加密传给前端,作为短信验证的密钥,来验证短信发送的IP地址
- aespass := utils.AESEncrypt(addr)
-
- fmt.Println("hhhhhhh3223323232332", aespass)
- this.ServeSuccessJSON(map[string]interface{}{
- "aespass": aespass,
- })
-
- }
-
- func (this *XcxApiController) GetUserRegister() {
-
- //用户绑定
- name := this.GetString("name")
- id_card_no := this.GetString("id_card_no")
- fmt.Println("id_card_no", id_card_no)
- mobile := this.GetString("mobile")
- code := this.GetString("code")
- patient, errcodes := service.GetMobilePatient(id_card_no)
- fmt.Println("errcodes2323232232", errcodes)
- if errcodes == nil {
- role := models.XcxAdminUserRole{
- PatientName: name,
- IdCardNo: id_card_no,
- Mobile: mobile,
- Code: code,
- PatientId: patient.ID,
- UserOrgId: patient.UserOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Appid: "",
- Appsecret: "",
- SessionKey: "",
- }
-
- //查找该电话号码是否存在
- _, errcode := service.GetMobilePatient(mobile)
- if errcode == gorm.ErrRecordNotFound {
- err := service.CreateXcxAdminUser(role)
- if err == nil {
- mobilePatient, _ := service.GetMobilePatient(id_card_no)
- this.ServeSuccessJSON(map[string]interface{}{
- "role": role,
- "is_bind": true,
- "patient": mobilePatient,
- })
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- "msg": "绑定失败",
- })
- }
- } else if errcode == nil {
- mobilePatient, _ := service.GetMobilePatient(id_card_no)
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": true,
- "patient": mobilePatient,
- })
- }
-
- fmt.Println("roler", role)
- } else if errcodes == gorm.ErrRecordNotFound {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_bind": false,
- })
- }
-
- }
-
- func (this *XcxApiController) GetCodeInfo() {
-
- //mobile := this.GetString("phone")
- //aespass := this.GetString("aespass")
- //utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
- //if utils.CellPhoneRegexp().MatchString(mobile) == false {
- // this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
- // this.ServeJSON()
- // return
- //}
-
- //if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
- // this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
- // this.ServeJSON()
- //} else {
- // this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
- // "msg": "短信发送成功,有效期为10分钟",
- //
- // })
- // this.ServeJSON()
- //}
- this.ServeSuccessJSON(map[string]interface{}{
- "code": "100100",
- })
- }
-
- func (this *XcxApiController) GetLoginInfor() {
-
- mobile := this.GetString("mobile")
- fmt.Println(mobile)
- user_admin, errcodes := service.GetXcxMobileInformation(mobile)
- if errcodes == gorm.ErrRecordNotFound {
- info, _ := service.GetMobilePatientInfo(mobile)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": info,
- "role": user_admin,
- "is_bind": false,
- })
- } else if errcodes == nil {
- info, _ := service.GetPatientListByPatientId(user_admin.PatientId)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": info,
- "role": user_admin,
- "is_bind": true,
- })
- }
-
- }
-
- func (this *XcxApiController) GetPatientList() {
- appid := "wx20b60369111b063a"
- key := "Yz1HgsFX3yJvWPJSEdwJDA=="
- strs := "uSevGQ5ShkiHjQuqz7s36SKZisVGA4fHH/dy+etg0W7ibVeidl6TyFS+kQZ6B9AI2T+1kOtKXeyveQR7q2TXJdu3fhKCFoLKVFzICNEvkiHMnchJ0T0OpRO3oT+icYq80+egvT+jMSgP7yi0cAgmiKaK/4QURD7+nvxRAj9drzz77sbeFt8KElb1LN/+Wn8dIoQzisxbON9G1VJYYtyBkQ=="
- iv := "JgsbDhJ613uaAgAoBVh0Zw=="
- //data, err := service.Dncrypt(strs, key, iv)
- //fmt.Println(err)
-
- data, err := service.DecryptData(appid, key, iv, strs)
- patient_id, _ := this.GetInt64("patient_id")
- patient, err := service.GetPatientListByPatientId(patient_id)
-
- if err == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- "data": data,
- })
- }
-
- func (this *XcxApiController) GetDataInfo() {
-
- appid := this.GetString("appid")
- fmt.Println(appid)
- key := this.GetString("key")
- iv := this.GetString("iv")
- encryptedData := this.GetString("encryptedData")
- list, _ := service.DecryptData(appid, key, iv, encryptedData)
- //list, _ := service.Dncrypt(encryptedData, key, iv)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *XcxApiController) GetScheduleInfo() {
- patient_id, _ := this.GetInt64("patient_id")
- fmt.Println(patient_id)
- thisWeekMonday := service.GetFirstDateOfWeek()
- weekDayWeek := service.GetWeekDayOfWeek()
- TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
- weekDays, _ := time.Parse("2006-01-02", weekDayWeek)
- lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
- nextWeekMonday := weekDays.AddDate(0, 0, +13)
- var weekMonday = lastWeekMonday.Format("2006-01-02")
- var weekDay = nextWeekMonday.Format("2006-01-02")
- fmt.Println("weekmodonday", weekMonday)
- fmt.Println("nextweeekday", weekDay)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
- fmt.Println("startiem", startTime)
- endTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekDay+"00:00:00", loc)
- fmt.Println(startTime.Unix(), endTime.Unix())
- schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), patient_id)
-
- //获取当前今日的排班日期
- time_now := time.Now().Format("2006-01-02")
- fmt.Println("time_now", time_now)
- timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
- fmt.Println("timeNowUnix", timeNowUnix.Unix())
-
- //获取今日下机日期
- order, _ := service.GetTodayDialysis(timeNowUnix.Unix(), patient_id)
-
- //获取下一次排班信息
- patientSchedule, _ := service.GetNextPatientSchedule(1, timeNowUnix.Unix())
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- var one = startTime.Unix() + 86400
- fmt.Println("one2322332", one)
- var two = one + 86400
- var three = two + 86400
- var four = three + 86400
- var five = four + 86400
- var six = five + 86400
- var seven = six + 86400
-
- var nextOne = seven + 86400
- var nexttwo = nextOne + 86400
- var nextthree = nexttwo + 86400
- var nextfour = nextthree + 86400
- var nextfive = nextfour + 86400
- var nextsix = nextfive + 86400
- var nextseven = nextsix + 86400
-
- var lastOne = nextseven + 86400
- var lastwo = lastOne + 86400
- var lasthree = lastwo + 86400
- var lastfour = lasthree + 86400
- var lastfive = lastfour + 86400
- var lastsix = lastfive + 86400
- var lastseven = lastsix + 86400
-
- fmt.Println("各地好当家232332323232", lastseven)
- array := []interface{}{
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
-
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
-
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": schedule,
- "array": array,
- "order": order,
- "patientSchedule": patientSchedule,
- })
- }
-
- func (this *XcxApiController) GetMobileSchedule() {
-
- patientID, _ := this.GetInt64("patient_id")
- recordDateStr := this.GetString("date")
- if patientID <= 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- this.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminInfo := this.GetMobileAdminUserInfo()
- patient, getPatientErr := service.MobileGetPatientDetail(adminInfo.Org.Id, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- schedual, getSchedualErr := service.MobileGetSchedualDetail(adminInfo.Org.Id, patientID, date.Unix())
-
- if getSchedualErr != nil {
- this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
- if getRTARErr != nil {
- this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
- if getPEErr != nil {
- this.ErrorLog("获取透前评估失败:%v", getPEErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
- if getLPEErr != nil {
- this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
- if getDoctorAdvicesErr != nil {
- this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
- if getDialysisOrderErr != nil {
- this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
- if getDoubleCheckErr != nil {
- this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
- if getMonitorRecordsErr != nil {
- this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var lastMonitorRecord *models.MonitoringRecord
-
- lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecord(adminInfo.Org.Id, patientID, date.Unix())
- if getLastErr != nil {
- this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
- if getAADErr != nil {
- this.ErrorLog("获取透后评估失败:%v", getAADErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- lastAssessmentAfterDislysis, getLAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
- if getLAADErr != nil {
- this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
- if getTreatmentSummaryErr != nil {
- this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
-
- dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
-
- lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
-
- //获取系统透析处方模版
- systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(adminInfo.Org.Id, schedual.ModeId)
-
- _, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
-
- _, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
-
- projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
-
- stockType, _ := service.GetStockType(adminInfo.Org.Id)
-
- prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
-
- //获取最后一次血管通路
- lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
-
- prescribeOne, parseDateErr := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
- var his_advices []*models.HisDoctorAdviceInfo
- if is_open_config.IsOpen == 1 {
- his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
- }
-
- if getLPEErr != nil {
- this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
- if getDryErr != nil {
- this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- _, gobalConfig := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
-
- operators, _ := service.GetAllStarfEs(adminInfo.Org.Id)
-
- returnData := map[string]interface{}{
- "patient": patient,
- "schedual": schedual,
- "prescription": dialysisPrescribe,
- "solution": dialysisSolution,
- "last_prescription": lastDialysisPrescribe,
- "receiver_treatment_access": receiverTreatmentAccess,
- "predialysis_evaluation": predialysisEvaluation,
- "doctor_advices": doctorAdvices,
- "double_check": doubleCheck,
- "assessment_after_dislysis": assessmentAfterDislysis,
- "treatment_summary": treatmentSummary,
- "monitor_records": monitorRecords,
- "dialysis_order": dialysisOrder,
- "operators": operators,
- "last_predialysis_evaluation": lastPredialysisEvaluation,
- "last_assessment_after_dislysis": lastAssessmentAfterDislysis,
- "last_monitor_record": lastMonitorRecord,
- "config": gobalConfig,
- "dry_weight": lastDryWeightDislysis,
- "system_prescription": systemDialysisPrescribe,
- "his_advices": his_advices,
- "is_open_config": is_open_config,
- "stockType": stockType,
- "prepare": prepare,
- "lastAssessment": lastAssessment,
- "prescribeOne": prescribeOne,
- "is_project_open_config": is_project_open_config,
- "project": projects,
- }
- this.ServeSuccessJSON(returnData)
-
- }
-
- func (this *XcxApiController) GetPatientInfo() {
-
- patient_id, _ := this.GetInt64("patient_id")
- patient, _ := service.GetXcxPatientInfo(patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *XcxApiController) GetOrgInfo() {
- patient_id, _ := this.GetInt64("patient_id")
- info, _ := service.GetXcxPatientInfo(patient_id)
- orgInfo, _ := service.GetOrgInfo(info.UserOrgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "orgInfo": orgInfo,
- })
- }
|