pc_index_evaluation_api_controller.go 29KB

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