his_print_api_controller.go 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "github.com/astaxie/beego"
  7. "strings"
  8. "time"
  9. )
  10. type HisPrintApiController struct {
  11. BaseAuthAPIController
  12. }
  13. func HisPrintApiRegistRouters() {
  14. beego.Router("/api/his/prescription/print", &HisPrintApiController{}, "get:GetBatchHisPrescriptionData")
  15. beego.Router("/api/his/prescription/list", &HisPrintApiController{}, "get:GetUnChargePrescriptionList")
  16. beego.Router("/api/his/prescription/summary", &HisPrintApiController{}, "get:GetUnChargePrescriptionSummary")
  17. beego.Router("/api/his/label/create", &HisPrintApiController{}, "get:CreateLablePrint")
  18. beego.Router("/api/his/label/get", &HisPrintApiController{}, "get:GetLablePrint")
  19. //beego.Router("/api/his/checkprescription/print", &HisPrintApiController{}, "get:GetBatchCheckHisPrescriptionData")
  20. }
  21. //func (c *HisPrintApiController) GetBatchCheckHisPrescriptionData() {
  22. // record_date := c.GetString("record_date")
  23. // patient_ids := c.GetString("patient_ids")
  24. // timeLayout := "2006-01-02"
  25. // loc, _ := time.LoadLocation("Local")
  26. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  27. // if err != nil {
  28. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  29. // return
  30. // }
  31. // recordDateTime := theTime.Unix()
  32. // adminInfo := c.GetAdminUserInfo()
  33. // ids := strings.Split(patient_ids, ",")
  34. //
  35. // //var newPatients []*models.PrintPatient
  36. //
  37. // patients, _ := service.GetBatchInspectionProjectHisPrescriptionTwo(ids, recordDateTime, adminInfo.CurrentOrgId)
  38. //
  39. // c.ServeSuccessJSON(map[string]interface{}{
  40. // "patients": patients,
  41. // })
  42. // break
  43. //}
  44. func (c *HisPrintApiController) GetLablePrint() {
  45. patient_id, _ := c.GetInt64("patient_id")
  46. ids := c.GetString("ids")
  47. record_date := c.GetString("record_date")
  48. labels, _ := service.GetLabelPrint(ids, c.GetAdminUserInfo().CurrentOrgId, record_date, patient_id)
  49. c.ServeSuccessJSON(map[string]interface{}{
  50. "labels": labels,
  51. })
  52. return
  53. }
  54. func (c *HisPrintApiController) CreateLablePrint() {
  55. patient_id, _ := c.GetInt64("patient_id")
  56. isCombinationPrint, _ := c.GetBool("is_combination_print")
  57. team_ids := c.GetString("team_ids")
  58. ids := c.GetString("ids")
  59. record_date := c.GetString("record_date")
  60. doctor_id, _ := c.GetInt64("doctor_id")
  61. project_ids := c.GetString("project_ids")
  62. is_team, _ := c.GetInt64("is_team")
  63. var hlpsi models.HisLabelPrintStatusInfo
  64. hlpsi.Status = 1
  65. hlpsi.UserOrgId = c.GetAdminUserInfo().CurrentOrgId
  66. hlpsi.PatientId = patient_id
  67. hlpsi.RecordDate = record_date
  68. hlpsi.Mtime = time.Now().Unix()
  69. hlpsi.Ctime = time.Now().Unix()
  70. hlpsi.ItemIds = team_ids
  71. hlpsi.ProjectIds = project_ids
  72. hlpsi.Ids = ids
  73. hlpsi.DoctorId = doctor_id
  74. hlpsi.IsTeam = is_team
  75. hlpsi.IsPrint = 1
  76. if isCombinationPrint == true {
  77. hlpsi.IsCombinationPrint = 1
  78. } else {
  79. hlpsi.IsCombinationPrint = 0
  80. }
  81. service.CreateLabelPrint(&hlpsi)
  82. c.ServeSuccessJSON(map[string]interface{}{
  83. "msg": "保存成功",
  84. "hlpsi": hlpsi,
  85. })
  86. return
  87. }
  88. func (c *HisPrintApiController) GetUnChargePrescriptionList() {
  89. patient_id, _ := c.GetInt64("patient_id")
  90. recordDateTime, _ := c.GetInt64("record_date")
  91. admin_user_id, _ := c.GetInt64("admin_user_id")
  92. p_type, _ := c.GetInt64("p_type", 0)
  93. admin := c.GetAdminUserInfo()
  94. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  95. record, _ := service.GetLastInHospitalRecord(patient_id, c.GetAdminUserInfo().CurrentOrgId)
  96. var prescriptions []*models.HisPrescription
  97. prescriptions, _ = service.GetUnChargeHisPrescriptionTen(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
  98. admin_info, _ := service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
  99. //获取所有科室信息
  100. c.ServeSuccessJSON(map[string]interface{}{
  101. "xt_info": xt_patient_info,
  102. "prescription": prescriptions,
  103. "record": record,
  104. "admin_info": admin_info,
  105. })
  106. return
  107. }
  108. func (c *HisPrintApiController) GetUnChargePrescriptionSummary() {
  109. patient_id, _ := c.GetInt64("patient_id")
  110. record_date, _ := c.GetInt64("record_date")
  111. admin_user_id, _ := c.GetInt64("admin_user_id")
  112. p_type, _ := c.GetInt64("p_type", 0)
  113. //timeLayout := "2006-01-02"
  114. //loc, _ := time.LoadLocation("Local")
  115. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  116. //if err != nil {
  117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. // return
  119. //}
  120. //recordDateTime := theTime.Unix()
  121. admin := c.GetAdminUserInfo()
  122. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  123. record, _ := service.GetLastInHospitalRecord(patient_id, c.GetAdminUserInfo().CurrentOrgId)
  124. var prescriptions []*models.HisPrescription
  125. prescriptions, _ = service.GetUnChargeHisPrescriptionTen(admin.CurrentOrgId, patient_id, record_date, p_type)
  126. //doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
  127. service.GetAdminUserRole(admin_user_id, c.GetAdminUserInfo().CurrentOrgId)
  128. //获取所有科室信息
  129. c.ServeSuccessJSON(map[string]interface{}{
  130. "xt_info": xt_patient_info,
  131. "prescription": prescriptions,
  132. "record": record,
  133. "admin_info": admin_user_id,
  134. })
  135. return
  136. }
  137. func (c *HisPrintApiController) GetBatchHisPrescriptionData() {
  138. record_date := c.GetString("record_date")
  139. patient_ids := c.GetString("patient_ids")
  140. print_type, _ := c.GetInt64("type")
  141. timeLayout := "2006-01-02"
  142. loc, _ := time.LoadLocation("Local")
  143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  144. if err != nil {
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  146. return
  147. }
  148. recordDateTime := theTime.Unix()
  149. adminInfo := c.GetAdminUserInfo()
  150. ids := strings.Split(patient_ids, ",")
  151. switch print_type {
  152. case 1:
  153. patients, _ := service.GetBatchDrugHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  154. c.ServeSuccessJSON(map[string]interface{}{
  155. "patients": patients,
  156. })
  157. break
  158. case 2:
  159. //var newPatients []*models.PrintPatient
  160. patients, _ := service.GetBatchProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  161. //for _, item := range patients {
  162. // for _, subItem := range item.HisPrintPrescription {
  163. // for _, subItemTwo := range subItem.HisPrescriptionProject {
  164. // if subItemTwo.HisProject.CostClassify != 3 {
  165. //
  166. // }
  167. // }
  168. // }
  169. //}
  170. c.ServeSuccessJSON(map[string]interface{}{
  171. "patients": patients,
  172. })
  173. break
  174. case 3:
  175. var newPatients []*models.PrintPatient
  176. var newPatientsTwo []*models.PrintPatient
  177. patients, _ := service.GetBatchInspectionProjectHisPrescription(ids, recordDateTime, adminInfo.CurrentOrgId)
  178. for _, item := range patients {
  179. var newPatient *models.PrintPatient
  180. newPatient = item
  181. for index, subItem := range item.HisPrintPrescription {
  182. if index > 0 {
  183. item.HisPrintPrescription[0].HisPrescriptionProject = append(item.HisPrintPrescription[0].HisPrescriptionProject, subItem.HisPrescriptionProject...)
  184. }
  185. }
  186. newPatients = append(newPatients, newPatient)
  187. }
  188. for _, item := range patients {
  189. var newPatient *models.PrintPatient
  190. newPatient = item
  191. if len(item.HisPrintPrescription) > 0 {
  192. newPatient.NewHisPrintPrescription = append(newPatient.NewHisPrintPrescription, item.HisPrintPrescription[0])
  193. newPatientsTwo = append(newPatientsTwo, newPatient)
  194. }
  195. }
  196. c.ServeSuccessJSON(map[string]interface{}{
  197. "patients": newPatientsTwo,
  198. })
  199. break
  200. }
  201. }