doctor_advice_api_controller.go 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package mobile_api_controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. )
  8. type DoctorAdviceAPIController struct {
  9. MobileBaseAPIAuthController
  10. }
  11. // /m/api/schedule/advices [get]
  12. // @param date:string (yyyy-mm-dd)
  13. // @param advice_type:int 1长期医嘱 3临时医嘱 其他:全部
  14. func (this *DoctorAdviceAPIController) ScheduleAdvices() {
  15. schedualDate := this.GetString("date")
  16. adviceType, _ := this.GetInt("advice_type")
  17. patientType, _ := this.GetInt("patient_type")
  18. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  19. adviceType = 0
  20. }
  21. if patientType != 1 && patientType != 2 {
  22. patientType = 0
  23. }
  24. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  25. if parseDateErr != nil {
  26. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27. return
  28. }
  29. adminInfo := this.GetMobileAdminUserInfo()
  30. orgID := adminInfo.Org.Id
  31. scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id)
  32. adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
  33. if err != nil {
  34. this.ErrorLog("获取排班信息失败:%v", err)
  35. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  36. } else {
  37. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  38. for _, schedual := range scheduals {
  39. if len(schedual.DoctorAdvices) > 0 {
  40. filtedScheduals = append(filtedScheduals, schedual)
  41. }
  42. }
  43. this.ServeSuccessJSON(map[string]interface{}{
  44. "scheduals": filtedScheduals,
  45. "adminUser": adminUser,
  46. })
  47. }
  48. }
  49. func (c *DoctorAdviceAPIController) GetAdviceConfigs() {
  50. advice_type, _ := c.GetInt64("type", 0)
  51. adminUserInfo := c.GetMobileAdminUserInfo()
  52. var drugs []models.DrugDic
  53. drugways, _, _ := service.GetDrugWayDics(adminUserInfo.Org.Id)
  54. efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.Org.Id)
  55. adviceTemplates, _ := service.FindAllAdviceTemplate(adminUserInfo.Org.Id, advice_type)
  56. c.ServeSuccessJSON(map[string]interface{}{
  57. "drugs": drugs,
  58. "drugways": drugways,
  59. "efs": efs,
  60. "advice_templates": adviceTemplates,
  61. })
  62. }