his_print_api_controller.go 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/service"
  5. "github.com/astaxie/beego"
  6. "strings"
  7. "time"
  8. )
  9. type HisPrintApiController struct {
  10. BaseAuthAPIController
  11. }
  12. func HisPrintApiRegistRouters() {
  13. beego.Router("/api/his/prescription/print", &HisPrintApiController{}, "get:GetBatchHisPrescriptionData")
  14. }
  15. func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
  16. record_date := c.GetString("record_date")
  17. patient_ids := c.GetString("patient_ids")
  18. print_type, _ := c.GetInt64("type")
  19. timeLayout := "2006-01-02"
  20. loc, _ := time.LoadLocation("Local")
  21. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  22. if err != nil {
  23. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24. return
  25. }
  26. recordDateTime := theTime.Unix()
  27. adminInfo := c.GetAdminUserInfo()
  28. ids := strings.Split(patient_ids, ",")
  29. switch print_type {
  30. case 1:
  31. patients, _ := service.GetBatchDrugHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  32. c.ServeSuccessJSON(map[string]interface{}{
  33. "patients": patients,
  34. })
  35. break
  36. case 2:
  37. patients, _ := service.GetBatchProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  38. c.ServeSuccessJSON(map[string]interface{}{
  39. "patients": patients,
  40. })
  41. break
  42. case 3:
  43. patients, _ := service.GetBatchInspectionProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  44. c.ServeSuccessJSON(map[string]interface{}{
  45. "patients": patients,
  46. })
  47. break
  48. }
  49. }