xcx_api_controller.go 43KB

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