qcd_api_controller.go 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. package controllers
  2. import (
  3. "Xcx_New/enums"
  4. "Xcx_New/service"
  5. "Xcx_New/utils"
  6. "time"
  7. "github.com/astaxie/beego"
  8. )
  9. type QcdApiController struct {
  10. BaseAuthAPIController
  11. }
  12. func QcdApiRegistRouters() {
  13. beego.Router("/api/qcd/dialysistotaldata", &QcdApiController{}, "get:GetDialysisTotalData")
  14. beego.Router("/api/qcd/processindicatorsdata", &QcdApiController{}, "get:GetProcessIndicatorsData")
  15. beego.Router("/api/qcd/oicdata", &QcdApiController{}, "get:GetOICData")
  16. beego.Router("/api/qcd/oiqdata", &QcdApiController{}, "get:GetOIQData")
  17. beego.Router("/api/qcd/patotaldata", &QcdApiController{}, "get:GetPATotalData")
  18. beego.Router("/api/qcd/padialysisagedata", &QcdApiController{}, "get:GetPADialysisAgeData")
  19. beego.Router("/api/qcd/paweightdata", &QcdApiController{}, "get:GetPAWeightData")
  20. beego.Router("/api/qcd/pabloodpressuredata", &QcdApiController{}, "get:GetPABloodPressureData")
  21. beego.Router("/api/qcd/pacomplicationdata", &QcdApiController{}, "get:GetPAComplicationData")
  22. beego.Router("/api/qcd/painfectiousdiseasesdata", &QcdApiController{}, "get:GetPAInfectiousDiseasesData")
  23. beego.Router("/api/qcd/papersonlapsetdata", &QcdApiController{}, "get:GetPersonLapsetoData")
  24. beego.Router("/api/qcd/papersonweightdata", &QcdApiController{}, "get:GetPersonWeightData")
  25. beego.Router("/api/qcd/papersonbloodpressuredata", &QcdApiController{}, "get:GetPersonBloodPressureData")
  26. beego.Router("/api/qcd/papersonicdata", &QcdApiController{}, "get:GetPersonICData")
  27. beego.Router("/api/qcd/papersonadvicedata", &QcdApiController{}, "get:GetPersonAdviceData")
  28. }
  29. func (c *QcdApiController) GetDialysisTotalData() {
  30. page, _ := c.GetInt64("page", 1)
  31. limit, _ := c.GetInt64("limit", 10)
  32. lapseto, _ := c.GetInt64("lapseto", 0)
  33. statisticalMethod, _ := c.GetInt64("statistical_method", 0)
  34. modeID, _ := c.GetInt64("mode_id", 0)
  35. startTime := c.GetString("start_time", "")
  36. endTime := c.GetString("end_time", "")
  37. if page <= 0 {
  38. page = 1
  39. }
  40. if limit <= 0 {
  41. limit = 10
  42. }
  43. adminUserInfo := c.GetAdminUserInfo()
  44. timeLayout := "2006-01-02"
  45. loc, _ := time.LoadLocation("Local")
  46. var isStartTime bool
  47. var theStartTIme int64
  48. if len(startTime) > 0 {
  49. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  50. if err != nil {
  51. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  52. return
  53. }
  54. isStartTime = true
  55. theStartTIme = theTime.Unix()
  56. }
  57. var isEndTime bool
  58. var theEndtTIme int64
  59. if len(endTime) > 0 {
  60. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  61. if err != nil {
  62. utils.ErrorLog(err.Error())
  63. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  64. return
  65. }
  66. isEndTime = true
  67. theEndtTIme = theTime.Unix()
  68. }
  69. data, ttd, total, _ := service.GetDialysisTotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, statisticalMethod, modeID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  70. c.ServeSuccessJSON(map[string]interface{}{
  71. "dtd": data,
  72. "ttd": ttd,
  73. "total": total,
  74. })
  75. return
  76. }
  77. func (c *QcdApiController) GetProcessIndicatorsData() {
  78. page, _ := c.GetInt64("page", 1)
  79. limit, _ := c.GetInt64("limit", 10)
  80. lapseto, _ := c.GetInt64("lapseto", 0)
  81. dialysisAge, _ := c.GetInt64("dialysis_age", 0)
  82. projectID, _ := c.GetInt64("project_id", 0)
  83. startTime := c.GetString("start_time", "")
  84. endTime := c.GetString("end_time", "")
  85. if page <= 0 {
  86. page = 1
  87. }
  88. if limit <= 0 {
  89. limit = 10
  90. }
  91. adminUserInfo := c.GetAdminUserInfo()
  92. timeLayout := "2006-01-02"
  93. loc, _ := time.LoadLocation("Local")
  94. var isStartTime bool
  95. var theStartTIme int64
  96. if len(startTime) > 0 {
  97. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  98. if err != nil {
  99. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  100. return
  101. }
  102. isStartTime = true
  103. theStartTIme = theTime.Unix()
  104. }
  105. var isEndTime bool
  106. var theEndtTIme int64
  107. if len(endTime) > 0 {
  108. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  109. if err != nil {
  110. utils.ErrorLog(err.Error())
  111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  112. return
  113. }
  114. isEndTime = true
  115. theEndtTIme = theTime.Unix()
  116. }
  117. inspections, references, patients, counts, total, err := service.GetProcessIndicatorsData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  118. if err != nil {
  119. utils.ErrorLog(err.Error())
  120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  121. return
  122. }
  123. c.ServeSuccessJSON(map[string]interface{}{
  124. "inspections": inspections,
  125. "references": references,
  126. "patients": patients,
  127. "unfinishedcount": counts[0].Count,
  128. "total": total,
  129. })
  130. return
  131. }
  132. func (c *QcdApiController) GetOICData() {
  133. page, _ := c.GetInt64("page", 1)
  134. limit, _ := c.GetInt64("limit", 10)
  135. lapseto, _ := c.GetInt64("lapseto", 0)
  136. dialysisAge, _ := c.GetInt64("dialysis_age", 0)
  137. projectID, _ := c.GetInt64("project_id", 0)
  138. itemID, _ := c.GetInt64("item_id", 0)
  139. startTime := c.GetString("start_time", "")
  140. endTime := c.GetString("end_time", "")
  141. if page <= 0 {
  142. page = 1
  143. }
  144. if limit <= 0 {
  145. limit = 10
  146. }
  147. adminUserInfo := c.GetAdminUserInfo()
  148. timeLayout := "2006-01-02"
  149. loc, _ := time.LoadLocation("Local")
  150. var isStartTime bool
  151. var theStartTIme int64
  152. if len(startTime) > 0 {
  153. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  154. if err != nil {
  155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  156. return
  157. }
  158. isStartTime = true
  159. theStartTIme = theTime.Unix()
  160. }
  161. var isEndTime bool
  162. var theEndtTIme int64
  163. if len(endTime) > 0 {
  164. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  165. if err != nil {
  166. utils.ErrorLog(err.Error())
  167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  168. return
  169. }
  170. isEndTime = true
  171. theEndtTIme = theTime.Unix()
  172. }
  173. inspections, references, patients, counts, total, err := service.GetOICData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, itemID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  174. if err != nil {
  175. utils.ErrorLog(err.Error())
  176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  177. return
  178. }
  179. c.ServeSuccessJSON(map[string]interface{}{
  180. "inspections": inspections,
  181. "references": references,
  182. "patients": patients,
  183. "unfinishedcount": counts[0].Count,
  184. "total": total,
  185. })
  186. return
  187. }
  188. func (c *QcdApiController) GetOIQData() {
  189. page, _ := c.GetInt64("page", 1)
  190. limit, _ := c.GetInt64("limit", 10)
  191. projectID, _ := c.GetInt64("project_id", 0)
  192. startTime := c.GetString("start_time", "")
  193. endTime := c.GetString("end_time", "")
  194. searchKey := c.GetString("search", "")
  195. if page <= 0 {
  196. page = 1
  197. }
  198. if limit <= 0 {
  199. limit = 10
  200. }
  201. adminUserInfo := c.GetAdminUserInfo()
  202. timeLayout := "2006-01-02"
  203. loc, _ := time.LoadLocation("Local")
  204. var isStartTime bool
  205. var theStartTIme int64
  206. if len(startTime) > 0 {
  207. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  208. if err != nil {
  209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  210. return
  211. }
  212. isStartTime = true
  213. theStartTIme = theTime.Unix()
  214. }
  215. var isEndTime bool
  216. var theEndtTIme int64
  217. if len(endTime) > 0 {
  218. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  219. if err != nil {
  220. utils.ErrorLog(err.Error())
  221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  222. return
  223. }
  224. isEndTime = true
  225. theEndtTIme = theTime.Unix()
  226. }
  227. inspections, references, patients, total, err := service.GetOIQData(adminUserInfo.CurrentOrgId, page, limit, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
  228. if err != nil {
  229. utils.ErrorLog(err.Error())
  230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  231. return
  232. }
  233. c.ServeSuccessJSON(map[string]interface{}{
  234. "inspections": inspections,
  235. "references": references,
  236. "patients": patients,
  237. "total": total,
  238. })
  239. return
  240. }
  241. func (c *QcdApiController) GetPATotalData() {
  242. page, _ := c.GetInt64("page", 1)
  243. limit, _ := c.GetInt64("limit", 10)
  244. startTime := c.GetString("start_time", "")
  245. endTime := c.GetString("end_time", "")
  246. searchKey := c.GetString("search", "")
  247. age, _ := c.GetInt64("age", 0)
  248. lapseto, _ := c.GetInt64("lapseto", 0)
  249. source, _ := c.GetInt64("source", 0)
  250. if page <= 0 {
  251. page = 1
  252. }
  253. if limit <= 0 {
  254. limit = 10
  255. }
  256. adminUserInfo := c.GetAdminUserInfo()
  257. timeLayout := "2006-01-02"
  258. loc, _ := time.LoadLocation("Local")
  259. var isStartTime bool
  260. var theStartTIme int64
  261. if len(startTime) > 0 {
  262. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  263. if err != nil {
  264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  265. return
  266. }
  267. isStartTime = true
  268. theStartTIme = theTime.Unix()
  269. }
  270. var isEndTime bool
  271. var theEndtTIme int64
  272. if len(endTime) > 0 {
  273. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  274. if err != nil {
  275. utils.ErrorLog(err.Error())
  276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  277. return
  278. }
  279. isEndTime = true
  280. theEndtTIme = theTime.Unix()
  281. }
  282. patients, lapsetoOut, lapsetoIn, total, err := service.GetPATotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, source, age, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
  283. if err != nil {
  284. utils.ErrorLog(err.Error())
  285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  286. return
  287. }
  288. c.ServeSuccessJSON(map[string]interface{}{
  289. "patients": patients,
  290. "total": total,
  291. "lapsetoOut": lapsetoOut,
  292. "lapsetoIn": lapsetoIn,
  293. })
  294. return
  295. }
  296. func (c *QcdApiController) GetPADialysisAgeData() {
  297. page, _ := c.GetInt64("page", 1)
  298. limit, _ := c.GetInt64("limit", 10)
  299. startTime := c.GetString("start_time", "")
  300. endTime := c.GetString("end_time", "")
  301. age, _ := c.GetInt64("age", 0)
  302. dialysisAge, _ := c.GetInt64("dialysis_age", 0)
  303. lapseto, _ := c.GetInt64("lapseto", 0)
  304. if page <= 0 {
  305. page = 1
  306. }
  307. if limit <= 0 {
  308. limit = 10
  309. }
  310. adminUserInfo := c.GetAdminUserInfo()
  311. timeLayout := "2006-01-02"
  312. loc, _ := time.LoadLocation("Local")
  313. var isStartTime bool
  314. var theStartTIme int64
  315. if len(startTime) > 0 {
  316. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  317. if err != nil {
  318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  319. return
  320. }
  321. isStartTime = true
  322. theStartTIme = theTime.Unix()
  323. }
  324. var isEndTime bool
  325. var theEndtTIme int64
  326. if len(endTime) > 0 {
  327. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  328. if err != nil {
  329. utils.ErrorLog(err.Error())
  330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  331. return
  332. }
  333. isEndTime = true
  334. theEndtTIme = theTime.Unix()
  335. }
  336. patients, counts, total, err := service.GetPADialysisAgeData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, dialysisAge, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  337. if err != nil {
  338. utils.ErrorLog(err.Error())
  339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  340. return
  341. }
  342. c.ServeSuccessJSON(map[string]interface{}{
  343. "patients": patients,
  344. "counts": counts,
  345. "total": total,
  346. })
  347. return
  348. }
  349. func (c *QcdApiController) GetPAWeightData() {
  350. page, _ := c.GetInt64("page", 1)
  351. limit, _ := c.GetInt64("limit", 10)
  352. startTime := c.GetString("start_time", "")
  353. endTime := c.GetString("end_time", "")
  354. age, _ := c.GetInt64("age", 0)
  355. lapseto, _ := c.GetInt64("lapseto", 0)
  356. if page <= 0 {
  357. page = 1
  358. }
  359. if limit <= 0 {
  360. limit = 10
  361. }
  362. adminUserInfo := c.GetAdminUserInfo()
  363. timeLayout := "2006-01-02"
  364. loc, _ := time.LoadLocation("Local")
  365. var isStartTime bool
  366. var theStartTIme int64
  367. if len(startTime) > 0 {
  368. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  369. if err != nil {
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  371. return
  372. }
  373. isStartTime = true
  374. theStartTIme = theTime.Unix()
  375. }
  376. var isEndTime bool
  377. var theEndtTIme int64
  378. if len(endTime) > 0 {
  379. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  380. if err != nil {
  381. utils.ErrorLog(err.Error())
  382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  383. return
  384. }
  385. isEndTime = true
  386. theEndtTIme = theTime.Unix()
  387. }
  388. weights, dryweight, weightincrease, afterweight, total, err := service.GetPAWeightData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  389. if err != nil {
  390. utils.ErrorLog(err.Error())
  391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  392. return
  393. }
  394. c.ServeSuccessJSON(map[string]interface{}{
  395. "weights": weights,
  396. "dryweight": dryweight,
  397. "weightincrease": weightincrease,
  398. "afterweight": afterweight,
  399. "total": total,
  400. })
  401. return
  402. }
  403. func (c *QcdApiController) GetPABloodPressureData() {
  404. page, _ := c.GetInt64("page", 1)
  405. limit, _ := c.GetInt64("limit", 10)
  406. startTime := c.GetString("start_time", "")
  407. endTime := c.GetString("end_time", "")
  408. lapseto, _ := c.GetInt64("lapseto", 0)
  409. dialysisStage, _ := c.GetInt64("dialysis_stage", 0)
  410. if page <= 0 {
  411. page = 1
  412. }
  413. if limit <= 0 {
  414. limit = 10
  415. }
  416. adminUserInfo := c.GetAdminUserInfo()
  417. timeLayout := "2006-01-02"
  418. loc, _ := time.LoadLocation("Local")
  419. var isStartTime bool
  420. var theStartTIme int64
  421. if len(startTime) > 0 {
  422. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  423. if err != nil {
  424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  425. return
  426. }
  427. isStartTime = true
  428. theStartTIme = theTime.Unix()
  429. }
  430. var isEndTime bool
  431. var theEndtTIme int64
  432. if len(endTime) > 0 {
  433. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  434. if err != nil {
  435. utils.ErrorLog(err.Error())
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  437. return
  438. }
  439. isEndTime = true
  440. theEndtTIme = theTime.Unix()
  441. }
  442. bloodPressures, bps, total, err := service.GetPABloodPressureData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisStage, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  443. if err != nil {
  444. utils.ErrorLog(err.Error())
  445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  446. return
  447. }
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "blood_pressures": bloodPressures,
  450. "bps": bps,
  451. "total": total,
  452. })
  453. return
  454. }
  455. func (c *QcdApiController) GetPAComplicationData() {
  456. page, _ := c.GetInt64("page", 1)
  457. limit, _ := c.GetInt64("limit", 10)
  458. startTime := c.GetString("start_time", "")
  459. endTime := c.GetString("end_time", "")
  460. age, _ := c.GetInt64("age", 0)
  461. statisticalState, _ := c.GetInt64("statistical_state", 0)
  462. if page <= 0 {
  463. page = 1
  464. }
  465. if limit <= 0 {
  466. limit = 10
  467. }
  468. adminUserInfo := c.GetAdminUserInfo()
  469. timeLayout := "2006-01-02"
  470. loc, _ := time.LoadLocation("Local")
  471. var isStartTime bool
  472. var theStartTIme int64
  473. if len(startTime) > 0 {
  474. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  475. if err != nil {
  476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  477. return
  478. }
  479. isStartTime = true
  480. theStartTIme = theTime.Unix()
  481. }
  482. var isEndTime bool
  483. var theEndtTIme int64
  484. if len(endTime) > 0 {
  485. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  486. if err != nil {
  487. utils.ErrorLog(err.Error())
  488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  489. return
  490. }
  491. isEndTime = true
  492. theEndtTIme = theTime.Unix()
  493. }
  494. complications, pcps, total, err := service.GetPAComplicationData(adminUserInfo.CurrentOrgId, page, limit, age, statisticalState, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  495. if err != nil {
  496. utils.ErrorLog(err.Error())
  497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  498. return
  499. }
  500. c.ServeSuccessJSON(map[string]interface{}{
  501. "complications": complications,
  502. "pcps": pcps,
  503. "total": total,
  504. })
  505. return
  506. }
  507. func (c *QcdApiController) GetPAInfectiousDiseasesData() {
  508. page, _ := c.GetInt64("page", 1)
  509. limit, _ := c.GetInt64("limit", 10)
  510. startTime := c.GetString("start_time", "")
  511. endTime := c.GetString("end_time", "")
  512. age, _ := c.GetInt64("age", 0)
  513. contagionType, _ := c.GetInt64("contagion_type", 0)
  514. lapseto, _ := c.GetInt64("lapseto", 0)
  515. if page <= 0 {
  516. page = 1
  517. }
  518. if limit <= 0 {
  519. limit = 10
  520. }
  521. adminUserInfo := c.GetAdminUserInfo()
  522. timeLayout := "2006-01-02"
  523. loc, _ := time.LoadLocation("Local")
  524. var isStartTime bool
  525. var theStartTIme int64
  526. if len(startTime) > 0 {
  527. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  528. if err != nil {
  529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  530. return
  531. }
  532. isStartTime = true
  533. theStartTIme = theTime.Unix()
  534. }
  535. var isEndTime bool
  536. var theEndtTIme int64
  537. if len(endTime) > 0 {
  538. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  539. if err != nil {
  540. utils.ErrorLog(err.Error())
  541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  542. return
  543. }
  544. isEndTime = true
  545. theEndtTIme = theTime.Unix()
  546. }
  547. patients, dsp, total, err := service.GetPAInfectiousDiseasesData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, contagionType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  548. if err != nil {
  549. utils.ErrorLog(err.Error())
  550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  551. return
  552. }
  553. c.ServeSuccessJSON(map[string]interface{}{
  554. "patients": patients,
  555. "dsp": dsp,
  556. "total": total,
  557. })
  558. return
  559. }
  560. func (c *QcdApiController) GetPersonLapsetoData() {
  561. page, _ := c.GetInt64("page", 1)
  562. limit, _ := c.GetInt64("limit", 10)
  563. patientId, _ := c.GetInt64("patient_id", 0)
  564. if page <= 0 {
  565. page = 1
  566. }
  567. if limit <= 0 {
  568. limit = 10
  569. }
  570. adminUserInfo := c.GetAdminUserInfo()
  571. patient, lapsetos, total, err := service.GetPersonLapsetoData(adminUserInfo.CurrentOrgId, patientId, page, limit)
  572. if err != nil {
  573. utils.ErrorLog(err.Error())
  574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  575. return
  576. }
  577. c.ServeSuccessJSON(map[string]interface{}{
  578. "patient": patient,
  579. "lapsetos": lapsetos,
  580. "total": total,
  581. })
  582. return
  583. }
  584. func (c *QcdApiController) GetPersonWeightData() {
  585. page, _ := c.GetInt64("page", 1)
  586. limit, _ := c.GetInt64("limit", 10)
  587. patientId, _ := c.GetInt64("patient_id", 0)
  588. startTime := c.GetString("start_time", "")
  589. endTime := c.GetString("end_time", "")
  590. if page <= 0 {
  591. page = 1
  592. }
  593. if limit <= 0 {
  594. limit = 10
  595. }
  596. var isStartTime bool
  597. var theStartTIme int64
  598. timeLayout := "2006-01-02"
  599. loc, _ := time.LoadLocation("Local")
  600. if len(startTime) > 0 {
  601. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  602. if err != nil {
  603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  604. return
  605. }
  606. isStartTime = true
  607. theStartTIme = theTime.Unix()
  608. }
  609. var isEndTime bool
  610. var theEndtTIme int64
  611. if len(endTime) > 0 {
  612. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  613. if err != nil {
  614. utils.ErrorLog(err.Error())
  615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  616. return
  617. }
  618. isEndTime = true
  619. theEndtTIme = theTime.Unix()
  620. }
  621. adminUserInfo := c.GetAdminUserInfo()
  622. patient, weight, pie, total, err := service.GetPersonWeightData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  623. if err != nil {
  624. utils.ErrorLog(err.Error())
  625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  626. return
  627. }
  628. c.ServeSuccessJSON(map[string]interface{}{
  629. "patient": patient,
  630. "weight": weight,
  631. "pie": pie,
  632. "total": total,
  633. })
  634. return
  635. }
  636. func (c *QcdApiController) GetPersonBloodPressureData() {
  637. page, _ := c.GetInt64("page", 1)
  638. limit, _ := c.GetInt64("limit", 10)
  639. patientId, _ := c.GetInt64("patient_id", 0)
  640. startTime := c.GetString("start_time", "")
  641. endTime := c.GetString("end_time", "")
  642. if page <= 0 {
  643. page = 1
  644. }
  645. if limit <= 0 {
  646. limit = 10
  647. }
  648. var isStartTime bool
  649. var theStartTIme int64
  650. timeLayout := "2006-01-02"
  651. loc, _ := time.LoadLocation("Local")
  652. if len(startTime) > 0 {
  653. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  654. if err != nil {
  655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  656. return
  657. }
  658. isStartTime = true
  659. theStartTIme = theTime.Unix()
  660. }
  661. var isEndTime bool
  662. var theEndtTIme int64
  663. if len(endTime) > 0 {
  664. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  665. if err != nil {
  666. utils.ErrorLog(err.Error())
  667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  668. return
  669. }
  670. isEndTime = true
  671. theEndtTIme = theTime.Unix()
  672. }
  673. adminUserInfo := c.GetAdminUserInfo()
  674. patient, bps, lines, total, err := service.GetPersonBloodPressureData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  675. if err != nil {
  676. utils.ErrorLog(err.Error())
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  678. return
  679. }
  680. c.ServeSuccessJSON(map[string]interface{}{
  681. "patient": patient,
  682. "bps": bps,
  683. "lines": lines,
  684. "total": total,
  685. })
  686. return
  687. }
  688. func (c *QcdApiController) GetPersonICData() {
  689. page, _ := c.GetInt64("page", 1)
  690. limit, _ := c.GetInt64("limit", 10)
  691. patientId, _ := c.GetInt64("patient_id", 0)
  692. if page <= 0 {
  693. page = 1
  694. }
  695. if limit <= 0 {
  696. limit = 10
  697. }
  698. adminUserInfo := c.GetAdminUserInfo()
  699. patient, inspections, references, total, err := service.GetPersonICData(adminUserInfo.CurrentOrgId, patientId, page, limit)
  700. if err != nil {
  701. utils.ErrorLog(err.Error())
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  703. return
  704. }
  705. c.ServeSuccessJSON(map[string]interface{}{
  706. "patient": patient,
  707. "inspections": inspections,
  708. "references": references,
  709. "total": total,
  710. })
  711. return
  712. }
  713. func (c *QcdApiController) GetPersonAdviceData() {
  714. page, _ := c.GetInt64("page", 1)
  715. limit, _ := c.GetInt64("limit", 10)
  716. patientId, _ := c.GetInt64("patient_id", 0)
  717. adviceType, _ := c.GetInt64("advice_type", 0)
  718. medicalType, _ := c.GetInt64("medical_type", 0)
  719. startTime := c.GetString("start_time", "")
  720. endTime := c.GetString("end_time", "")
  721. if page <= 0 {
  722. page = 1
  723. }
  724. if limit <= 0 {
  725. limit = 10
  726. }
  727. var isStartTime bool
  728. var theStartTIme int64
  729. timeLayout := "2006-01-02"
  730. loc, _ := time.LoadLocation("Local")
  731. if len(startTime) > 0 {
  732. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  733. if err != nil {
  734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  735. return
  736. }
  737. isStartTime = true
  738. theStartTIme = theTime.Unix()
  739. }
  740. var isEndTime bool
  741. var theEndtTIme int64
  742. if len(endTime) > 0 {
  743. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  744. if err != nil {
  745. utils.ErrorLog(err.Error())
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  747. return
  748. }
  749. isEndTime = true
  750. theEndtTIme = theTime.Unix()
  751. }
  752. adminUserInfo := c.GetAdminUserInfo()
  753. patient, advices, total, err := service.GetPersonAdviceData(adminUserInfo.CurrentOrgId, patientId, page, limit, adviceType, medicalType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
  754. if err != nil {
  755. utils.ErrorLog(err.Error())
  756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  757. return
  758. }
  759. users, err := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  760. if err != nil {
  761. utils.ErrorLog(err.Error())
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  763. return
  764. }
  765. c.ServeSuccessJSON(map[string]interface{}{
  766. "patient": patient,
  767. "advices": advices,
  768. "users": users,
  769. "total": total,
  770. })
  771. return
  772. }