xcx_api_controller.go 46KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  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. "strconv"
  12. "time"
  13. )
  14. func XcxApiControllersRegisterRouters() {
  15. ////传送codeinit
  16. beego.Router("/xcx/m/api/code", &XcxApiController{}, "Get:GetCodeInit")
  17. //获取验证码
  18. beego.Router("/xcx/api/mobile/code", &XcxApiController{}, "Get:GetCodeInfo")
  19. //用户绑定
  20. beego.Router("/xcx/api/mobile/register", &XcxApiController{}, "Get:GetUserNameRegister")
  21. //登录
  22. beego.Router("/xcx/api/mobile/login", &XcxApiController{}, "Get:GetLoginInfor")
  23. //获取二维码信息
  24. beego.Router("/xcx/api/mobile/patient", &XcxApiController{}, "Get:GetPatientList")
  25. //获取登录后的信息
  26. beego.Router("/xcx/api/mobile/getdatainfo", &XcxApiController{}, "Get:GetDataInfo")
  27. //获取排班数据
  28. beego.Router("/xcx/api/mobile/schedule", &XcxApiController{}, "Get:GetScheduleInfo")
  29. //获取透析记录
  30. beego.Router("/xcx/api/mobile/dialysis", &XcxApiController{}, "Get:GetMobileSchedule")
  31. //获取患者的电子病历
  32. beego.Router("/xcx/api/mobile/getpatientinfo", &XcxApiController{}, "Get:GetPatientInfo")
  33. //获取机构名称
  34. beego.Router("/xcx/api/mobile/getorginfo", &XcxApiController{}, "Get:GetOrgInfo")
  35. //获取宣教信息
  36. beego.Router("/xcx/api/mobile/geteducation", &XcxApiController{}, "Get:GetEducationList")
  37. //获取医嘱信息
  38. beego.Router("/xcx/api/mobile/getdoctoradvice", &XcxApiController{}, "Get:GetDoctorAdvice")
  39. //获取机构医生护士的姓名
  40. beego.Router("/xcx/api/mobile/getdoctorname", &XcxApiController{}, "Get:GetDoctorName")
  41. //获取显示配置
  42. beego.Router("/xcx/api/moible/getfieldconfig", &XcxApiController{}, "Get:GetFieldConfig")
  43. //获取数据字典数据
  44. beego.Router("/xcx/api/mobile/getdataconfig", &XcxApiController{}, "Get:GetDataConfig")
  45. //检验检查
  46. beego.Router("/xcx/api/mobile/getinspectionlist", &XcxApiController{}, "Get:GetInspectionList")
  47. //肾有杯
  48. beego.Router("/xcx/api/mobile/getarticlist", &XcxApiController{}, "Get:GetArticList")
  49. beego.Router("/xcx/api/mobile/getarticlistdetail", &XcxApiController{}, "Get:GetArticListDetail")
  50. beego.Router("/xcx/api/mobile/getstoryscore", &XcxApiController{}, "Get:GetStoryScoreList")
  51. //获取appid
  52. beego.Router("/xcx/api/mobile/getappid", &XcxApiController{}, "Get:GetAppId")
  53. }
  54. type XcxApiController struct {
  55. mobile_api_controllers.MobileBaseAPIController
  56. }
  57. func (this *XcxApiController) GetCodeInit() {
  58. redisClient := service.RedisClient()
  59. defer redisClient.Close()
  60. req := this.Ctx.Request
  61. addr := utils.GetIP(req)
  62. cur_time := time.Now().Format("2006-01-02")
  63. _, err := redisClient.Get(redisClient.Context(),"ip:host_" + cur_time + "_" + addr).Result()
  64. if err != nil {
  65. redisClient.Set(redisClient.Context(),"ip:host_"+cur_time+"_"+addr, 0, time.Second*24*60*60)
  66. }
  67. //将客户端的ip加密传给前端,作为短信验证的密钥,来验证短信发送的IP地址
  68. aespass := utils.AESEncrypt(addr)
  69. fmt.Println("hhhhhhh3223323232332", aespass)
  70. this.ServeSuccessJSON(map[string]interface{}{
  71. "aespass": aespass,
  72. })
  73. }
  74. func (this *XcxApiController) GetUserNameRegister() {
  75. name := this.GetString("name")
  76. id_card_no := this.GetString("id_card_no")
  77. mobile := this.GetString("mobile")
  78. patient, errcodes := service.GetNamePatient(name, id_card_no)
  79. if errcodes == nil {
  80. role := models.XcxAdminUserRole{
  81. PatientName: name,
  82. IdCardNo: id_card_no,
  83. Mobile: mobile,
  84. Code: "000000",
  85. PatientId: patient.ID,
  86. UserOrgId: patient.UserOrgId,
  87. Status: 1,
  88. Ctime: time.Now().Unix(),
  89. Mtime: 0,
  90. Appid: "",
  91. Appsecret: "",
  92. SessionKey: "",
  93. }
  94. err := service.CreateXcxAdminUser(role)
  95. if err == nil {
  96. mobilePatient, _ := service.GetNamePatient(name, id_card_no)
  97. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  98. //处方
  99. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  100. //接诊评估
  101. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  102. //透前评估
  103. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  104. //透析上机
  105. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  106. //透析监测
  107. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  108. //透后评估
  109. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  110. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  111. var configList interface{}
  112. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  113. this.ServeSuccessJSON(map[string]interface{}{
  114. "role": role,
  115. "is_bind": true,
  116. "patient": mobilePatient,
  117. "template_id": template_id,
  118. "user_org_id": mobilePatient.UserOrgId,
  119. "prescripition_config": prescripition_config,
  120. "receive_treatement_config": receive_treatement_config,
  121. "dialysis_befor": dialysis_befor,
  122. "dialysis_order": dialysis_order,
  123. "monitor_record": monitor_record,
  124. "dialysis_after": dialysis_after,
  125. "treate_ment": treate_ment,
  126. "configList": configList,
  127. "result": false,
  128. })
  129. } else {
  130. this.ServeSuccessJSON(map[string]interface{}{
  131. "is_bind": false,
  132. "msg": "绑定失败",
  133. "result": false,
  134. })
  135. }
  136. } else {
  137. this.ServeSuccessJSON(map[string]interface{}{
  138. "is_bind": false,
  139. "msg": "绑定失败",
  140. "result": false,
  141. })
  142. }
  143. }
  144. func (this *XcxApiController) GetUserRegister() {
  145. //用户绑定
  146. name := this.GetString("name")
  147. id_card_no := this.GetString("id_card_no")
  148. fmt.Println("id_card_no", id_card_no)
  149. mobile := this.GetString("mobile")
  150. code := this.GetString("code")
  151. if len(code) == 0 {
  152. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeVerificationCodeWrong)
  153. return
  154. }
  155. if code == "000000" {
  156. patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
  157. fmt.Println("errcodes2323232232", errcodes)
  158. if errcodes == nil {
  159. role := models.XcxAdminUserRole{
  160. PatientName: name,
  161. IdCardNo: id_card_no,
  162. Mobile: mobile,
  163. Code: code,
  164. PatientId: patient.ID,
  165. UserOrgId: patient.UserOrgId,
  166. Status: 1,
  167. Ctime: time.Now().Unix(),
  168. Mtime: 0,
  169. Appid: "",
  170. Appsecret: "",
  171. SessionKey: "",
  172. }
  173. //查找该电话号码是否存在
  174. _, errcode := service.GetMobilePatientOne(mobile)
  175. if errcode == gorm.ErrRecordNotFound {
  176. err := service.CreateXcxAdminUser(role)
  177. if err == nil {
  178. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  179. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  180. //处方
  181. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  182. //接诊评估
  183. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  184. //透前评估
  185. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  186. //透析上机
  187. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  188. //透析监测
  189. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  190. //透后评估
  191. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  192. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  193. var configList interface{}
  194. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  195. this.ServeSuccessJSON(map[string]interface{}{
  196. "role": role,
  197. "is_bind": true,
  198. "patient": mobilePatient,
  199. "template_id": template_id,
  200. "user_org_id": mobilePatient.UserOrgId,
  201. "prescripition_config": prescripition_config,
  202. "receive_treatement_config": receive_treatement_config,
  203. "dialysis_befor": dialysis_befor,
  204. "dialysis_order": dialysis_order,
  205. "monitor_record": monitor_record,
  206. "dialysis_after": dialysis_after,
  207. "treate_ment": treate_ment,
  208. "configList": configList,
  209. "result": false,
  210. })
  211. } else {
  212. this.ServeSuccessJSON(map[string]interface{}{
  213. "is_bind": false,
  214. "msg": "绑定失败",
  215. "result": false,
  216. })
  217. }
  218. } else if errcode == nil {
  219. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  220. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  221. //处方
  222. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  223. //接诊评估
  224. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  225. //透前评估
  226. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  227. //透析上机
  228. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  229. //透析监测
  230. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  231. //透后评估
  232. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  233. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  234. var configList interface{}
  235. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  236. this.ServeSuccessJSON(map[string]interface{}{
  237. "is_bind": true,
  238. "patient": mobilePatient,
  239. "template_id": template_id,
  240. "user_org_id": mobilePatient.UserOrgId,
  241. "prescripition_config": prescripition_config,
  242. "receive_treatement_config": receive_treatement_config,
  243. "dialysis_befor": dialysis_befor,
  244. "dialysis_order": dialysis_order,
  245. "monitor_record": monitor_record,
  246. "dialysis_after": dialysis_after,
  247. "treate_ment": treate_ment,
  248. "list": configList,
  249. "result": false,
  250. })
  251. }
  252. fmt.Println("roler", role)
  253. } else if errcodes == gorm.ErrRecordNotFound {
  254. this.ServeSuccessJSON(map[string]interface{}{
  255. "is_bind": false,
  256. "result": false,
  257. })
  258. }
  259. this.ServeJSON()
  260. } else {
  261. redisClient := service.RedisClient()
  262. defer redisClient.Close()
  263. cache_code, _ := redisClient.Get(redisClient.Context(),"code_msg_" + mobile).Result()
  264. fmt.Println("cache_code9999999293323232322323", cache_code)
  265. if cache_code != code {
  266. this.ServeSuccessJSON(map[string]interface{}{
  267. "result": false,
  268. })
  269. return
  270. } else {
  271. this.Ctx.SetCookie("mobile", mobile)
  272. // 注册成功后验证码就要使其失效
  273. redisClient.Del(redisClient.Context(),"code_msg_" + mobile)
  274. patient, errcodes := service.GetMobilePatient(mobile, id_card_no)
  275. fmt.Println("errcodes2323232232", errcodes)
  276. if errcodes == nil {
  277. role := models.XcxAdminUserRole{
  278. PatientName: name,
  279. IdCardNo: id_card_no,
  280. Mobile: mobile,
  281. Code: code,
  282. PatientId: patient.ID,
  283. UserOrgId: patient.UserOrgId,
  284. Status: 1,
  285. Ctime: time.Now().Unix(),
  286. Mtime: 0,
  287. Appid: "",
  288. Appsecret: "",
  289. SessionKey: "",
  290. }
  291. //查找该电话号码是否存在
  292. _, errcode := service.GetMobilePatientOne(mobile)
  293. if errcode == gorm.ErrRecordNotFound {
  294. err := service.CreateXcxAdminUser(role)
  295. if err == nil {
  296. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  297. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  298. //处方
  299. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  300. //接诊评估
  301. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  302. //透前评估
  303. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  304. //透析上机
  305. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  306. //透析监测
  307. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  308. //透后评估
  309. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  310. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  311. var configList interface{}
  312. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  313. this.ServeSuccessJSON(map[string]interface{}{
  314. "role": role,
  315. "is_bind": true,
  316. "patient": mobilePatient,
  317. "template_id": template_id,
  318. "user_org_id": mobilePatient.UserOrgId,
  319. "prescripition_config": prescripition_config,
  320. "receive_treatement_config": receive_treatement_config,
  321. "dialysis_befor": dialysis_befor,
  322. "dialysis_order": dialysis_order,
  323. "monitor_record": monitor_record,
  324. "dialysis_after": dialysis_after,
  325. "treate_ment": treate_ment,
  326. "configList": configList,
  327. "result": false,
  328. })
  329. } else {
  330. this.ServeSuccessJSON(map[string]interface{}{
  331. "is_bind": false,
  332. "msg": "绑定失败",
  333. "result": false,
  334. })
  335. }
  336. } else if errcode == nil {
  337. mobilePatient, _ := service.GetMobilePatient(mobile, id_card_no)
  338. template_id, _ := service.GetTemplateMode(mobilePatient.UserOrgId)
  339. //处方
  340. prescripition_config, _ := service.GetPrescripionFieldConfig(mobilePatient.UserOrgId)
  341. //接诊评估
  342. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(mobilePatient.UserOrgId)
  343. //透前评估
  344. dialysis_befor, _ := service.GetDialysisBefor(mobilePatient.UserOrgId)
  345. //透析上机
  346. dialysis_order, _ := service.GetDialysisOrderConfig(mobilePatient.UserOrgId)
  347. //透析监测
  348. monitor_record, _ := service.GetMonitorRecordConfig(mobilePatient.UserOrgId)
  349. //透后评估
  350. dialysis_after, _ := service.GetDialysisAfeterConfig(mobilePatient.UserOrgId)
  351. treate_ment, _ := service.GetTreatMentConfig(mobilePatient.UserOrgId)
  352. var configList interface{}
  353. configList, _ = service.GetConfigList(mobilePatient.UserOrgId)
  354. this.ServeSuccessJSON(map[string]interface{}{
  355. "is_bind": true,
  356. "patient": mobilePatient,
  357. "template_id": template_id,
  358. "user_org_id": mobilePatient.UserOrgId,
  359. "prescripition_config": prescripition_config,
  360. "receive_treatement_config": receive_treatement_config,
  361. "dialysis_befor": dialysis_befor,
  362. "dialysis_order": dialysis_order,
  363. "monitor_record": monitor_record,
  364. "dialysis_after": dialysis_after,
  365. "treate_ment": treate_ment,
  366. "list": configList,
  367. "result": false,
  368. })
  369. }
  370. fmt.Println("roler", role)
  371. } else if errcodes == gorm.ErrRecordNotFound {
  372. this.ServeSuccessJSON(map[string]interface{}{
  373. "is_bind": false,
  374. "result": false,
  375. })
  376. }
  377. this.ServeJSON()
  378. }
  379. }
  380. }
  381. func (this *XcxApiController) GetCodeInfo() {
  382. mobile := this.GetString("phone")
  383. aespass := this.GetString("aespass")
  384. utils.TraceLog("mobile:%v aespass:%v", mobile, aespass)
  385. if utils.CellPhoneRegexp().MatchString(mobile) == false {
  386. this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeMobileFormat)
  387. this.ServeJSON()
  388. return
  389. }
  390. if err := service.SendVerificationCodeSMS(mobile, aespass); err != nil {
  391. this.Data["json"] = enums.MakeFailResponseJSON(err.Error(), 600)
  392. this.ServeJSON()
  393. } else {
  394. this.Data["json"] = enums.MakeSuccessResponseJSON(map[string]interface{}{
  395. "msg": "短信发送成功,有效期为10分钟",
  396. })
  397. this.ServeJSON()
  398. }
  399. this.ServeSuccessJSON(map[string]interface{}{
  400. "code": "100100",
  401. })
  402. }
  403. func (this *XcxApiController) GetLoginInfor() {
  404. mobile := this.GetString("mobile")
  405. fmt.Println(mobile)
  406. user_admin, errcodes := service.GetXcxMobileInformation(mobile)
  407. if errcodes == gorm.ErrRecordNotFound {
  408. info, _ := service.GetMobilePatientInfo(mobile)
  409. template_id, _ := service.GetTemplateMode(info.UserOrgId)
  410. //处方
  411. prescripition_config, _ := service.GetPrescripionFieldConfig(info.UserOrgId)
  412. //接诊评估
  413. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(info.UserOrgId)
  414. //透前评估
  415. dialysis_befor, _ := service.GetDialysisBefor(info.UserOrgId)
  416. //透析上机
  417. dialysis_order, _ := service.GetDialysisOrderConfig(info.UserOrgId)
  418. //透析监测
  419. monitor_record, _ := service.GetMonitorRecordConfig(info.UserOrgId)
  420. //透后评估
  421. dialysis_after, _ := service.GetDialysisAfeterConfig(info.UserOrgId)
  422. treate_ment, _ := service.GetTreatMentConfig(info.UserOrgId)
  423. var configList interface{}
  424. configList, _ = service.GetConfigList(info.UserOrgId)
  425. this.ServeSuccessJSON(map[string]interface{}{
  426. "patient": info,
  427. "template_id": template_id,
  428. "user_org_id": info.UserOrgId,
  429. "prescripition_config": prescripition_config,
  430. "receive_treatement_config": receive_treatement_config,
  431. "dialysis_befor": dialysis_befor,
  432. "dialysis_order": dialysis_order,
  433. "monitor_record": monitor_record,
  434. "dialysis_after": dialysis_after,
  435. "treate_ment": treate_ment,
  436. "role": user_admin,
  437. "is_bind": false,
  438. "list": configList,
  439. })
  440. } else if errcodes == nil {
  441. info, _ := service.GetPatientListByPatientId(user_admin.PatientId)
  442. template_id, _ := service.GetTemplateMode(info.UserOrgId)
  443. //处方
  444. prescripition_config, _ := service.GetPrescripionFieldConfig(info.UserOrgId)
  445. //接诊评估
  446. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(info.UserOrgId)
  447. //透前评估
  448. dialysis_befor, _ := service.GetDialysisBefor(info.UserOrgId)
  449. //透析上机
  450. dialysis_order, _ := service.GetDialysisOrderConfig(info.UserOrgId)
  451. //透析监测
  452. monitor_record, _ := service.GetMonitorRecordConfig(info.UserOrgId)
  453. //透后评估
  454. dialysis_after, _ := service.GetDialysisAfeterConfig(info.UserOrgId)
  455. treate_ment, _ := service.GetTreatMentConfig(info.UserOrgId)
  456. var configList interface{}
  457. configList, _ = service.GetConfigList(info.UserOrgId)
  458. this.ServeSuccessJSON(map[string]interface{}{
  459. "patient": info,
  460. "role": user_admin,
  461. "is_bind": true,
  462. "template_id": template_id,
  463. "user_org_id": info.UserOrgId,
  464. "prescripition_config": prescripition_config,
  465. "receive_treatement_config": receive_treatement_config,
  466. "dialysis_befor": dialysis_befor,
  467. "dialysis_order": dialysis_order,
  468. "monitor_record": monitor_record,
  469. "dialysis_after": dialysis_after,
  470. "treate_ment": treate_ment,
  471. "list": configList,
  472. })
  473. }
  474. }
  475. func (this *XcxApiController) GetPatientList() {
  476. //appid := "wx20b60369111b063a"
  477. appid := "wxcdf53b48b7df107e"
  478. key := "Yz1HgsFX3yJvWPJSEdwJDA=="
  479. strs := "uSevGQ5ShkiHjQuqz7s36SKZisVGA4fHH/dy+etg0W7ibVeidl6TyFS+kQZ6B9AI2T+1kOtKXeyveQR7q2TXJdu3fhKCFoLKVFzICNEvkiHMnchJ0T0OpRO3oT+icYq80+egvT+jMSgP7yi0cAgmiKaK/4QURD7+nvxRAj9drzz77sbeFt8KElb1LN/+Wn8dIoQzisxbON9G1VJYYtyBkQ=="
  480. iv := "JgsbDhJ613uaAgAoBVh0Zw=="
  481. //data, err := service.Dncrypt(strs, key, iv)
  482. //fmt.Println(err)
  483. data, err := service.DecryptData(appid, key, iv, strs)
  484. patient_id, _ := this.GetInt64("patient_id")
  485. patient, err := service.GetPatientListByPatientId(patient_id)
  486. if err == nil {
  487. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  488. return
  489. }
  490. this.ServeSuccessJSON(map[string]interface{}{
  491. "patient": patient,
  492. "data": data,
  493. })
  494. }
  495. func (this *XcxApiController) GetDataInfo() {
  496. appid := this.GetString("appid")
  497. fmt.Println(appid)
  498. key := this.GetString("key")
  499. iv := this.GetString("iv")
  500. encryptedData := this.GetString("encryptedData")
  501. list, _ := service.DecryptData(appid, key, iv, encryptedData)
  502. //list, _ := service.Dncrypt(encryptedData, key, iv)
  503. this.ServeSuccessJSON(map[string]interface{}{
  504. "list": list,
  505. })
  506. }
  507. func (this *XcxApiController) GetScheduleInfo() {
  508. patient_id, _ := this.GetInt64("patient_id")
  509. fmt.Println(patient_id)
  510. thisWeekMonday := service.GetFirstDateOfWeek()
  511. weekDayWeek := service.GetWeekDayOfWeek()
  512. TimeMonday, _ := time.Parse("2006-01-02", thisWeekMonday)
  513. weekDays, _ := time.Parse("2006-01-02", weekDayWeek)
  514. lastWeekMonday := TimeMonday.AddDate(0, 0, -7)
  515. nextWeekMonday := weekDays.AddDate(0, 0, +13)
  516. var weekMonday = lastWeekMonday.Format("2006-01-02")
  517. var weekDay = nextWeekMonday.Format("2006-01-02")
  518. fmt.Println("weekmodonday", weekMonday)
  519. fmt.Println("nextweeekday", weekDay)
  520. timeLayout := "2006-01-02"
  521. loc, _ := time.LoadLocation("Local")
  522. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", weekMonday+" 00:00:00", loc)
  523. fmt.Println("startiem", startTime)
  524. endTime, _ := time.ParseInLocation(timeLayout+"15:04:05", weekDay+"00:00:00", loc)
  525. fmt.Println(startTime.Unix(), endTime.Unix())
  526. schedule, err := service.GetScheduleInfo(startTime.Unix(), endTime.Unix(), patient_id)
  527. //获取当前今日的排班日期
  528. time_now := time.Now().Format("2006-01-02")
  529. fmt.Println("time_now", time_now)
  530. timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
  531. fmt.Println("timeNowUnix", timeNowUnix.Unix())
  532. //获取今日下机日期
  533. order, _ := service.GetTodayDialysis(timeNowUnix.Unix(), patient_id)
  534. //获取今日的处方
  535. prescription, _ := service.GetTodayPrescription(timeNowUnix.Unix(), patient_id)
  536. //获取下一次排班信息
  537. patientSchedule, _ := service.GetNextPatientSchedule(patient_id, timeNowUnix.Unix())
  538. if err != nil {
  539. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  540. return
  541. }
  542. var one = startTime.Unix() + 86400
  543. fmt.Println("one2322332", one)
  544. var two = one + 86400
  545. var three = two + 86400
  546. var four = three + 86400
  547. var five = four + 86400
  548. var six = five + 86400
  549. var seven = six + 86400
  550. var nextOne = seven + 86400
  551. var nexttwo = nextOne + 86400
  552. var nextthree = nexttwo + 86400
  553. var nextfour = nextthree + 86400
  554. var nextfive = nextfour + 86400
  555. var nextsix = nextfive + 86400
  556. var nextseven = nextsix + 86400
  557. var lastOne = nextseven + 86400
  558. var lastwo = lastOne + 86400
  559. var lasthree = lastwo + 86400
  560. var lastfour = lasthree + 86400
  561. var lastfive = lastfour + 86400
  562. var lastsix = lastfive + 86400
  563. var lastseven = lastsix + 86400
  564. fmt.Println("各地好当家232332323232", lastseven)
  565. array := []interface{}{
  566. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  567. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  568. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(one, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  569. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  570. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  571. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(two, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  572. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  573. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  574. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(three, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  575. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  576. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  577. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(four, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  578. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  579. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  580. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(five, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  581. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  582. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  583. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(six, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  584. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  585. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  586. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(seven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  587. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  588. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  589. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  590. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  591. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  592. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nexttwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  593. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  594. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  595. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  596. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  597. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  598. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  599. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  600. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  601. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  602. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  603. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  604. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  605. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  606. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  607. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(nextseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  608. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  609. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  610. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastOne, 10), "schedule_week": "1", "mode_id": "", "name": ""},
  611. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  612. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  613. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastwo, 10), "schedule_week": "2", "mode_id": "", "name": ""},
  614. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  615. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  616. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lasthree, 10), "schedule_week": "3", "mode_id": "", "name": ""},
  617. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  618. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  619. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfour, 10), "schedule_week": "4", "mode_id": "", "name": ""},
  620. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  621. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  622. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastfive, 10), "schedule_week": "5", "mode_id": "", "name": ""},
  623. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  624. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  625. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastsix, 10), "schedule_week": "6", "mode_id": "", "name": ""},
  626. map[string]string{"schedule_type": "1", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  627. map[string]string{"schedule_type": "2", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  628. map[string]string{"schedule_type": "3", "schedule_date": strconv.FormatInt(lastseven, 10), "schedule_week": "7", "mode_id": "", "name": ""},
  629. }
  630. this.ServeSuccessJSON(map[string]interface{}{
  631. "list": schedule,
  632. "array": array,
  633. "order": order,
  634. "patientSchedule": patientSchedule,
  635. "prescription": prescription,
  636. })
  637. }
  638. func (this *XcxApiController) GetMobileSchedule() {
  639. patientID, _ := this.GetInt64("patient_id")
  640. fmt.Println("1", patientID)
  641. info, _ := service.GetXcxPatientInfo(patientID)
  642. timeLayout := "2006-01-02"
  643. loc, _ := time.LoadLocation("Local")
  644. time_now := time.Now().Format("2006-01-02")
  645. timeNowUnix, _ := time.ParseInLocation(timeLayout+"15:04:05", time_now+"00:00:00", loc)
  646. fmt.Println("timeNowUnix", timeNowUnix.Unix())
  647. //获取该患者最后一次排班
  648. list, _ := service.GetLastScheduleListOne(patientID, timeNowUnix.Unix())
  649. fmt.Println("hh2332323232323223", list)
  650. fmt.Println("list233232232332", list.ScheduleDate)
  651. patient, getPatientErr := service.MobileGetPatientDetail(info.UserOrgId, patientID)
  652. if getPatientErr != nil {
  653. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  654. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  655. return
  656. } else if patient == nil {
  657. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  658. return
  659. }
  660. schedual, getSchedualErr := service.MobileGetSchedualDetailOne(info.UserOrgId, patientID)
  661. if getSchedualErr != nil {
  662. this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
  663. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecordOne(info.UserOrgId, patientID, list.ScheduleDate)
  667. if getRTARErr != nil {
  668. this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
  669. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  670. return
  671. }
  672. predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(info.UserOrgId, patientID, list.ScheduleDate)
  673. if getPEErr != nil {
  674. this.ErrorLog("获取透前评估失败:%v", getPEErr)
  675. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  676. return
  677. }
  678. lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluationOne(info.UserOrgId, patientID)
  679. if getLPEErr != nil {
  680. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  681. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  682. return
  683. }
  684. doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvicesByGroupsOne(info.UserOrgId, patientID, list.ScheduleDate)
  685. if getDoctorAdvicesErr != nil {
  686. this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
  687. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  688. return
  689. }
  690. dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecordOne(info.UserOrgId, patientID, list.ScheduleDate)
  691. if getDialysisOrderErr != nil {
  692. this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
  693. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  694. return
  695. }
  696. doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheckOne(info.UserOrgId, patientID, list.ScheduleDate)
  697. if getDoubleCheckErr != nil {
  698. this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
  699. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  700. return
  701. }
  702. monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecordsOne(info.UserOrgId, patientID, list.ScheduleDate)
  703. if getMonitorRecordsErr != nil {
  704. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  705. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  706. return
  707. }
  708. var lastMonitorRecord *models.MonitoringRecord
  709. lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecordOne(info.UserOrgId, patientID)
  710. if getLastErr != nil {
  711. this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
  712. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  713. return
  714. }
  715. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(info.UserOrgId, patientID, list.ScheduleDate)
  716. if getAADErr != nil {
  717. this.ErrorLog("获取透后评估失败:%v", getAADErr)
  718. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  719. return
  720. }
  721. lastAssessmentAfterDislysis, getLAADErr := service.MobileGetAssessmentAfterDislysisOne(info.UserOrgId, patientID, list.ScheduleDate)
  722. if getLAADErr != nil {
  723. this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
  724. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  725. return
  726. }
  727. treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummaryOne(info.UserOrgId, patientID, list.ScheduleDate)
  728. if getTreatmentSummaryErr != nil {
  729. this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
  730. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  731. return
  732. }
  733. dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(info.UserOrgId, patientID, schedual.ModeId)
  734. lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(info.UserOrgId, patientID, schedual.ModeId)
  735. //获取系统透析处方模版
  736. systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(info.UserOrgId, schedual.ModeId)
  737. _, is_open_config := service.FindXTHisRecordByOrgId(info.UserOrgId)
  738. _, is_project_open_config := service.FindXTHisProjectByOrgId(info.UserOrgId)
  739. projects, _ := service.GetHisPrescriptionProjectsOne(info.UserOrgId, patientID)
  740. stockType, _ := service.GetStockType(info.UserOrgId)
  741. prepare, _ := service.GetDialyStockOutOne(info.UserOrgId, patientID)
  742. //获取最后一次血管通路
  743. lastAssessment, _ := service.GetLastPassWayAssessment(info.UserOrgId, patientID)
  744. prescribeOne, _ := service.MobileGetDialysisPrescribeByModeIdFive(info.UserOrgId, patientID, list.ScheduleDate)
  745. var his_advices []*models.HisDoctorAdviceInfo
  746. if is_open_config.IsOpen == 1 {
  747. his_advices, _ = service.GetAllHisDoctorAdviceOne(info.UserOrgId, patientID, list.ScheduleDate)
  748. }
  749. if getLPEErr != nil {
  750. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  751. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. lastDryWeightDislysis, getDryErr := service.MobileGetLastDryWeight(info.UserOrgId, patientID)
  755. if getDryErr != nil {
  756. this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
  757. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. _, gobalConfig := service.FindAutomaticReduceRecordByOrgId(info.UserOrgId)
  761. operators, _ := service.GetAllStarfEs(info.UserOrgId)
  762. returnData := map[string]interface{}{
  763. "patient": patient,
  764. "schedual": schedual,
  765. "prescription": prescribeOne,
  766. "solution": dialysisSolution,
  767. "last_prescription": lastDialysisPrescribe,
  768. "receiver_treatment_access": receiverTreatmentAccess,
  769. "predialysis_evaluation": predialysisEvaluation,
  770. "doctor_advices": doctorAdvices,
  771. "double_check": doubleCheck,
  772. "assessment_after_dislysis": assessmentAfterDislysis,
  773. "treatment_summary": treatmentSummary,
  774. "monitor_records": monitorRecords,
  775. "dialysis_order": dialysisOrder,
  776. "operators": operators,
  777. "last_predialysis_evaluation": lastPredialysisEvaluation,
  778. "last_assessment_after_dislysis": lastAssessmentAfterDislysis,
  779. "last_monitor_record": lastMonitorRecord,
  780. "config": gobalConfig,
  781. "dry_weight": lastDryWeightDislysis,
  782. "system_prescription": systemDialysisPrescribe,
  783. "his_advices": his_advices,
  784. "is_open_config": is_open_config,
  785. "stockType": stockType,
  786. "prepare": prepare,
  787. "lastAssessment": lastAssessment,
  788. "is_project_open_config": is_project_open_config,
  789. "project": projects,
  790. "scheduleDate": list.ScheduleDate,
  791. }
  792. this.ServeSuccessJSON(returnData)
  793. }
  794. func (this *XcxApiController) GetPatientInfo() {
  795. patient_id, _ := this.GetInt64("patient_id")
  796. patient, _ := service.GetXcxPatientInfo(patient_id)
  797. this.ServeSuccessJSON(map[string]interface{}{
  798. "patient": patient,
  799. })
  800. }
  801. func (this *XcxApiController) GetOrgInfo() {
  802. patient_id, _ := this.GetInt64("patient_id")
  803. info, _ := service.GetXcxPatientInfo(patient_id)
  804. orgInfo, _ := service.GetOrgInfo(info.UserOrgId)
  805. this.ServeSuccessJSON(map[string]interface{}{
  806. "orgInfo": orgInfo,
  807. })
  808. }
  809. func (this *XcxApiController) GetEducationList() {
  810. start_time := this.GetString("start_time")
  811. end_time := this.GetString("end_time")
  812. patient_id, _ := this.GetInt64("patient_id")
  813. timeLayout := "2006-01-02"
  814. loc, _ := time.LoadLocation("Local")
  815. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  816. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  817. list, _ := service.GetEducationList(startTime.Unix(), endTime.Unix(), patient_id)
  818. this.ServeSuccessJSON(map[string]interface{}{
  819. "list": list,
  820. })
  821. }
  822. func (this *XcxApiController) GetDoctorAdvice() {
  823. //判断是否开启医嘱同步功能
  824. start_time := this.GetString("start_time")
  825. end_time := this.GetString("end_time")
  826. patient_id, _ := this.GetInt64("patient_id")
  827. fmt.Println("patient_id", patient_id)
  828. timeLayout := "2006-01-02"
  829. loc, _ := time.LoadLocation("Local")
  830. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  831. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  832. info, _ := service.GetXcxPatientInfo(patient_id)
  833. config, _ := service.GetDoctorAdviceConfig(info.UserOrgId)
  834. fmt.Println(startTime, endTime, config.IsOpenRemind)
  835. if config.IsOpenRemind == 0 || config.IsOpenRemind == 2 {
  836. list, _ := service.GetDoctorAdviceGroup(patient_id, startTime.Unix(), endTime.Unix())
  837. advice, _ := service.GetDoctorAdvice(patient_id, startTime.Unix(), endTime.Unix())
  838. for _, item := range list {
  839. for _, it := range advice {
  840. if item.AdviceDate == it.AdviceDate {
  841. item.Childs = append(item.Childs, it)
  842. }
  843. }
  844. }
  845. this.ServeSuccessJSON(map[string]interface{}{
  846. "list": list,
  847. })
  848. }
  849. if config.IsOpenRemind == 1 {
  850. list, _ := service.GetHisDoctorAdviceGroup(patient_id, startTime.Unix(), endTime.Unix())
  851. advice, _ := service.GetHisDoctorAdvice(patient_id, startTime.Unix(), endTime.Unix())
  852. for _, item := range list {
  853. for _, it := range advice {
  854. if item.AdviceDate == it.AdviceDate {
  855. item.Childs = append(item.Childs, it)
  856. }
  857. }
  858. }
  859. this.ServeSuccessJSON(map[string]interface{}{
  860. "list": list,
  861. })
  862. }
  863. }
  864. func (this *XcxApiController) GetDoctorName() {
  865. patient_id, _ := this.GetInt64("patient_id")
  866. fmt.Println("patient_id", patient_id)
  867. info, _ := service.GetXcxPatientInfo(patient_id)
  868. user_name, _ := service.GetDoctorName(info.UserOrgId)
  869. this.ServeSuccessJSON(map[string]interface{}{
  870. "user_name": user_name,
  871. })
  872. }
  873. func (this *XcxApiController) GetFieldConfig() {
  874. patient_id, _ := this.GetInt64("patient_id")
  875. fmt.Println("patient_id", patient_id)
  876. info, _ := service.GetXcxPatientInfo(patient_id)
  877. //处方
  878. prescripition_config, _ := service.GetPrescripionFieldConfig(info.UserOrgId)
  879. //接诊评估
  880. receive_treatement_config, _ := service.GetReceiveTreatmentAssess(info.UserOrgId)
  881. //透前评估
  882. dialysis_befor, _ := service.GetDialysisBefor(info.UserOrgId)
  883. //透析上机
  884. dialysis_order, _ := service.GetDialysisOrderConfig(info.UserOrgId)
  885. //透析监测
  886. monitor_record, _ := service.GetMonitorRecordConfig(info.UserOrgId)
  887. //透后评估
  888. dialysis_after, _ := service.GetDialysisAfeterConfig(info.UserOrgId)
  889. treate_ment, _ := service.GetTreatMentConfig(info.UserOrgId)
  890. this.ServeSuccessJSON(map[string]interface{}{
  891. "prescripition_config": prescripition_config,
  892. "receive_treatement_config": receive_treatement_config,
  893. "dialysis_befor": dialysis_befor,
  894. "dialysis_order": dialysis_order,
  895. "monitor_record": monitor_record,
  896. "dialysis_after": dialysis_after,
  897. "treate_ment": treate_ment,
  898. })
  899. }
  900. func (this *XcxApiController) GetDataConfig() {
  901. var configList interface{}
  902. patient_id, _ := this.GetInt64("patient_id")
  903. fmt.Println("patient_id", patient_id)
  904. info, _ := service.GetXcxPatientInfo(patient_id)
  905. //list, _ := service.GetDataConfig(info.UserOrgId)
  906. configList, _ = service.GetConfigList(info.UserOrgId)
  907. this.ServeSuccessJSON(map[string]interface{}{
  908. "list": configList,
  909. })
  910. }
  911. func (this *XcxApiController) GetInspectionList() {
  912. start_time := this.GetString("start_time")
  913. end_time := this.GetString("end_time")
  914. patient_id, _ := this.GetInt64("patient_id")
  915. fmt.Println("patient_id", patient_id)
  916. timeLayout := "2006-01-02"
  917. loc, _ := time.LoadLocation("Local")
  918. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  919. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  920. list, _ := service.GetInspectionGroupList(patient_id, startTime.Unix(), endTime.Unix())
  921. insepctionList, _ := service.GetInsepctionList(patient_id, startTime.Unix(), endTime.Unix())
  922. for _, item := range list {
  923. for _, it := range insepctionList {
  924. if item.ProjectId == it.ProjectId && item.InspectDate == it.InspectDate {
  925. item.Childs = append(item.Childs, it)
  926. }
  927. }
  928. }
  929. this.ServeSuccessJSON(map[string]interface{}{
  930. "list": list,
  931. })
  932. }
  933. func (this *XcxApiController) GetArticList() {
  934. page, _ := this.GetInt64("page")
  935. limit, _ := this.GetInt64("limit")
  936. activity_id, _ := this.GetInt64("activity_id")
  937. list, total, _ := service.GetArticList(activity_id, page, limit)
  938. this.ServeSuccessJSON(map[string]interface{}{
  939. "list": list,
  940. "total": total,
  941. })
  942. }
  943. func (this *XcxApiController) GetArticListDetail() {
  944. id, _ := this.GetInt64("id")
  945. detail, _ := service.GetArticListDetail(id)
  946. this.ServeSuccessJSON(map[string]interface{}{
  947. "story": detail,
  948. })
  949. }
  950. func (this *XcxApiController) GetStoryScoreList() {
  951. page, _ := this.GetInt64("page")
  952. limit, _ := this.GetInt64("limit")
  953. activity_id, _ := this.GetInt64("activity_id")
  954. list, total, _ := service.GetStoryScoreList(activity_id, page, limit)
  955. this.ServeSuccessJSON(map[string]interface{}{
  956. "list": list,
  957. "total": total,
  958. })
  959. }
  960. func (this *XcxApiController) GetAppId() {
  961. var appid = "wxcdf53b48b7df107e"
  962. var secret = "94e944a69ad1d43ac447f5a8769ab801"
  963. var grant_type = "authorization_code"
  964. code := this.GetString("js_code")
  965. //var code = "041pXnGa1eLxTB0iypFa1W6USs1pXnGK"
  966. openId, _ := service.SendWxAuthAPI(appid, secret, grant_type, code)
  967. //session_key, _ := service.SendWxAuthAPIOne(appid, secret, grant_type, code)
  968. this.ServeSuccessJSON(map[string]interface{}{
  969. "data": openId,
  970. //"session_key": session_key,
  971. })
  972. }