his_print_api_controller.go 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. for _, item := range patients {
  39. for _, subItem := range item.HisPrintPrescription {
  40. for _, subItemTwo := range subItem.HisPrescriptionProject {
  41. if subItemTwo.HisProject.CostClassify == 3 {
  42. }
  43. }
  44. }
  45. }
  46. c.ServeSuccessJSON(map[string]interface{}{
  47. "patients": patients,
  48. })
  49. break
  50. case 3:
  51. patients, _ := service.GetBatchInspectionProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  52. c.ServeSuccessJSON(map[string]interface{}{
  53. "patients": patients,
  54. })
  55. break
  56. }
  57. }