zuobiao_api_controller.go 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "github.com/astaxie/beego"
  7. "time"
  8. )
  9. type ZuobiaoApiController struct {
  10. BaseAuthAPIController
  11. }
  12. func ZuobiaoApiRegistRouters() {
  13. beego.Router("/api/zuobiaodetail/list", &ZuobiaoApiController{}, "get:GetHisZuoBiaoDetailPatientList")
  14. beego.Router("/api/zuobiaodetail/info", &ZuobiaoApiController{}, "get:GetHisZuoBiaoDetailInfo")
  15. beego.Router("/api/uploadzuobiaodetail/info", &ZuobiaoApiController{}, "get:GetUploadHisZuoBiaoDetailInfo")
  16. beego.Router("/api/zuobiaomonthdetail/info", &ZuobiaoApiController{}, "get:GetHisZuoBiaoMonthDetailInfo")
  17. }
  18. func (c *ZuobiaoApiController) GetHisZuoBiaoDetailPatientList() {
  19. record_date := c.GetString("record_date")
  20. timeLayout := "2006-01-02"
  21. loc, _ := time.LoadLocation("Local")
  22. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  23. if err != nil {
  24. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25. return
  26. }
  27. var patients []*service.NewTempPatients
  28. var patienttwos []*service.NewTempPatients
  29. recordDateTime := theTime.Unix()
  30. adminInfo := c.GetAdminUserInfo()
  31. UnuploadTempPatients, _ := service.GetNewAllUnHisZuoBiaoPatientList(adminInfo.CurrentOrgId, recordDateTime)
  32. uploadTempPatients, _ := service.GetNewAllChargeHisZuoBiaoPatientList(adminInfo.CurrentOrgId, recordDateTime)
  33. uploadPatient, _ := service.GetUploadHisZuoBiaoPatientList(adminInfo.CurrentOrgId, recordDateTime)
  34. for _, item := range UnuploadTempPatients {
  35. //if len(item.HisPrescription) > 0 {
  36. patients = append(patients, item)
  37. //}
  38. }
  39. for _, item := range uploadTempPatients {
  40. if len(item.HisPrescription) > 0 {
  41. patienttwos = append(patienttwos, item)
  42. }
  43. }
  44. c.ServeSuccessJSON(map[string]interface{}{
  45. "list": patients,
  46. "list_two": patienttwos,
  47. "upload_list": uploadPatient,
  48. "upload_num": len(uploadPatient),
  49. "un_upload_num": len(patients),
  50. })
  51. }
  52. func (c *ZuobiaoApiController) GetHisZuoBiaoDetailInfo() {
  53. record_date := c.GetString("record_date")
  54. is_upload, _ := c.GetInt64("is_upload")
  55. patient_id, _ := c.GetInt64("id")
  56. start_time_str := c.GetString("start_time")
  57. end_time_str := c.GetString("end_time")
  58. timeLayout := "2006-01-02"
  59. loc, _ := time.LoadLocation("Local")
  60. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  61. if err != nil {
  62. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  63. return
  64. }
  65. recordDateTime := theTime.Unix()
  66. adminInfo := c.GetAdminUserInfo()
  67. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  68. if err != nil {
  69. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  70. return
  71. }
  72. recordStartTime := theStartTime.Unix()
  73. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  74. if err != nil {
  75. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  76. return
  77. }
  78. recordEndTime := theEndTime.Unix()
  79. var prescriptions []*models.HisPrescription
  80. if is_upload == 1 { //未上传
  81. prescriptions, _ = service.GetUnUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  82. } else if is_upload == 2 { //已上传
  83. prescriptions, _ = service.GetUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  84. }
  85. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  86. var monthPrescriptions []*models.HisPrescription
  87. if is_upload == 1 {
  88. monthPrescriptions, _ = service.GetMonthUnUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  89. } else if is_upload == 2 {
  90. monthPrescriptions, _ = service.GetMonthUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  91. }
  92. prescription_info, _ := service.GetZuoBiaoPrescriptionInfo(c.GetAdminUserInfo().CurrentOrgId, patient.ID)
  93. c.ServeSuccessJSON(map[string]interface{}{
  94. "prescription": prescriptions,
  95. "month_prescriptions": monthPrescriptions,
  96. "patient": patient,
  97. "prescription_info": prescription_info,
  98. })
  99. }
  100. func (c *ZuobiaoApiController) GetUploadHisZuoBiaoDetailInfo() {
  101. id, _ := c.GetInt64("id")
  102. _, zuobiao_info := service.GetZuobiaoInfoById(id)
  103. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, zuobiao_info.PatientId)
  104. order, _ := service.GetHisOrderByID(zuobiao_info.Oid)
  105. prescription, _ := service.GetHisPrescriptionByBatchNumber(c.GetAdminUserInfo().CurrentOrgId, order.Number)
  106. prescription_info, _ := service.GetZuoBiaoPrescriptionInfo(c.GetAdminUserInfo().CurrentOrgId, patient.ID)
  107. c.ServeSuccessJSON(map[string]interface{}{
  108. "month_prescriptions": prescription,
  109. "patient": patient,
  110. "zuobiao_info": zuobiao_info,
  111. "prescription_info": prescription_info,
  112. })
  113. }
  114. func (c *ZuobiaoApiController) GetHisZuoBiaoMonthDetailInfo() {
  115. patient_id, _ := c.GetInt64("id")
  116. is_upload, _ := c.GetInt64("is_upload")
  117. //patient_id, _ := c.GetInt64("patient_id")
  118. start_time_str := c.GetString("start_time")
  119. end_time_str := c.GetString("end_time")
  120. //record, _ := service.GetInHospitalRecord(id)
  121. timeLayout := "2006-01-02"
  122. loc, _ := time.LoadLocation("Local")
  123. adminInfo := c.GetAdminUserInfo()
  124. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  125. if err != nil {
  126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  127. return
  128. }
  129. recordStartTime := theStartTime.Unix()
  130. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  131. if err != nil {
  132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  133. return
  134. }
  135. recordEndTime := theEndTime.Unix()
  136. //var prescriptions []*models.HisPrescription
  137. var monthPrescriptions []*models.HisPrescription
  138. if is_upload == 1 {
  139. monthPrescriptions, _ = service.GetMonthUnUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  140. } else if is_upload == 2 {
  141. monthPrescriptions, _ = service.GetMonthUploadHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  142. } else {
  143. monthPrescriptions, _ = service.GetAllMonthHisZuoBiaoPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  144. }
  145. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  146. c.ServeSuccessJSON(map[string]interface{}{
  147. "month_prescriptions": monthPrescriptions,
  148. //"his_info": record,
  149. "patient": patient,
  150. })
  151. }