pc_index_evaluation_api_controller.go 27KB

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