pc_index_evaluation_api_controller.go 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  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. this.ServeSuccessJSON(map[string]interface{}{
  178. "data": data,
  179. })
  180. }
  181. func (this *PCIndexEvaluationApiController) GetPatientInspectionBarChartData() {
  182. adminUserInfo := this.GetAdminUserInfo()
  183. start_time := this.GetString("start_time")
  184. end_time := this.GetString("end_time")
  185. project_id, _ := this.GetInt64("project_id")
  186. item_id, _ := this.GetInt64("item_id")
  187. range_type, _ := this.GetInt("range_type")
  188. patient_id, _ := this.GetInt64("patient_id")
  189. timeLayout := "2006-01-02"
  190. loc, _ := time.LoadLocation("Local")
  191. var theStartTIme int64
  192. if len(start_time) > 0 {
  193. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  194. if err != nil {
  195. utils.ErrorLog(err.Error())
  196. }
  197. theStartTIme = theTime.Unix()
  198. }
  199. var theEndtTIme int64
  200. if len(end_time) > 0 {
  201. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  202. if err != nil {
  203. utils.ErrorLog(err.Error())
  204. }
  205. theEndtTIme = theTime.Unix()
  206. }
  207. var range_value string
  208. if range_type == 1 {
  209. qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
  210. range_value = qcs.MinRange + "," + qcs.LargeRange
  211. } else {
  212. inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
  213. for _, item := range inspection {
  214. if len(range_value) == 0 {
  215. range_value = item.InspectValue
  216. } else {
  217. range_value = range_value + "," + item.InspectValue
  218. }
  219. }
  220. }
  221. data, _ := statistics_service.GetPatientInspectionBarChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, project_id, item_id, range_type, range_value, patient_id)
  222. this.ServeSuccessJSON(map[string]interface{}{
  223. "data": data,
  224. })
  225. }
  226. func (this *PCIndexEvaluationApiController) GetAdminUser() {
  227. admins, _ := statistics_service.GetAllAdminUser(this.GetAdminUserInfo().CurrentOrgId)
  228. this.ServeSuccessJSON(map[string]interface{}{
  229. "admin": admins,
  230. })
  231. }
  232. func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexChartData() {
  233. adminUserInfo := this.GetAdminUserInfo()
  234. statistics_type, _ := this.GetInt("statistics_type")
  235. start_time := this.GetString("start_time")
  236. end_time := this.GetString("end_time")
  237. patient_id, _ := this.GetInt64("patient_id")
  238. timeLayout := "2006-01-02"
  239. loc, _ := time.LoadLocation("Local")
  240. var theStartTIme int64
  241. if len(start_time) > 0 {
  242. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  243. if err != nil {
  244. utils.ErrorLog(err.Error())
  245. }
  246. theStartTIme = theTime.Unix()
  247. }
  248. var theEndtTIme int64
  249. if len(end_time) > 0 {
  250. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  251. if err != nil {
  252. utils.ErrorLog(err.Error())
  253. }
  254. theEndtTIme = theTime.Unix()
  255. }
  256. if patient_id == 0 {
  257. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  258. if patientInfo == nil {
  259. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  260. return
  261. }
  262. if statistics_type == 9 || statistics_type == 10 {
  263. data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
  264. this.ServeSuccessJSON(map[string]interface{}{
  265. "data": data,
  266. })
  267. } else {
  268. data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
  269. this.ServeSuccessJSON(map[string]interface{}{
  270. "data": data,
  271. })
  272. }
  273. } else {
  274. if statistics_type == 9 || statistics_type == 10 {
  275. data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  276. this.ServeSuccessJSON(map[string]interface{}{
  277. "data": data,
  278. })
  279. } else {
  280. data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  281. this.ServeSuccessJSON(map[string]interface{}{
  282. "data": data,
  283. })
  284. }
  285. }
  286. }
  287. func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexTableData() {
  288. adminUserInfo := this.GetAdminUserInfo()
  289. start_time := this.GetString("start_time")
  290. end_time := this.GetString("end_time")
  291. patient_id, _ := this.GetInt64("patient_id")
  292. page, _ := this.GetInt64("page")
  293. limit, _ := this.GetInt64("limit")
  294. if page == 0 {
  295. page = 1
  296. }
  297. if limit == 0 {
  298. limit = 20
  299. }
  300. timeLayout := "2006-01-02"
  301. loc, _ := time.LoadLocation("Local")
  302. var theStartTIme int64
  303. if len(start_time) > 0 {
  304. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  305. if err != nil {
  306. utils.ErrorLog(err.Error())
  307. }
  308. theStartTIme = theTime.Unix()
  309. }
  310. var theEndtTIme int64
  311. if len(end_time) > 0 {
  312. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  313. if err != nil {
  314. utils.ErrorLog(err.Error())
  315. }
  316. theEndtTIme = theTime.Unix()
  317. }
  318. if patient_id == 0 {
  319. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  320. if patientInfo == nil {
  321. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  322. return
  323. }
  324. data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
  325. this.ServeSuccessJSON(map[string]interface{}{
  326. "data": data,
  327. "total": total,
  328. })
  329. } else {
  330. data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  331. this.ServeSuccessJSON(map[string]interface{}{
  332. "data": data,
  333. "total": total,
  334. })
  335. }
  336. }
  337. func (this *PCIndexEvaluationApiController) GetDialysisWatchChartData() {
  338. adminUserInfo := this.GetAdminUserInfo()
  339. statistics_type, _ := this.GetInt("statistics_type")
  340. start_time := this.GetString("start_time")
  341. end_time := this.GetString("end_time")
  342. patient_id, _ := this.GetInt64("patient_id")
  343. timeLayout := "2006-01-02"
  344. loc, _ := time.LoadLocation("Local")
  345. var theStartTIme int64
  346. if len(start_time) > 0 {
  347. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  348. if err != nil {
  349. utils.ErrorLog(err.Error())
  350. }
  351. theStartTIme = theTime.Unix()
  352. }
  353. var theEndtTIme int64
  354. if len(end_time) > 0 {
  355. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  356. if err != nil {
  357. utils.ErrorLog(err.Error())
  358. }
  359. theEndtTIme = theTime.Unix()
  360. }
  361. if patient_id == 0 {
  362. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  363. if patientInfo == nil {
  364. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  365. return
  366. }
  367. data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
  368. this.ServeSuccessJSON(map[string]interface{}{
  369. "data": data,
  370. })
  371. } else {
  372. data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  373. this.ServeSuccessJSON(map[string]interface{}{
  374. "data": data,
  375. })
  376. }
  377. }
  378. func (this *PCIndexEvaluationApiController) GetDialysisWatchTableData() {
  379. adminUserInfo := this.GetAdminUserInfo()
  380. start_time := this.GetString("start_time")
  381. end_time := this.GetString("end_time")
  382. patient_id, _ := this.GetInt64("patient_id")
  383. page, _ := this.GetInt64("page")
  384. limit, _ := this.GetInt64("limit")
  385. if page == 0 {
  386. page = 1
  387. }
  388. if limit == 0 {
  389. limit = 20
  390. }
  391. timeLayout := "2006-01-02"
  392. loc, _ := time.LoadLocation("Local")
  393. var theStartTIme int64
  394. if len(start_time) > 0 {
  395. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  396. if err != nil {
  397. utils.ErrorLog(err.Error())
  398. }
  399. theStartTIme = theTime.Unix()
  400. }
  401. var theEndtTIme int64
  402. if len(end_time) > 0 {
  403. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  404. if err != nil {
  405. utils.ErrorLog(err.Error())
  406. }
  407. theEndtTIme = theTime.Unix()
  408. }
  409. if patient_id == 0 {
  410. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  411. if patientInfo == nil {
  412. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  413. return
  414. }
  415. data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
  416. this.ServeSuccessJSON(map[string]interface{}{
  417. "data": data,
  418. "total": total,
  419. })
  420. } else {
  421. data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  422. this.ServeSuccessJSON(map[string]interface{}{
  423. "data": data,
  424. "total": total,
  425. })
  426. }
  427. }
  428. func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureChartData() {
  429. adminUserInfo := this.GetAdminUserInfo()
  430. statistics_type, _ := this.GetInt("statistics_type")
  431. start_time := this.GetString("start_time")
  432. end_time := this.GetString("end_time")
  433. patient_id, _ := this.GetInt64("patient_id")
  434. timeLayout := "2006-01-02"
  435. loc, _ := time.LoadLocation("Local")
  436. var theStartTIme int64
  437. if len(start_time) > 0 {
  438. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  439. if err != nil {
  440. utils.ErrorLog(err.Error())
  441. }
  442. theStartTIme = theTime.Unix()
  443. }
  444. var theEndtTIme int64
  445. if len(end_time) > 0 {
  446. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  447. if err != nil {
  448. utils.ErrorLog(err.Error())
  449. }
  450. theEndtTIme = theTime.Unix()
  451. }
  452. data, _ := statistics_service.GetBloodPressureChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, patient_id)
  453. this.ServeSuccessJSON(map[string]interface{}{
  454. "data": data,
  455. })
  456. }
  457. func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureTableData() {
  458. adminUserInfo := this.GetAdminUserInfo()
  459. start_time := this.GetString("start_time")
  460. end_time := this.GetString("end_time")
  461. patient_id, _ := this.GetInt64("patient_id")
  462. page, _ := this.GetInt64("page")
  463. limit, _ := this.GetInt64("limit")
  464. if page == 0 {
  465. page = 1
  466. }
  467. if limit == 0 {
  468. limit = 20
  469. }
  470. timeLayout := "2006-01-02"
  471. loc, _ := time.LoadLocation("Local")
  472. var theStartTIme int64
  473. if len(start_time) > 0 {
  474. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  475. if err != nil {
  476. utils.ErrorLog(err.Error())
  477. }
  478. theStartTIme = theTime.Unix()
  479. }
  480. var theEndtTIme int64
  481. if len(end_time) > 0 {
  482. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  483. if err != nil {
  484. utils.ErrorLog(err.Error())
  485. }
  486. theEndtTIme = theTime.Unix()
  487. }
  488. data, total, _ := statistics_service.GetBloodPressureTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  489. this.ServeSuccessJSON(map[string]interface{}{
  490. "data": data,
  491. "total": total,
  492. })
  493. }
  494. func (this *PCIndexEvaluationApiController) GetDialysisPatientBloodPressureChartData() {
  495. adminUserInfo := this.GetAdminUserInfo()
  496. statistics_type, _ := this.GetInt("statistics_type")
  497. start_time := this.GetString("start_time")
  498. end_time := this.GetString("end_time")
  499. patient_id, _ := this.GetInt64("patient_id")
  500. timeLayout := "2006-01-02"
  501. loc, _ := time.LoadLocation("Local")
  502. var theStartTIme int64
  503. if len(start_time) > 0 {
  504. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  505. if err != nil {
  506. utils.ErrorLog(err.Error())
  507. }
  508. theStartTIme = theTime.Unix()
  509. }
  510. var theEndtTIme int64
  511. if len(end_time) > 0 {
  512. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  513. if err != nil {
  514. utils.ErrorLog(err.Error())
  515. }
  516. theEndtTIme = theTime.Unix()
  517. }
  518. data, _ := statistics_service.GetPatientBloodPressureChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  519. this.ServeSuccessJSON(map[string]interface{}{
  520. "data": data,
  521. })
  522. }
  523. func (this *PCIndexEvaluationApiController) GetDialysisWeightChartData() {
  524. adminUserInfo := this.GetAdminUserInfo()
  525. statistics_type, _ := this.GetInt("statistics_type")
  526. start_time := this.GetString("start_time")
  527. end_time := this.GetString("end_time")
  528. timeLayout := "2006-01-02"
  529. loc, _ := time.LoadLocation("Local")
  530. var theStartTIme int64
  531. if len(start_time) > 0 {
  532. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  533. if err != nil {
  534. utils.ErrorLog(err.Error())
  535. }
  536. theStartTIme = theTime.Unix()
  537. }
  538. var theEndtTIme int64
  539. if len(end_time) > 0 {
  540. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  541. if err != nil {
  542. utils.ErrorLog(err.Error())
  543. }
  544. theEndtTIme = theTime.Unix()
  545. }
  546. data, _ := statistics_service.GetDialysisWeightChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
  547. this.ServeSuccessJSON(map[string]interface{}{
  548. "data": data,
  549. })
  550. }
  551. func (this *PCIndexEvaluationApiController) GetDialysisWeightTableData() {
  552. adminUserInfo := this.GetAdminUserInfo()
  553. start_time := this.GetString("start_time")
  554. end_time := this.GetString("end_time")
  555. patient_id, _ := this.GetInt64("patient_id")
  556. page, _ := this.GetInt64("page")
  557. limit, _ := this.GetInt64("limit")
  558. if page == 0 {
  559. page = 1
  560. }
  561. if limit == 0 {
  562. limit = 20
  563. }
  564. timeLayout := "2006-01-02"
  565. loc, _ := time.LoadLocation("Local")
  566. var theStartTIme int64
  567. if len(start_time) > 0 {
  568. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  569. if err != nil {
  570. utils.ErrorLog(err.Error())
  571. }
  572. theStartTIme = theTime.Unix()
  573. }
  574. var theEndtTIme int64
  575. if len(end_time) > 0 {
  576. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  577. if err != nil {
  578. utils.ErrorLog(err.Error())
  579. }
  580. theEndtTIme = theTime.Unix()
  581. }
  582. data, total, _ := statistics_service.GetDialysisWeightTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  583. this.ServeSuccessJSON(map[string]interface{}{
  584. "data": data,
  585. "total": total,
  586. })
  587. }
  588. func (this *PCIndexEvaluationApiController) GetDialysisPatientWeightChartData() {
  589. adminUserInfo := this.GetAdminUserInfo()
  590. statistics_type, _ := this.GetInt("statistics_type")
  591. start_time := this.GetString("start_time")
  592. end_time := this.GetString("end_time")
  593. patient_id, _ := this.GetInt64("patient_id")
  594. timeLayout := "2006-01-02"
  595. loc, _ := time.LoadLocation("Local")
  596. var theStartTIme int64
  597. if len(start_time) > 0 {
  598. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  599. if err != nil {
  600. utils.ErrorLog(err.Error())
  601. }
  602. theStartTIme = theTime.Unix()
  603. }
  604. var theEndtTIme int64
  605. if len(end_time) > 0 {
  606. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  607. if err != nil {
  608. utils.ErrorLog(err.Error())
  609. }
  610. theEndtTIme = theTime.Unix()
  611. }
  612. data, _ := statistics_service.GetPatientDialysisWeightChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  613. this.ServeSuccessJSON(map[string]interface{}{
  614. "data": data,
  615. })
  616. }
  617. func (this *PCIndexEvaluationApiController) GetDoctorWorkloadChartData() {
  618. adminUserInfo := this.GetAdminUserInfo()
  619. statistics_type, _ := this.GetInt("statistics_type")
  620. start_time := this.GetString("start_time")
  621. end_time := this.GetString("end_time")
  622. timeLayout := "2006-01-02"
  623. loc, _ := time.LoadLocation("Local")
  624. var theStartTIme int64
  625. if len(start_time) > 0 {
  626. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  627. if err != nil {
  628. utils.ErrorLog(err.Error())
  629. }
  630. theStartTIme = theTime.Unix()
  631. }
  632. var theEndtTIme int64
  633. if len(end_time) > 0 {
  634. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  635. if err != nil {
  636. utils.ErrorLog(err.Error())
  637. }
  638. theEndtTIme = theTime.Unix()
  639. }
  640. data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
  641. this.ServeSuccessJSON(map[string]interface{}{
  642. "data": data,
  643. })
  644. }
  645. func (this *PCIndexEvaluationApiController) GetDoctorWorkloadTableData() {
  646. adminUserInfo := this.GetAdminUserInfo()
  647. start_time := this.GetString("start_time")
  648. end_time := this.GetString("end_time")
  649. admin_user_id, _ := this.GetInt64("admin_user_id")
  650. page, _ := this.GetInt64("page")
  651. limit, _ := this.GetInt64("limit")
  652. if page == 0 {
  653. page = 1
  654. }
  655. if limit == 0 {
  656. limit = 20
  657. }
  658. timeLayout := "2006-01-02"
  659. loc, _ := time.LoadLocation("Local")
  660. var theStartTIme int64
  661. if len(start_time) > 0 {
  662. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  663. if err != nil {
  664. utils.ErrorLog(err.Error())
  665. }
  666. theStartTIme = theTime.Unix()
  667. }
  668. var theEndtTIme int64
  669. if len(end_time) > 0 {
  670. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  671. if err != nil {
  672. utils.ErrorLog(err.Error())
  673. }
  674. theEndtTIme = theTime.Unix()
  675. }
  676. data, _ := statistics_service.GetDoctorWorkloadTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id)
  677. this.ServeSuccessJSON(map[string]interface{}{
  678. "data": data,
  679. })
  680. }
  681. func (this *PCIndexEvaluationApiController) GetNurseWorkloadChartData() {
  682. adminUserInfo := this.GetAdminUserInfo()
  683. statistics_type, _ := this.GetInt("statistics_type")
  684. start_time := this.GetString("start_time")
  685. end_time := this.GetString("end_time")
  686. timeLayout := "2006-01-02"
  687. loc, _ := time.LoadLocation("Local")
  688. var theStartTIme int64
  689. if len(start_time) > 0 {
  690. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  691. if err != nil {
  692. utils.ErrorLog(err.Error())
  693. }
  694. theStartTIme = theTime.Unix()
  695. }
  696. var theEndtTIme int64
  697. if len(end_time) > 0 {
  698. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  699. if err != nil {
  700. utils.ErrorLog(err.Error())
  701. }
  702. theEndtTIme = theTime.Unix()
  703. }
  704. data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
  705. this.ServeSuccessJSON(map[string]interface{}{
  706. "data": data,
  707. })
  708. }
  709. func (this *PCIndexEvaluationApiController) GetNurseWorkloadTableData() {
  710. adminUserInfo := this.GetAdminUserInfo()
  711. start_time := this.GetString("start_time")
  712. end_time := this.GetString("end_time")
  713. admin_user_id, _ := this.GetInt64("admin_user_id")
  714. page, _ := this.GetInt64("page")
  715. limit, _ := this.GetInt64("limit")
  716. if page == 0 {
  717. page = 1
  718. }
  719. if limit == 0 {
  720. limit = 5
  721. }
  722. timeLayout := "2006-01-02"
  723. loc, _ := time.LoadLocation("Local")
  724. var theStartTIme int64
  725. if len(start_time) > 0 {
  726. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  727. if err != nil {
  728. utils.ErrorLog(err.Error())
  729. }
  730. theStartTIme = theTime.Unix()
  731. }
  732. var theEndtTIme int64
  733. if len(end_time) > 0 {
  734. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  735. if err != nil {
  736. utils.ErrorLog(err.Error())
  737. }
  738. theEndtTIme = theTime.Unix()
  739. }
  740. data, total, _ := statistics_service.GetNurseWorkloadTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id, page, limit)
  741. this.ServeSuccessJSON(map[string]interface{}{
  742. "data": data,
  743. "total": total,
  744. })
  745. }
  746. func (this *PCIndexEvaluationApiController) GetDefaultPatient() {
  747. adminUserInfo := this.GetAdminUserInfo()
  748. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  749. if patientInfo == nil {
  750. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  751. return
  752. }
  753. this.ServeSuccessJSON(map[string]interface{}{
  754. "patient": patientInfo,
  755. })
  756. }