his_charge_api_controller.go 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/service"
  5. "github.com/astaxie/beego"
  6. "time"
  7. )
  8. type HisChargeApiController struct {
  9. BaseAuthAPIController
  10. }
  11. func HisChargeApiRegistRouters() {
  12. beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
  13. beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
  14. }
  15. func (c *HisChargeApiController) GetChargeStatisticsDetail() {
  16. start_time := c.GetString("start_time")
  17. end_time := c.GetString("end_time")
  18. keyword := c.GetString("keyword")
  19. item_type, _ := c.GetInt64("type")
  20. adminUser := c.GetAdminUserInfo()
  21. timeLayout := "2006-01-02"
  22. loc, _ := time.LoadLocation("Local")
  23. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24. if err != nil {
  25. }
  26. startRecordDateTime := startTime.Unix()
  27. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28. if err != nil {
  29. }
  30. endRecordDateTime := endTime.Unix()
  31. chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  32. if err == nil {
  33. c.ServeSuccessJSON(map[string]interface{}{
  34. "patients": chargePatient,
  35. })
  36. return
  37. } else {
  38. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  39. return
  40. }
  41. }
  42. func (c *HisChargeApiController) GetChargeStatisticsSettle() {
  43. start_time := c.GetString("start_time")
  44. end_time := c.GetString("end_time")
  45. keyword := c.GetString("keyword")
  46. item_type, _ := c.GetInt64("type")
  47. adminUser := c.GetAdminUserInfo()
  48. timeLayout := "2006-01-02"
  49. loc, _ := time.LoadLocation("Local")
  50. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  51. if err != nil {
  52. }
  53. startRecordDateTime := startTime.Unix()
  54. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  55. if err != nil {
  56. }
  57. endRecordDateTime := endTime.Unix()
  58. chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  59. if err == nil {
  60. c.ServeSuccessJSON(map[string]interface{}{
  61. "patients": chargePatient,
  62. })
  63. return
  64. } else {
  65. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  66. return
  67. }
  68. }