1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package mobile_api_controllers
-
- import (
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- )
-
- type DoctorAdviceAPIController struct {
- MobileBaseAPIAuthController
- }
-
- // /m/api/schedule/advices [get]
- // @param date:string (yyyy-mm-dd)
- // @param advice_type:int 1长期医嘱 3临时医嘱 其他:全部
- func (this *DoctorAdviceAPIController) ScheduleAdvices() {
- schedualDate := this.GetString("date")
- adviceType, _ := this.GetInt("advice_type")
- patientType, _ := this.GetInt("patient_type")
-
- if adviceType != 1 && adviceType != 3 && adviceType != 2 {
- adviceType = 0
- }
-
- if patientType != 1 && patientType != 2 {
-
- patientType = 0
- }
-
- date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
- if parseDateErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminInfo := this.GetMobileAdminUserInfo()
- orgID := adminInfo.Org.Id
-
- scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id)
- adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
- if err != nil {
- this.ErrorLog("获取排班信息失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- } else {
- filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
- for _, schedual := range scheduals {
- if len(schedual.DoctorAdvices) > 0 {
- filtedScheduals = append(filtedScheduals, schedual)
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "scheduals": filtedScheduals,
-
- "adminUser": adminUser,
- })
- }
- }
-
- func (c *DoctorAdviceAPIController) GetAdviceConfigs() {
- advice_type, _ := c.GetInt64("type", 0)
- adminUserInfo := c.GetMobileAdminUserInfo()
- var drugs []models.DrugDic
- drugways, _, _ := service.GetDrugWayDics(adminUserInfo.Org.Id)
- efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.Org.Id)
- adviceTemplates, _ := service.FindAllAdviceTemplate(adminUserInfo.Org.Id, advice_type)
- c.ServeSuccessJSON(map[string]interface{}{
- "drugs": drugs,
- "drugways": drugways,
- "efs": efs,
- "advice_templates": adviceTemplates,
- })
- }
|