pc_index_evaluation_api_controller.go 30KB

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