pc_index_evaluation_api_controller.go 30KB

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