xcx_api_controller.go 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. package xcx_mobile_api_controller_go
  2. import (
  3. "Xcx_New/controllers/mobile_api_controllers"
  4. "Xcx_New/enums"
  5. "Xcx_New/models"
  6. "Xcx_New/service"
  7. "Xcx_New/utils"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "github.com/jinzhu/gorm"
  11. "time"
  12. )
  13. func XcxApiControllersRegisterRouters() {
  14. ////传送codeinit
  15. beego.Router("/xcx/m/api/code", &XcxApiController{}, "Get:GetCodeInit")
  16. //获取验证码
  17. beego.Router("/xcx/api/mobile/code", &XcxApiController{}, "Get:GetCodeInfo")
  18. //用户绑定
  19. beego.Router("/xcx/api/mobile/register", &XcxApiController{}, "Get:GetUserRegister")
  20. //登录
  21. beego.Router("/xcx/api/mobile/login", &XcxApiController{}, "Get:GetLoginInfor")
  22. //获取二维码信息
  23. beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
  24. //获取登录后的信息
  25. beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
  26. //获取排班数据
  27. beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
  28. //获取透析记录
  29. beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
  30. }
  31. type XcxApiController struct {
  32. mobile_api_controllers.MobileBaseAPIController
  33. }
  34. func (this *XcxApiController) GetCodeInit() {
  35. redisClient := service.RedisClient()
  36. defer redisClient.Close()
  37. req := this.Ctx.Request
  38. addr := utils.GetIP(req)
  39. cur_time := time.Now().Format("2006-01-02")
  40. _, err := redisClient.Get("ip:host_" + cur_time + "_" + addr).Result()
  41. if err != nil {
  42. redisClient.Set("ip:host_"+cur_time+"_"+addr, 0, time.Second*24*60*60)
  43. }
  44. //将客户端的ip加密传给前端,作为短信验证的密钥,来验证短信发送的IP地址
  45. aespass := utils.AESEncrypt(addr)
  46. fmt.Println("hhhhhhh3223323232332", aespass)
  47. this.ServeSuccessJSON(map[string]interface{}{
  48. "aespass": aespass,
  49. })
  50. }
  51. func (this *XcxApiController) GetUserRegister() {
  52. //用户绑定
  53. name := this.GetString("name")
  54. id_card_no := this.GetString("id_card_no")
  55. mobile := this.GetString("mobile")
  56. code := this.GetString("code")
  57. patient, errcodes := service.GetMobilePatient(id_card_no)
  58. if errcodes == gorm.ErrRecordNotFound {
  59. role := models.XcxAdminUserRole{
  60. PatientName: name,
  61. IdCardNo: id_card_no,
  62. Mobile: mobile,
  63. Code: code,
  64. PatientId: patient.ID,
  65. UserOrgId: patient.UserOrgId,
  66. Status: 1,
  67. Ctime: time.Now().Unix(),
  68. Mtime: 0,
  69. Appid: "",
  70. Appsecret: "",
  71. SessionKey: "",
  72. }
  73. //查找该电话号码是否存在
  74. _, errcode := service.GetMobilePatient(mobile)
  75. if errcode == gorm.ErrRecordNotFound {
  76. err := service.CreateXcxAdminUser(role)
  77. if err == nil {
  78. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  79. return
  80. }
  81. this.ServeSuccessJSON(map[string]interface{}{
  82. "role": role,
  83. })
  84. } else if errcode == nil {
  85. mobilePatient, _ := service.GetMobilePatient(id_card_no)
  86. this.ServeSuccessJSON(map[string]interface{}{
  87. "is_bind": true,
  88. "patient": mobilePatient,
  89. })
  90. }
  91. fmt.Println("roler", role)
  92. } else if errcodes == nil {
  93. this.ServeSuccessJSON(map[string]interface{}{
  94. "is_bind": false,
  95. "patient": patient,
  96. })
  97. }
  98. }
  99. func (this *XcxApiController) GetCodeInfo() {
  100. mobile := this.GetString("phone")
  101. aespass := this.GetString("aespass")
  102. utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
  103. if utils.CellPhoneRegexp().MatchString(mobile) == false {
  104. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
  105. this.ServeJSON()
  106. return
  107. }
  108. if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
  109. this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
  110. this.ServeJSON()
  111. } else {
  112. this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
  113. "msg": "短信发送成功,有效期为10分钟",
  114. })
  115. this.ServeJSON()
  116. }
  117. }
  118. func (this *XcxApiController) GetLoginInfor() {
  119. mobile := this.GetString("mobile")
  120. fmt.Println(mobile)
  121. info, _ := service.GetMobilePatientInfo("18179463966")
  122. if info.ID == 0 {
  123. this.ServeSuccessJSON(map[string]interface{}{
  124. "is_bind": false,
  125. "info": info,
  126. })
  127. } else {
  128. _, errcode := service.GetLoginInfor("18179463966")
  129. if errcode == gorm.ErrRecordNotFound {
  130. role := models.XcxAdminUserRole{
  131. PatientName: info.Name,
  132. IdCardNo: info.IdCardNo,
  133. Mobile: info.TellPhone,
  134. Code: "",
  135. PatientId: info.ID,
  136. UserOrgId: info.UserOrgId,
  137. Status: 1,
  138. Ctime: time.Now().Unix(),
  139. Mtime: 0,
  140. Appid: "",
  141. Appsecret: "",
  142. SessionKey: "",
  143. }
  144. err := service.CreateXcxAdminUser(role)
  145. fmt.Println(err)
  146. } else {
  147. this.ServeSuccessJSON(map[string]interface{}{
  148. "is_bind": true,
  149. "info": info,
  150. })
  151. }
  152. this.ServeSuccessJSON(map[string]interface{}{
  153. "is_bind": true,
  154. "info": info,
  155. })
  156. }
  157. }
  158. func (this *XcxApiController) GetPatientList() {
  159. appid := "wx20b60369111b063a"
  160. key := "Yz1HgsFX3yJvWPJSEdwJDA=="
  161. strs := "uSevGQ5ShkiHjQuqz7s36SKZisVGA4fHH/dy+etg0W7ibVeidl6TyFS+kQZ6B9AI2T+1kOtKXeyveQR7q2TXJdu3fhKCFoLKVFzICNEvkiHMnchJ0T0OpRO3oT+icYq80+egvT+jMSgP7yi0cAgmiKaK/4QURD7+nvxRAj9drzz77sbeFt8KElb1LN/+Wn8dIoQzisxbON9G1VJYYtyBkQ=="
  162. iv := "JgsbDhJ613uaAgAoBVh0Zw=="
  163. //data, err := service.Dncrypt(strs, key, iv)
  164. //fmt.Println(err)
  165. data, err := service.DecryptData(appid, key, iv, strs)
  166. patient_id, _ := this.GetInt64("patient_id")
  167. patient, err := service.GetPatientListByPatientId(patient_id)
  168. if err == nil {
  169. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  170. return
  171. }
  172. this.ServeSuccessJSON(map[string]interface{}{
  173. "patient": patient,
  174. "data": data,
  175. })
  176. }
  177. func (this *XcxApiController) GetDataInfo() {
  178. appid := this.GetString("appid")
  179. fmt.Println(appid)
  180. key := this.GetString("key")
  181. iv := this.GetString("iv")
  182. encryptedData := this.GetString("encryptedData")
  183. list, _ := service.DecryptData(appid, key, iv, encryptedData)
  184. //list, _ := service.Dncrypt(encryptedData, key, iv)
  185. this.ServeSuccessJSON(map[string]interface{}{
  186. "list": list,
  187. })
  188. }
  189. func (this *XcxApiController) GetScheduleInfo() {
  190. patient_id, _ := this.GetInt64("patient_id")
  191. fmt.Println(patient_id)
  192. thisWeekMonday := service.GetFirstDateOfWeek()
  193. weekDayWeek := service.GetWeekDayOfWeek()
  194. TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
  195. weekDays, _ := time.Parse("2006-01-02", weekDayWeek)
  196. lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
  197. nextWeekMonday := weekDays.AddDate(0, 0, +13)
  198. var weekMonday = lastWeekMonday.Format("2006-01-02")
  199. var weekDay = nextWeekMonday.Format("2006-01-02")
  200. fmt.Println("weekmodonday", weekMonday)
  201. fmt.Println("nextweeekday", weekDay)
  202. timeLayout := "2006-01-02"
  203. loc, _ := time.LoadLocation("Local")
  204. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
  205. //startTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekMonday+"00:00:00", loc)
  206. fmt.Println("startiem", startTime)
  207. endTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekDay+"00:00:00", loc)
  208. fmt.Println(startTime.Unix(), endTime.Unix())
  209. schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), 1)
  210. if err != nil {
  211. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  212. return
  213. }
  214. array := []interface{}{
  215. map[string]string{"schedule_type": "1", "schedule_date": "1632067200", "schedule_week": "1", "mode_id": "", "name": ""},
  216. map[string]string{"schedule_type": "2", "schedule_date": "1632067200", "schedule_week": "1", "mode_id": "", "name": ""},
  217. map[string]string{"schedule_type": "3", "schedule_date": "1632067200", "schedule_week": "1", "mode_id": "", "name": ""},
  218. map[string]string{"schedule_type": "1", "schedule_date": "1632153600", "schedule_week": "2", "mode_id": "", "name": ""},
  219. map[string]string{"schedule_type": "2", "schedule_date": "1632153600", "schedule_week": "2", "mode_id": "", "name": ""},
  220. map[string]string{"schedule_type": "3", "schedule_date": "1632153600", "schedule_week": "2", "mode_id": "", "name": ""},
  221. map[string]string{"schedule_type": "1", "schedule_date": "1632240000", "schedule_week": "3", "mode_id": "", "name": ""},
  222. map[string]string{"schedule_type": "2", "schedule_date": "1632240000", "schedule_week": "3", "mode_id": "", "name": ""},
  223. map[string]string{"schedule_type": "3", "schedule_date": "1632240000", "schedule_week": "3", "mode_id": "", "name": ""},
  224. map[string]string{"schedule_type": "1", "schedule_date": "1632240000", "schedule_week": "4", "mode_id": "", "name": ""},
  225. map[string]string{"schedule_type": "2", "schedule_date": "1632326400", "schedule_week": "4", "mode_id": "", "name": ""},
  226. map[string]string{"schedule_type": "3", "schedule_date": "1632326400", "schedule_week": "4", "mode_id": "", "name": ""},
  227. map[string]string{"schedule_type": "1", "schedule_date": "1632326400", "schedule_week": "5", "mode_id": "", "name": ""},
  228. map[string]string{"schedule_type": "2", "schedule_date": "1632412800", "schedule_week": "5", "mode_id": "", "name": ""},
  229. map[string]string{"schedule_type": "3", "schedule_date": "1632412800", "schedule_week": "5", "mode_id": "", "name": ""},
  230. map[string]string{"schedule_type": "1", "schedule_date": "1632412800", "schedule_week": "6", "mode_id": "", "name": ""},
  231. map[string]string{"schedule_type": "2", "schedule_date": "1630684800", "schedule_week": "6", "mode_id": "", "name": ""},
  232. map[string]string{"schedule_type": "3", "schedule_date": "1630684800", "schedule_week": "6", "mode_id": "", "name": ""},
  233. map[string]string{"schedule_type": "1", "schedule_date": "1630771200", "schedule_week": "7", "mode_id": "", "name": ""},
  234. map[string]string{"schedule_type": "2", "schedule_date": "1630771200", "schedule_week": "7", "mode_id": "", "name": ""},
  235. map[string]string{"schedule_type": "3", "schedule_date": "1630771200", "schedule_week": "7", "mode_id": "", "name": ""},
  236. map[string]string{"schedule_type": "1", "schedule_date": "1630857600", "schedule_week": "1", "mode_id": "", "name": ""},
  237. map[string]string{"schedule_type": "2", "schedule_date": "1630857600", "schedule_week": "1", "mode_id": "", "name": ""},
  238. map[string]string{"schedule_type": "3", "schedule_date": "1630857600", "schedule_week": "1", "mode_id": "", "name": ""},
  239. map[string]string{"schedule_type": "1", "schedule_date": "1630944000", "schedule_week": "2", "mode_id": "", "name": ""},
  240. map[string]string{"schedule_type": "2", "schedule_date": "1630944000", "schedule_week": "2", "mode_id": "", "name": ""},
  241. map[string]string{"schedule_type": "3", "schedule_date": "1630944000", "schedule_week": "2", "mode_id": "", "name": ""},
  242. map[string]string{"schedule_type": "1", "schedule_date": "1631030400", "schedule_week": "3", "mode_id": "", "name": ""},
  243. map[string]string{"schedule_type": "2", "schedule_date": "1631030400", "schedule_week": "3", "mode_id": "", "name": ""},
  244. map[string]string{"schedule_type": "3", "schedule_date": "1631030400", "schedule_week": "3", "mode_id": "", "name": ""},
  245. map[string]string{"schedule_type": "1", "schedule_date": "1631116800", "schedule_week": "4", "mode_id": "", "name": ""},
  246. map[string]string{"schedule_type": "2", "schedule_date": "1631116800", "schedule_week": "4", "mode_id": "", "name": ""},
  247. map[string]string{"schedule_type": "3", "schedule_date": "1631116800", "schedule_week": "4", "mode_id": "", "name": ""},
  248. map[string]string{"schedule_type": "1", "schedule_date": "1632499200", "schedule_week": "5", "mode_id": "", "name": ""},
  249. map[string]string{"schedule_type": "2", "schedule_date": "1632499200", "schedule_week": "5", "mode_id": "", "name": ""},
  250. map[string]string{"schedule_type": "3", "schedule_date": "1632499200", "schedule_week": "5", "mode_id": "", "name": ""},
  251. map[string]string{"schedule_type": "1", "schedule_date": "1632585600", "schedule_week": "6", "mode_id": "", "name": ""},
  252. map[string]string{"schedule_type": "2", "schedule_date": "1632585600", "schedule_week": "6", "mode_id": "", "name": ""},
  253. map[string]string{"schedule_type": "3", "schedule_date": "1632585600", "schedule_week": "6", "mode_id": "", "name": ""},
  254. map[string]string{"schedule_type": "1", "schedule_date": "1632672000", "schedule_week": "7", "mode_id": "", "name": ""},
  255. map[string]string{"schedule_type": "2", "schedule_date": "1632672000", "schedule_week": "7", "mode_id": "", "name": ""},
  256. map[string]string{"schedule_type": "3", "schedule_date": "1632672000", "schedule_week": "7", "mode_id": "", "name": ""},
  257. map[string]string{"schedule_type": "1", "schedule_date": "1631462400", "schedule_week": "1", "mode_id": "", "name": ""},
  258. map[string]string{"schedule_type": "2", "schedule_date": "1631462400", "schedule_week": "1", "mode_id": "", "name": ""},
  259. map[string]string{"schedule_type": "3", "schedule_date": "1631462400", "schedule_week": "1", "mode_id": "", "name": ""},
  260. map[string]string{"schedule_type": "1", "schedule_date": "1631548800", "schedule_week": "2", "mode_id": "", "name": ""},
  261. map[string]string{"schedule_type": "2", "schedule_date": "1631548800", "schedule_week": "2", "mode_id": "", "name": ""},
  262. map[string]string{"schedule_type": "3", "schedule_date": "1631548800", "schedule_week": "2", "mode_id": "", "name": ""},
  263. map[string]string{"schedule_type": "1", "schedule_date": "1631635200", "schedule_week": "3", "mode_id": "", "name": ""},
  264. map[string]string{"schedule_type": "2", "schedule_date": "1631635200", "schedule_week": "3", "mode_id": "", "name": ""},
  265. map[string]string{"schedule_type": "3", "schedule_date": "1631635200", "schedule_week": "3", "mode_id": "", "name": ""},
  266. map[string]string{"schedule_type": "1", "schedule_date": "1631721600", "schedule_week": "4", "mode_id": "", "name": ""},
  267. map[string]string{"schedule_type": "2", "schedule_date": "1631721600", "schedule_week": "4", "mode_id": "", "name": ""},
  268. map[string]string{"schedule_type": "3", "schedule_date": "1631721600", "schedule_week": "4", "mode_id": "", "name": ""},
  269. map[string]string{"schedule_type": "1", "schedule_date": "1631808000", "schedule_week": "5", "mode_id": "", "name": ""},
  270. map[string]string{"schedule_type": "2", "schedule_date": "1631808000", "schedule_week": "5", "mode_id": "", "name": ""},
  271. map[string]string{"schedule_type": "3", "schedule_date": "1631808000", "schedule_week": "5", "mode_id": "", "name": ""},
  272. map[string]string{"schedule_type": "1", "schedule_date": "1631894400", "schedule_week": "6", "mode_id": "", "name": ""},
  273. map[string]string{"schedule_type": "2", "schedule_date": "1631894400", "schedule_week": "6", "mode_id": "", "name": ""},
  274. map[string]string{"schedule_type": "3", "schedule_date": "1631894400", "schedule_week": "6", "mode_id": "", "name": ""},
  275. map[string]string{"schedule_type": "1", "schedule_date": "1631980800", "schedule_week": "7", "mode_id": "", "name": ""},
  276. map[string]string{"schedule_type": "2", "schedule_date": "1631980800", "schedule_week": "7", "mode_id": "", "name": ""},
  277. map[string]string{"schedule_type": "3", "schedule_date": "1631980800", "schedule_week": "7", "mode_id": "", "name": ""},
  278. }
  279. this.ServeSuccessJSON(map[string]interface{}{
  280. "list": schedule,
  281. "array": array,
  282. })
  283. }
  284. func (this *XcxApiController) GetMobileSchedule() {
  285. patientID, _ := this.GetInt64("patient_id")
  286. recordDateStr := this.GetString("date")
  287. if patientID <= 0 {
  288. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  289. return
  290. }
  291. if len(recordDateStr) == 0 {
  292. recordDateStr = time.Now().Format("2006-01-02")
  293. }
  294. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  295. if parseDateErr != nil {
  296. this.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  297. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  298. return
  299. }
  300. adminInfo := this.GetMobileAdminUserInfo()
  301. patient, getPatientErr := service.MobileGetPatientDetail(adminInfo.Org.Id, patientID)
  302. if getPatientErr != nil {
  303. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  304. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  305. return
  306. } else if patient == nil {
  307. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  308. return
  309. }
  310. schedual, getSchedualErr := service.MobileGetSchedualDetail(adminInfo.Org.Id, patientID, date.Unix())
  311. if getSchedualErr != nil {
  312. this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
  313. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  314. return
  315. }
  316. receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
  317. if getRTARErr != nil {
  318. this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
  319. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  320. return
  321. }
  322. predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
  323. if getPEErr != nil {
  324. this.ErrorLog("获取透前评估失败:%v", getPEErr)
  325. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
  329. if getLPEErr != nil {
  330. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  331. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  332. return
  333. }
  334. doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
  335. if getDoctorAdvicesErr != nil {
  336. this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
  337. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  338. return
  339. }
  340. dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
  341. if getDialysisOrderErr != nil {
  342. this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
  343. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  344. return
  345. }
  346. doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
  347. if getDoubleCheckErr != nil {
  348. this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
  349. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
  353. if getMonitorRecordsErr != nil {
  354. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  355. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. var lastMonitorRecord *models.MonitoringRecord
  359. lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecord(adminInfo.Org.Id, patientID, date.Unix())
  360. if getLastErr != nil {
  361. this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
  362. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  363. return
  364. }
  365. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
  366. if getAADErr != nil {
  367. this.ErrorLog("获取透后评估失败:%v", getAADErr)
  368. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  369. return
  370. }
  371. lastAssessmentAfterDislysis, getLAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
  372. if getLAADErr != nil {
  373. this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
  374. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  375. return
  376. }
  377. treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
  378. if getTreatmentSummaryErr != nil {
  379. this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
  380. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  381. return
  382. }
  383. dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
  384. dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
  385. lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
  386. //获取系统透析处方模版
  387. systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(adminInfo.Org.Id, schedual.ModeId)
  388. _, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
  389. _, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
  390. projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
  391. stockType, _ := service.GetStockType(adminInfo.Org.Id)
  392. prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
  393. //获取最后一次血管通路
  394. lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
  395. prescribeOne, parseDateErr := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
  396. var his_advices []*models.HisDoctorAdviceInfo
  397. if is_open_config.IsOpen == 1 {
  398. his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
  399. }
  400. if getLPEErr != nil {
  401. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  402. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
  406. if getDryErr != nil {
  407. this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
  408. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. _, gobalConfig := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
  412. operators, _ := service.GetAllStarfEs(adminInfo.Org.Id)
  413. returnData := map[string]interface{}{
  414. "patient": patient,
  415. "schedual": schedual,
  416. "prescription": dialysisPrescribe,
  417. "solution": dialysisSolution,
  418. "last_prescription": lastDialysisPrescribe,
  419. "receiver_treatment_access": receiverTreatmentAccess,
  420. "predialysis_evaluation": predialysisEvaluation,
  421. "doctor_advices": doctorAdvices,
  422. "double_check": doubleCheck,
  423. "assessment_after_dislysis": assessmentAfterDislysis,
  424. "treatment_summary": treatmentSummary,
  425. "monitor_records": monitorRecords,
  426. "dialysis_order": dialysisOrder,
  427. "operators": operators,
  428. "last_predialysis_evaluation": lastPredialysisEvaluation,
  429. "last_assessment_after_dislysis": lastAssessmentAfterDislysis,
  430. "last_monitor_record": lastMonitorRecord,
  431. "config": gobalConfig,
  432. "dry_weight": lastDryWeightDislysis,
  433. "system_prescription": systemDialysisPrescribe,
  434. "his_advices": his_advices,
  435. "is_open_config": is_open_config,
  436. "stockType": stockType,
  437. "prepare": prepare,
  438. "lastAssessment": lastAssessment,
  439. "prescribeOne": prescribeOne,
  440. "is_project_open_config": is_project_open_config,
  441. "project": projects,
  442. }
  443. this.ServeSuccessJSON(returnData)
  444. }