his_charge_api_controller.go 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
  15. beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
  16. }
  17. func (c *HisChargeApiController) GetChargeStatisticsDetail() {
  18. start_time := c.GetString("start_time")
  19. end_time := c.GetString("end_time")
  20. keyword := c.GetString("keyword")
  21. item_type, _ := c.GetInt64("type")
  22. adminUser := c.GetAdminUserInfo()
  23. timeLayout := "2006-01-02"
  24. loc, _ := time.LoadLocation("Local")
  25. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26. if err != nil {
  27. }
  28. startRecordDateTime := startTime.Unix()
  29. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30. if err != nil {
  31. }
  32. endRecordDateTime := endTime.Unix()
  33. chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  34. if err == nil {
  35. c.ServeSuccessJSON(map[string]interface{}{
  36. "patients": chargePatient,
  37. })
  38. return
  39. } else {
  40. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  41. return
  42. }
  43. }
  44. func (c *HisChargeApiController) GetChargeStatisticsSettle() {
  45. start_time := c.GetString("start_time")
  46. end_time := c.GetString("end_time")
  47. keyword := c.GetString("keyword")
  48. item_type, _ := c.GetInt64("type")
  49. adminUser := c.GetAdminUserInfo()
  50. timeLayout := "2006-01-02"
  51. loc, _ := time.LoadLocation("Local")
  52. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  53. if err != nil {
  54. }
  55. startRecordDateTime := startTime.Unix()
  56. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  57. if err != nil {
  58. }
  59. endRecordDateTime := endTime.Unix()
  60. chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  61. if err == nil {
  62. c.ServeSuccessJSON(map[string]interface{}{
  63. "patients": chargePatient,
  64. })
  65. return
  66. } else {
  67. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  68. return
  69. }
  70. }
  71. func (c *HisChargeApiController) GetHisInspectionList() {
  72. record_date := c.GetString("record_date")
  73. keyword := c.GetString("keyword")
  74. is_print, _ := c.GetInt64("is_print")
  75. page, _ := c.GetInt64("page")
  76. limit, _ := c.GetInt64("limit")
  77. adminUser := c.GetAdminUserInfo()
  78. timeLayout := "2006-01-02"
  79. loc, _ := time.LoadLocation("Local")
  80. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  81. if err != nil {
  82. }
  83. record_time := startTime.Unix()
  84. labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword)
  85. if err == nil {
  86. c.ServeSuccessJSON(map[string]interface{}{
  87. "labels": labels,
  88. "total": total,
  89. })
  90. return
  91. } else {
  92. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  93. return
  94. }
  95. }
  96. func (c *HisChargeApiController) GetHisInspectionInfo() {
  97. id, _ := c.GetInt64("id")
  98. label, err := service.GetLabelPrintInfo(id)
  99. if err == nil {
  100. c.ServeSuccessJSON(map[string]interface{}{
  101. "label": label,
  102. })
  103. return
  104. } else {
  105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  106. return
  107. }
  108. }