pc_index_evaluation_api_controller.go 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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/dialysisprocessindex/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisProcessIndexChartData")
  11. beego.Router("/api/dialysisprocessindex/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisProcessIndexTableData")
  12. beego.Router("/api/dialysiswatch/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisWatchChartData")
  13. beego.Router("/api/dialysiswatch/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisWatchTableData")
  14. beego.Router("/api/dialysisbloodpressure/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisBloodPressureChartData")
  15. beego.Router("/api/dialysisbloodpressure/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisBloodPressureTableData")
  16. beego.Router("/api/patientdialysisbloodpressure/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisPatientBloodPressureChartData")
  17. beego.Router("/api/dialysisweight/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisWeightChartData")
  18. beego.Router("/api/dialysisweight/table", &PCIndexEvaluationApiController{}, "Get:GetDialysisWeightTableData")
  19. beego.Router("/api/patientdialysisweight/chart", &PCIndexEvaluationApiController{}, "Get:GetDialysisPatientWeightChartData")
  20. beego.Router("/api/doctorworkload/chart", &PCIndexEvaluationApiController{}, "Get:GetDoctorWorkloadChartData")
  21. beego.Router("/api/doctorworkload/table", &PCIndexEvaluationApiController{}, "Get:GetDoctorWorkloadTableData")
  22. beego.Router("/api/nurseworkload/chart", &PCIndexEvaluationApiController{}, "Get:GetNurseWorkloadChartData")
  23. beego.Router("/api/nurseworkload/table", &PCIndexEvaluationApiController{}, "Get:GetNurseWorkloadTableData")
  24. beego.Router("/api/adminuser/all", &PCIndexEvaluationApiController{}, "Get:GetAdminUser")
  25. beego.Router("/api/defalutpatient/get", &PCIndexEvaluationApiController{}, "Get:GetDefaultPatient")
  26. }
  27. type PCIndexEvaluationApiController struct {
  28. BaseAuthAPIController
  29. }
  30. func (this *PCIndexEvaluationApiController) GetAdminUser() {
  31. admins, _ := statistics_service.GetAllAdminUser(this.GetAdminUserInfo().CurrentOrgId)
  32. this.ServeSuccessJSON(map[string]interface{}{
  33. "admin": admins,
  34. })
  35. }
  36. func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexChartData() {
  37. adminUserInfo := this.GetAdminUserInfo()
  38. statistics_type, _ := this.GetInt("statistics_type")
  39. start_time := this.GetString("start_time")
  40. end_time := this.GetString("end_time")
  41. patient_id, _ := this.GetInt64("patient_id")
  42. timeLayout := "2006-01-02"
  43. loc, _ := time.LoadLocation("Local")
  44. var theStartTIme int64
  45. if len(start_time) > 0 {
  46. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  47. if err != nil {
  48. utils.ErrorLog(err.Error())
  49. }
  50. theStartTIme = theTime.Unix()
  51. }
  52. var theEndtTIme int64
  53. if len(end_time) > 0 {
  54. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  55. if err != nil {
  56. utils.ErrorLog(err.Error())
  57. }
  58. theEndtTIme = theTime.Unix()
  59. }
  60. if patient_id == 0 {
  61. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  62. if patientInfo == nil {
  63. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  64. return
  65. }
  66. if statistics_type == 9 || statistics_type == 10 {
  67. data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
  68. this.ServeSuccessJSON(map[string]interface{}{
  69. "data": data,
  70. })
  71. } else {
  72. data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
  73. this.ServeSuccessJSON(map[string]interface{}{
  74. "data": data,
  75. })
  76. }
  77. } else {
  78. if statistics_type == 9 || statistics_type == 10 {
  79. data, _ := statistics_service.GetDialysisProcessIndexOtherChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  80. this.ServeSuccessJSON(map[string]interface{}{
  81. "data": data,
  82. })
  83. } else {
  84. data, _ := statistics_service.GetDialysisProcessIndexChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  85. this.ServeSuccessJSON(map[string]interface{}{
  86. "data": data,
  87. })
  88. }
  89. }
  90. }
  91. func (this *PCIndexEvaluationApiController) GetDialysisProcessIndexTableData() {
  92. adminUserInfo := this.GetAdminUserInfo()
  93. start_time := this.GetString("start_time")
  94. end_time := this.GetString("end_time")
  95. patient_id, _ := this.GetInt64("patient_id")
  96. page, _ := this.GetInt64("page")
  97. limit, _ := this.GetInt64("limit")
  98. if page == 0 {
  99. page = 1
  100. }
  101. if limit == 0 {
  102. limit = 20
  103. }
  104. timeLayout := "2006-01-02"
  105. loc, _ := time.LoadLocation("Local")
  106. var theStartTIme int64
  107. if len(start_time) > 0 {
  108. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  109. if err != nil {
  110. utils.ErrorLog(err.Error())
  111. }
  112. theStartTIme = theTime.Unix()
  113. }
  114. var theEndtTIme int64
  115. if len(end_time) > 0 {
  116. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  117. if err != nil {
  118. utils.ErrorLog(err.Error())
  119. }
  120. theEndtTIme = theTime.Unix()
  121. }
  122. if patient_id == 0 {
  123. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  124. if patientInfo == nil {
  125. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  126. return
  127. }
  128. data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
  129. this.ServeSuccessJSON(map[string]interface{}{
  130. "data": data,
  131. "total": total,
  132. })
  133. } else {
  134. data, total, _ := statistics_service.GetDialysisProcessIndexTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  135. this.ServeSuccessJSON(map[string]interface{}{
  136. "data": data,
  137. "total": total,
  138. })
  139. }
  140. }
  141. func (this *PCIndexEvaluationApiController) GetDialysisWatchChartData() {
  142. adminUserInfo := this.GetAdminUserInfo()
  143. statistics_type, _ := this.GetInt("statistics_type")
  144. start_time := this.GetString("start_time")
  145. end_time := this.GetString("end_time")
  146. patient_id, _ := this.GetInt64("patient_id")
  147. timeLayout := "2006-01-02"
  148. loc, _ := time.LoadLocation("Local")
  149. var theStartTIme int64
  150. if len(start_time) > 0 {
  151. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  152. if err != nil {
  153. utils.ErrorLog(err.Error())
  154. }
  155. theStartTIme = theTime.Unix()
  156. }
  157. var theEndtTIme int64
  158. if len(end_time) > 0 {
  159. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  160. if err != nil {
  161. utils.ErrorLog(err.Error())
  162. }
  163. theEndtTIme = theTime.Unix()
  164. }
  165. if patient_id == 0 {
  166. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  167. if patientInfo == nil {
  168. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  169. return
  170. }
  171. data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patientInfo.ID, theStartTIme, theEndtTIme, statistics_type)
  172. this.ServeSuccessJSON(map[string]interface{}{
  173. "data": data,
  174. })
  175. } else {
  176. data, _ := statistics_service.GetDialysisWatchChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  177. this.ServeSuccessJSON(map[string]interface{}{
  178. "data": data,
  179. })
  180. }
  181. }
  182. func (this *PCIndexEvaluationApiController) GetDialysisWatchTableData() {
  183. adminUserInfo := this.GetAdminUserInfo()
  184. start_time := this.GetString("start_time")
  185. end_time := this.GetString("end_time")
  186. patient_id, _ := this.GetInt64("patient_id")
  187. page, _ := this.GetInt64("page")
  188. limit, _ := this.GetInt64("limit")
  189. if page == 0 {
  190. page = 1
  191. }
  192. if limit == 0 {
  193. limit = 20
  194. }
  195. timeLayout := "2006-01-02"
  196. loc, _ := time.LoadLocation("Local")
  197. var theStartTIme int64
  198. if len(start_time) > 0 {
  199. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  200. if err != nil {
  201. utils.ErrorLog(err.Error())
  202. }
  203. theStartTIme = theTime.Unix()
  204. }
  205. var theEndtTIme int64
  206. if len(end_time) > 0 {
  207. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  208. if err != nil {
  209. utils.ErrorLog(err.Error())
  210. }
  211. theEndtTIme = theTime.Unix()
  212. }
  213. if patient_id == 0 {
  214. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  215. if patientInfo == nil {
  216. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  217. return
  218. }
  219. data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, patientInfo.ID, page, limit, theStartTIme, theEndtTIme)
  220. this.ServeSuccessJSON(map[string]interface{}{
  221. "data": data,
  222. "total": total,
  223. })
  224. } else {
  225. data, total, _ := statistics_service.GetDialysisWatchTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  226. this.ServeSuccessJSON(map[string]interface{}{
  227. "data": data,
  228. "total": total,
  229. })
  230. }
  231. }
  232. func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureChartData() {
  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. data, _ := statistics_service.GetBloodPressureChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type, patient_id)
  257. this.ServeSuccessJSON(map[string]interface{}{
  258. "data": data,
  259. })
  260. }
  261. func (this *PCIndexEvaluationApiController) GetDialysisBloodPressureTableData() {
  262. adminUserInfo := this.GetAdminUserInfo()
  263. start_time := this.GetString("start_time")
  264. end_time := this.GetString("end_time")
  265. patient_id, _ := this.GetInt64("patient_id")
  266. page, _ := this.GetInt64("page")
  267. limit, _ := this.GetInt64("limit")
  268. if page == 0 {
  269. page = 1
  270. }
  271. if limit == 0 {
  272. limit = 20
  273. }
  274. timeLayout := "2006-01-02"
  275. loc, _ := time.LoadLocation("Local")
  276. var theStartTIme int64
  277. if len(start_time) > 0 {
  278. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  279. if err != nil {
  280. utils.ErrorLog(err.Error())
  281. }
  282. theStartTIme = theTime.Unix()
  283. }
  284. var theEndtTIme int64
  285. if len(end_time) > 0 {
  286. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  287. if err != nil {
  288. utils.ErrorLog(err.Error())
  289. }
  290. theEndtTIme = theTime.Unix()
  291. }
  292. data, total, _ := statistics_service.GetBloodPressureTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  293. this.ServeSuccessJSON(map[string]interface{}{
  294. "data": data,
  295. "total": total,
  296. })
  297. }
  298. func (this *PCIndexEvaluationApiController) GetDialysisPatientBloodPressureChartData() {
  299. adminUserInfo := this.GetAdminUserInfo()
  300. statistics_type, _ := this.GetInt("statistics_type")
  301. start_time := this.GetString("start_time")
  302. end_time := this.GetString("end_time")
  303. patient_id, _ := this.GetInt64("patient_id")
  304. timeLayout := "2006-01-02"
  305. loc, _ := time.LoadLocation("Local")
  306. var theStartTIme int64
  307. if len(start_time) > 0 {
  308. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  309. if err != nil {
  310. utils.ErrorLog(err.Error())
  311. }
  312. theStartTIme = theTime.Unix()
  313. }
  314. var theEndtTIme int64
  315. if len(end_time) > 0 {
  316. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  317. if err != nil {
  318. utils.ErrorLog(err.Error())
  319. }
  320. theEndtTIme = theTime.Unix()
  321. }
  322. data, _ := statistics_service.GetPatientBloodPressureChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  323. this.ServeSuccessJSON(map[string]interface{}{
  324. "data": data,
  325. })
  326. }
  327. func (this *PCIndexEvaluationApiController) GetDialysisWeightChartData() {
  328. adminUserInfo := this.GetAdminUserInfo()
  329. statistics_type, _ := this.GetInt("statistics_type")
  330. start_time := this.GetString("start_time")
  331. end_time := this.GetString("end_time")
  332. timeLayout := "2006-01-02"
  333. loc, _ := time.LoadLocation("Local")
  334. var theStartTIme int64
  335. if len(start_time) > 0 {
  336. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  337. if err != nil {
  338. utils.ErrorLog(err.Error())
  339. }
  340. theStartTIme = theTime.Unix()
  341. }
  342. var theEndtTIme int64
  343. if len(end_time) > 0 {
  344. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  345. if err != nil {
  346. utils.ErrorLog(err.Error())
  347. }
  348. theEndtTIme = theTime.Unix()
  349. }
  350. data, _ := statistics_service.GetDialysisWeightChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
  351. this.ServeSuccessJSON(map[string]interface{}{
  352. "data": data,
  353. })
  354. }
  355. func (this *PCIndexEvaluationApiController) GetDialysisWeightTableData() {
  356. adminUserInfo := this.GetAdminUserInfo()
  357. start_time := this.GetString("start_time")
  358. end_time := this.GetString("end_time")
  359. patient_id, _ := this.GetInt64("patient_id")
  360. page, _ := this.GetInt64("page")
  361. limit, _ := this.GetInt64("limit")
  362. if page == 0 {
  363. page = 1
  364. }
  365. if limit == 0 {
  366. limit = 20
  367. }
  368. timeLayout := "2006-01-02"
  369. loc, _ := time.LoadLocation("Local")
  370. var theStartTIme int64
  371. if len(start_time) > 0 {
  372. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  373. if err != nil {
  374. utils.ErrorLog(err.Error())
  375. }
  376. theStartTIme = theTime.Unix()
  377. }
  378. var theEndtTIme int64
  379. if len(end_time) > 0 {
  380. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  381. if err != nil {
  382. utils.ErrorLog(err.Error())
  383. }
  384. theEndtTIme = theTime.Unix()
  385. }
  386. data, total, _ := statistics_service.GetDialysisWeightTableData(adminUserInfo.CurrentOrgId, patient_id, page, limit, theStartTIme, theEndtTIme)
  387. this.ServeSuccessJSON(map[string]interface{}{
  388. "data": data,
  389. "total": total,
  390. })
  391. }
  392. func (this *PCIndexEvaluationApiController) GetDialysisPatientWeightChartData() {
  393. adminUserInfo := this.GetAdminUserInfo()
  394. statistics_type, _ := this.GetInt("statistics_type")
  395. start_time := this.GetString("start_time")
  396. end_time := this.GetString("end_time")
  397. patient_id, _ := this.GetInt64("patient_id")
  398. timeLayout := "2006-01-02"
  399. loc, _ := time.LoadLocation("Local")
  400. var theStartTIme int64
  401. if len(start_time) > 0 {
  402. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  403. if err != nil {
  404. utils.ErrorLog(err.Error())
  405. }
  406. theStartTIme = theTime.Unix()
  407. }
  408. var theEndtTIme int64
  409. if len(end_time) > 0 {
  410. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  411. if err != nil {
  412. utils.ErrorLog(err.Error())
  413. }
  414. theEndtTIme = theTime.Unix()
  415. }
  416. data, _ := statistics_service.GetPatientDialysisWeightChartData(adminUserInfo.CurrentOrgId, patient_id, theStartTIme, theEndtTIme, statistics_type)
  417. this.ServeSuccessJSON(map[string]interface{}{
  418. "data": data,
  419. })
  420. }
  421. func (this *PCIndexEvaluationApiController) GetDoctorWorkloadChartData() {
  422. adminUserInfo := this.GetAdminUserInfo()
  423. statistics_type, _ := this.GetInt("statistics_type")
  424. start_time := this.GetString("start_time")
  425. end_time := this.GetString("end_time")
  426. timeLayout := "2006-01-02"
  427. loc, _ := time.LoadLocation("Local")
  428. var theStartTIme int64
  429. if len(start_time) > 0 {
  430. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  431. if err != nil {
  432. utils.ErrorLog(err.Error())
  433. }
  434. theStartTIme = theTime.Unix()
  435. }
  436. var theEndtTIme int64
  437. if len(end_time) > 0 {
  438. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  439. if err != nil {
  440. utils.ErrorLog(err.Error())
  441. }
  442. theEndtTIme = theTime.Unix()
  443. }
  444. data, _ := statistics_service.GetDoctorWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
  445. this.ServeSuccessJSON(map[string]interface{}{
  446. "data": data,
  447. })
  448. }
  449. func (this *PCIndexEvaluationApiController) GetDoctorWorkloadTableData() {
  450. adminUserInfo := this.GetAdminUserInfo()
  451. start_time := this.GetString("start_time")
  452. end_time := this.GetString("end_time")
  453. admin_user_id, _ := this.GetInt64("admin_user_id")
  454. page, _ := this.GetInt64("page")
  455. limit, _ := this.GetInt64("limit")
  456. if page == 0 {
  457. page = 1
  458. }
  459. if limit == 0 {
  460. limit = 20
  461. }
  462. timeLayout := "2006-01-02"
  463. loc, _ := time.LoadLocation("Local")
  464. var theStartTIme int64
  465. if len(start_time) > 0 {
  466. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  467. if err != nil {
  468. utils.ErrorLog(err.Error())
  469. }
  470. theStartTIme = theTime.Unix()
  471. }
  472. var theEndtTIme int64
  473. if len(end_time) > 0 {
  474. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  475. if err != nil {
  476. utils.ErrorLog(err.Error())
  477. }
  478. theEndtTIme = theTime.Unix()
  479. }
  480. data, _ := statistics_service.GetDoctorWorkloadTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id)
  481. this.ServeSuccessJSON(map[string]interface{}{
  482. "data": data,
  483. })
  484. }
  485. func (this *PCIndexEvaluationApiController) GetNurseWorkloadChartData() {
  486. adminUserInfo := this.GetAdminUserInfo()
  487. statistics_type, _ := this.GetInt("statistics_type")
  488. start_time := this.GetString("start_time")
  489. end_time := this.GetString("end_time")
  490. timeLayout := "2006-01-02"
  491. loc, _ := time.LoadLocation("Local")
  492. var theStartTIme int64
  493. if len(start_time) > 0 {
  494. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  495. if err != nil {
  496. utils.ErrorLog(err.Error())
  497. }
  498. theStartTIme = theTime.Unix()
  499. }
  500. var theEndtTIme int64
  501. if len(end_time) > 0 {
  502. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  503. if err != nil {
  504. utils.ErrorLog(err.Error())
  505. }
  506. theEndtTIme = theTime.Unix()
  507. }
  508. data, _ := statistics_service.GetNurseWorkloadChartData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, statistics_type)
  509. this.ServeSuccessJSON(map[string]interface{}{
  510. "data": data,
  511. })
  512. }
  513. func (this *PCIndexEvaluationApiController) GetNurseWorkloadTableData() {
  514. adminUserInfo := this.GetAdminUserInfo()
  515. start_time := this.GetString("start_time")
  516. end_time := this.GetString("end_time")
  517. admin_user_id, _ := this.GetInt64("admin_user_id")
  518. page, _ := this.GetInt64("page")
  519. limit, _ := this.GetInt64("limit")
  520. if page == 0 {
  521. page = 1
  522. }
  523. if limit == 0 {
  524. limit = 20
  525. }
  526. timeLayout := "2006-01-02"
  527. loc, _ := time.LoadLocation("Local")
  528. var theStartTIme int64
  529. if len(start_time) > 0 {
  530. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  531. if err != nil {
  532. utils.ErrorLog(err.Error())
  533. }
  534. theStartTIme = theTime.Unix()
  535. }
  536. var theEndtTIme int64
  537. if len(end_time) > 0 {
  538. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  539. if err != nil {
  540. utils.ErrorLog(err.Error())
  541. }
  542. theEndtTIme = theTime.Unix()
  543. }
  544. data, _ := statistics_service.GetNurseWorkloadTableData(adminUserInfo.CurrentOrgId, theStartTIme, theEndtTIme, admin_user_id)
  545. this.ServeSuccessJSON(map[string]interface{}{
  546. "data": data,
  547. })
  548. }
  549. func (this *PCIndexEvaluationApiController) GetDefaultPatient() {
  550. adminUserInfo := this.GetAdminUserInfo()
  551. patientInfo, _ := statistics_service.GetOrgFirstPatientInfo(adminUserInfo.CurrentOrgId)
  552. if patientInfo == nil {
  553. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrgNoPatient)
  554. return
  555. }
  556. this.ServeSuccessJSON(map[string]interface{}{
  557. "patient": patientInfo,
  558. })
  559. }