doctor_advice_api_controller.go 2.7KB

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