1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312 |
- package new_mobile_api_controllers
-
- import (
- "XT_New/controllers/mobile_api_controllers"
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "encoding/json"
- "fmt"
- "github.com/jinzhu/gorm"
- "reflect"
- "strconv"
- "strings"
- "time"
- )
-
- type StaffScheduleApiController struct {
- mobile_api_controllers.MobileBaseAPIAuthController
- }
-
- func (this *StaffScheduleApiController) GetMobileDoctorList() {
-
- orgId := this.GetMobileAdminUserInfo().Org.Id
- appId := this.GetMobileAdminUserInfo().App.Id
- staffList, err := service.GetDoctorList(orgId, appId)
- //获取所有的医生
- doctorList, err := service.GetAllDoctorList(orgId, appId)
-
- //获取所有的护士
- nurseList, err := service.GetAllNurseList(orgId, appId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "staffList": staffList,
- "doctorList": doctorList,
- "nurseList": nurseList,
- })
- }
-
- func (this *StaffScheduleApiController) GetMobileStaffScheduleList() {
-
- orgId := this.GetMobileAdminUserInfo().Org.Id
- //start_time, _ := this.GetInt64("start_time")
- //fmt.Println("staft_time", start_time)
- //end_time, _ := this.GetInt64("end_time")
- //fmt.Println("start_time",start_time)
- //fmt.Println("end_time",end_time)
- start_time_one := this.GetString("start_time_one")
- end_time_one := this.GetString("end_time_one")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- staffList, err := service.GetStaffScheduleList(orgId, startTime, endTime)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "staffList": staffList,
- })
- }
-
- func (this *StaffScheduleApiController) GetMobileNextWeekScheduleLIst() {
-
- orgId := this.GetMobileAdminUserInfo().Org.Id
- //start_time, _ := this.GetInt64("start_time")
- //end_time, _ := this.GetInt64("end_time")
- start_time_one := this.GetString("start_time_one")
- end_time_one := this.GetString("end_time_one")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
-
- staffList, err := service.GetStaffScheduleList(orgId, startTime, endTime)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "staffList": staffList,
- })
- }
-
- func (this *StaffScheduleApiController) GetScheduleByUserType() {
- doctor_id, _ := this.GetInt64("doctor_id")
- //start_time, _ := this.GetInt64("start_time")
- //end_time, _ := this.GetInt64("end_time")
- start_time_one := this.GetString("start_time_one")
- end_time_one := this.GetString("end_time_one")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- orgId := this.GetMobileAdminUserInfo().Org.Id
- staffList, err := service.GetScheduleByDoctorId(doctor_id, startTime, endTime, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "staffList": staffList,
- })
- }
-
- func (this *StaffScheduleApiController) GetSearchPatientByDoctorId() {
-
- orgId := this.GetMobileAdminUserInfo().Org.Id
- user_name := this.GetString("user_name")
- //start_time, _ := this.GetInt64("start_time")
- //end_time, _ := this.GetInt64("end_time")
-
- start_time_one := this.GetString("start_time_one")
- end_time_one := this.GetString("end_time_one")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_one+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- var endTime int64
- if len(end_time_one) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_one+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- endTime = theTime.Unix()
- }
- //
- staffList, err := service.ToSearchSeacheduleList(user_name, startTime, endTime, orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "staffList": staffList,
- })
- }
-
- func (this *StaffScheduleApiController) GetMobileSchedulelist() {
-
- orgId := this.GetMobileAdminUserInfo().Org.Id
- list, err := service.GetScheduleList(orgId)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *StaffScheduleApiController) GetMobileScheduleListTotal() {
-
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- orgId := this.GetMobileAdminUserInfo().Org.Id
-
- //统计班次
- scheudletotal, err := service.GetScheduleListTotal(orgId, start_time, end_time)
- //统计总工时
- list, err := service.GetTotalMinutes(orgId, start_time, end_time)
- //统计出勤天数
- workDay, err := service.GetTotalWorkDay(orgId, start_time, end_time)
- //统计缺勤天数
- noWorkDay, err := service.GetTotalNoWorkDay(orgId, start_time, end_time)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "scheudletotal": scheudletotal,
- "list": list,
- "workDay": workDay,
- "noWorkDay": noWorkDay,
- })
- }
-
- func (this *StaffScheduleApiController) GetMySchedule() {
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- orgId := this.GetMobileAdminUserInfo().Org.Id
- creator, _ := this.GetInt64("creator")
- schedule, err := service.GetMySchedule(start_time, end_time, orgId, creator)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- }
-
- func (this *StaffScheduleApiController) GetMobileChartList() {
-
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- orgId := this.GetMobileAdminUserInfo().Org.Id
- //统计总工时
- list, err := service.GetTotalMinutesOne(orgId, start_time, end_time)
- //统计出勤的总工时
- workDaylist, err := service.GetTotalMinutesTwo(orgId, start_time, end_time)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "workDaylist": workDaylist,
- })
- }
-
- func (this *StaffScheduleApiController) ToSearchMobileTotal() {
-
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- orgId := this.GetMobileAdminUserInfo().Org.Id
- keyword := this.GetString("keyword")
- //统计表
- scheduletotal, err := service.GetSearchScheduleListTotal(orgId, start_time, end_time, keyword)
- list, err := service.GeSearchtTotalMinutes(orgId, start_time, end_time, keyword)
- workDay, err := service.GetSearchWorkDay(orgId, start_time, end_time, keyword)
- noWorkDay, err := service.GetSearchWorkNoDay(orgId, start_time, end_time, keyword)
-
- //统计图
- chartTotalMinute, err := service.GetChartTotalMinutesOne(orgId, start_time, end_time, keyword)
- chartWorkDayMinute, err := service.GetChartTotalMinutesTwo(orgId, start_time, end_time, keyword)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "scheduletotal": scheduletotal,
- "list": list,
- "workDay": workDay,
- "noWorkDay": noWorkDay,
- "chartTotalMinute": chartTotalMinute,
- "chartWorkDayMinute": chartWorkDayMinute,
- })
- }
-
- func (this *StaffScheduleApiController) ChangeMobileOption() {
-
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- orgId := this.GetMobileAdminUserInfo().Org.Id
- doctor_type, _ := this.GetInt64("doctor_type")
- //统计图
- scheduletotal, err := service.ChagneScheduleListTotal(orgId, start_time, end_time, doctor_type)
- list, err := service.ChangeScheduleMinute(orgId, start_time, end_time, doctor_type)
- workday, err := service.ChangeWorkDay(orgId, start_time, end_time, doctor_type)
- worknoday, err := service.ChangeNoWorkDay(orgId, start_time, end_time, doctor_type)
-
- //统计表
- chartotalminute, err := service.ChartTotalMinute(orgId, start_time, end_time, doctor_type)
- chartworkdayminute, err := service.ChartWorkDayMinute(orgId, start_time, end_time, doctor_type)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "scheduletotal": scheduletotal,
- "list": list,
- "workday": workday,
- "worknoday": worknoday,
- "chartotalminute": chartotalminute,
- "chartworkdayminute": chartworkdayminute,
- })
- }
-
- func (this *StaffScheduleApiController) GetAllZone() {
-
- id := this.GetMobileAdminUserInfo().Org.Id
- zone, err := service.GetAllMobileZone(id)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- })
- }
-
- func (this *StaffScheduleApiController) GetAllZonePb() {
- orgid := this.GetMobileAdminUserInfo().Org.Id
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- zoneid, _ := this.GetInt64("zoneid")
- classtype, _ := this.GetInt64("classtype")
-
- // is_open, _ := this.GetInt64("is_open")
-
- //获取空床位的排班数据
- list, _ := service.GetPatientScheduleByPd(startTime, zoneid, orgid, classtype)
- if len(list) > 0 {
- for _, item := range list {
- for _, device := range item.DeviceNumber {
- item.TotalBed += 1
- for _, schedule := range device.Schedule {
- if schedule.ScheduleType == 1 {
- item.SwBed += 1
- }
- if schedule.ScheduleType == 2 {
- item.XwBed += 1
- }
- if schedule.ScheduleType == 3 {
- item.WsBed += 1
- }
- }
- }
- }
- }
-
- //针对百霖和贝尔
- if orgid == 10138 || orgid == 10278 || orgid == 3877 {
- //获取今日的排班数据
- list, _ := service.GetMobileScheduleListByScheduleDate(orgid, startTime)
- for _, item := range list {
- solution, _ := service.GetLongSolutionByModeId(item.PatientId, item.ModeId, item.UserOrgId)
- var str = solution.DialysisDialyszers + "/" + solution.DialysisIrrigation
- service.UpdateScheduleByDialysis(item.PatientId, item.ModeId, item.ScheduleDate, item.UserOrgId, str, item.ScheduleType)
- }
- }
-
- // stockType, _ := service.GetStockType(orgid)
- //zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
- // if err != nil {
- // this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- // return
- // }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": list,
- // "stockType": stockType,
- //"zonelist": zonelist,
- })
-
- // id := this.GetMobileAdminUserInfo().Org.Id
- // zone, err := service.GetAllMobileZonePb(id)
-
- // if err != nil {
- // this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- // return
- // }
- // this.ServeSuccessJSON(map[string]interface{}{
- // "zone": zone,
- // })
- }
-
- func (this *StaffScheduleApiController) GetPatientScheduleList() {
- orgid := this.GetMobileAdminUserInfo().Org.Id
- fmt.Println("orgid", orgid)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- start_time := this.GetString("start_time")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- zoneid, _ := this.GetInt64("zoneid")
- fmt.Println(zoneid)
- classtype, _ := this.GetInt64("classtype")
-
- is_open, _ := this.GetInt64("is_open")
-
- if is_open == 0 {
- //获取当天排班的病人情况
- schedule, err := service.GetPatientSchedule(startTime, zoneid, classtype, orgid)
-
- zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- "zonelist": zonelist,
- })
- }
- if is_open == 1 {
- //获取空床位的排班数据
- list, err := service.GetPatientScheduleByBed(startTime, zoneid, orgid, classtype)
- stockType, _ := service.GetStockType(orgid)
- zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": list,
- "stockType": stockType,
- "zonelist": zonelist,
- })
- }
- }
-
- func (this *StaffScheduleApiController) DeleteSchedule() {
- id, _ := this.GetInt64("id")
- org_id := this.GetMobileAdminUserInfo().Org.Id
- err := service.DeleteSchedule(id)
-
- if err == nil {
- schedule, _ := service.GetScheduleNight(org_id, id)
-
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- xtScheduleLog := models.XtScheduleLog{
- UserOrgId: org_id,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "手机端删除排班",
- Module: 5,
- AdminUserId: this.GetMobileAdminUserInfo().AdminUser.Id,
- }
- service.CreateScheduleLog(xtScheduleLog)
-
- //针对凤凰医院
- if org_id == 10579 || org_id == 10344 || org_id == 10206 {
- advice, _ := service.GetDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, org_id)
- if len(advice) > 0 {
- service.UpdateAdviceObj(schedule.PatientId, schedule.ScheduleDate, org_id)
- }
- }
-
- if org_id == 10206 {
- advice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, org_id)
- if len(advice) > 0 {
- service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, org_id)
- }
- }
- redis := service.RedisClient()
- //处方
- keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
-
- //医嘱
- keyTwo := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
- redis.Set(keySix, "", time.Second)
- keyThree := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
-
- keyFour := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
- redis.Set(keyFour, "", time.Second)
-
- keyFive := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
- redis.Set(keyFive, "", time.Second)
-
- keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
- redis.Set(keySeven, "", time.Second)
-
- defer redis.Close()
- fmt.Println(err)
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
-
- } else {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "删除失败")
- return
- }
- }
-
- func (this *StaffScheduleApiController) SearchPatient() {
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- keyword := this.GetString("keyword")
- fmt.Println(keyword)
- orgId := this.GetMobileAdminUserInfo().Org.Id
- start_time := this.GetString("start_time")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- schedule, err := service.GetSearchPatient(keyword, orgId, startTime)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- }
-
- func (this *StaffScheduleApiController) UpdatePatientScheduleById() {
-
- ids := this.GetString("ids")
- idSplit := strings.Split(ids, ",")
- var err error
- //查询患者信息
- list, _ := service.GetStaffScheduleById(idSplit)
- if len(list) > 0 {
- for index, _ := range list {
- fmt.Println("index2322332", index)
- schedule := models.XtSchedule{
- PatientId: list[0].PatientId,
- ModeId: list[0].ModeId,
- DialysisMachineName: list[0].DialysisMachineName,
- }
- xtSchedule := models.WeekSchedule{
- PatientId: list[1].PatientId,
- ModeId: list[1].ModeId,
- DialysisMachineName: list[1].DialysisMachineName,
- }
- err = service.UpdateStaffSchedule(list[1].ID, schedule)
- fmt.Println("errrrrrrr2323323232323", err)
- service.UpdateStaffScheduleOne(list[0].ID, xtSchedule)
- }
- }
- fmt.Println(err)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "切换成功",
- })
- }
- func (this *StaffScheduleApiController) UpdateDialysisPrescription() {
- patient_id, _ := this.GetInt64("patient_id")
- start_time, _ := this.GetInt64("start_time")
- mode_id, _ := this.GetInt64("mode_id")
- dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
- dialysis_irrigation := this.GetString("dialysis_irrigation")
- //更改透析模式
- _, errcode := service.GetDialyisSolution(patient_id, start_time)
- if errcode == gorm.ErrRecordNotFound {
- orgId := this.GetMobileAdminUserInfo().Org.Id
- prescription := models.DialysisPrescription{
- DialysisDialyszers: dialyzer_perfusion_apparatus,
- DialysisIrrigation: dialysis_irrigation,
- PatientId: patient_id,
- UserOrgId: orgId,
- Status: 1,
- RecordDate: start_time,
- CreatedTime: time.Now().Unix(),
- ModeId: mode_id,
- }
- err := service.CreateDialysisPrescription(&prescription)
-
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- } else if errcode == nil {
- prescription := models.DialysisPrescription{
- DialysisDialyszers: dialyzer_perfusion_apparatus,
- DialysisIrrigation: dialysis_irrigation,
- ModeId: mode_id,
- }
- err := service.UpdateDialysisPrescriptionOne(prescription, patient_id, start_time, mode_id)
- if err != nil {
- this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- }
- }
-
- func (this *StaffScheduleApiController) UpdateBloodScheduleMode() {
-
- id, _ := this.GetInt64("id")
- mode_id, _ := this.GetInt64("mode_id")
- schedule := models.XtSchedule{
- ModeId: mode_id,
- }
- service.UpdatedScheduleMode(schedule, id)
-
- orgId := this.GetMobileAdminUserInfo().Org.Id
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: orgId,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "手机端修改排班模式",
- Module: 5,
- AdminUserId: this.GetMobileAdminUserInfo().AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- }
-
- func (this *StaffScheduleApiController) UpdateBloodSchedule() {
-
- patient_id, _ := this.GetInt64("patient_id")
- mode_id, _ := this.GetInt64("mode_id")
- schedule_type, _ := this.GetInt64("schedule_type")
- start_time, _ := this.GetInt64("start_time")
- bed_id, _ := this.GetInt64("bed_id")
- orgid := this.GetMobileAdminUserInfo().Org.Id
- //更改排班
- schedule := models.XtSchedule{
- ScheduleType: schedule_type,
- ModeId: mode_id,
- }
-
- //查询该床位该班次是否存在排班
- _, errschedulecode := service.GetPatientScheduleIsExist(start_time, schedule_type, bed_id, orgid)
- if errschedulecode == gorm.ErrRecordNotFound {
- service.UpdatedSchedule(schedule, patient_id, start_time, schedule_type, bed_id)
-
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: orgid,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "手机修改排班班次",
- Module: 5,
- AdminUserId: this.GetMobileAdminUserInfo().AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
- this.ServeSuccessJSON(map[string]interface{}{
- "msgerr": "保存成功",
- })
- } else if errschedulecode == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "msgerr": "排班已存在",
- })
- }
-
- }
-
- func (this *StaffScheduleApiController) GetSchedulePatient() {
-
- schedule, _ := this.GetInt64("schedule", 0) //1已2未
- contagion, _ := this.GetInt64("contagion", 0)
- keywords := this.GetString("keywords", "")
- adminInfo := this.GetMobileAdminUserInfo()
- thisTime := time.Now()
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- thisWeekEnd := 7 - weekDay
- weekStartPoint := thisWeekEnd - 6
- weekStartDay := thisTime.AddDate(0, 0, weekStartPoint)
- weekEndPoint := thisWeekEnd + 7
- weekEndDay := thisTime.AddDate(0, 0, weekEndPoint)
- fmt.Println(weekStartPoint, weekStartDay, weekEndPoint, weekEndDay)
-
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
- fmt.Println(weekStartTime, weekEndTime)
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
- weekStart := theStarTime.Unix()
- weekEnd := theEndTime.Unix()
- patients, _ := service.GetPatientWithScheduleAndSolutionTwo(adminInfo.Org.Id, keywords, weekStart, weekEnd, schedule, contagion)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- })
- return
- }
-
- func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
-
- patientID, _ := c.GetInt64("patient_id", 0)
- if patientID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patientID)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var schedule models.Schedule
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleDate, _ := dataBody["schedule_date"].(string)
- if len(scheduleDate) == 0 {
- utils.ErrorLog("len(schedule_date) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleDate = theTime.Unix()
-
- timeNow := time.Now().Format("2006-01-02")
- if timeNow > scheduleDate {
- utils.ErrorLog(timeNow)
- utils.ErrorLog(scheduleDate)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
-
- if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleType := int64(dataBody["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(dataBody["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
- utils.ErrorLog("partition_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(dataBody["partition_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("partitionId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
- utils.ErrorLog("schedule_week")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleWeek := int64(dataBody["schedule_week"].(float64))
- if scheduleWeek < 1 || scheduleWeek > 7 {
- utils.ErrorLog("scheduleWeek < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleWeek = scheduleWeek
-
- if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(dataBody["mode_id"].(float64))
- if modeId < 1 && modeId > 14 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ModeId = modeId
-
- schedule.PatientId = patientID
- schedule.CreatedTime = time.Now().Unix()
- schedule.UpdatedTime = time.Now().Unix()
- schedule.Status = 1
- schedule.IsExport = 6000
- schedule.UserOrgId = adminUserInfo.Org.Id
-
- bed, _ := service.GetDeviceNumberByID(adminUserInfo.Org.Id, schedule.BedId)
- if bed == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
- return
- }
- if bed.ZoneID != schedule.PartitionId {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
- return
- }
-
- scheduleDateStart := scheduleDate + " 00:00:00"
- scheduleDateEnd := scheduleDate + " 23:59:59"
- timeLayout = "2006-01-02 15:04:05"
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
- startTime := theStartTime.Unix()
- endTime := theEndTime.Unix()
-
- //一天只有排班一次
- daySchedule, err := service.GetDaySchedule(adminUserInfo.Org.Id, startTime, endTime, patientID)
- if daySchedule.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
- return
- }
-
- //同天同位置只能排一个
- pointSchedule, err := service.GetPointSchedule(adminUserInfo.Org.Id, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if pointSchedule.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
- return
- }
-
- redis := service.RedisClient()
- err = service.CreateScheduleTwo(&schedule)
- service.UpdateRepeatSchStatus(adminUserInfo.Org.Id, schedule.ScheduleDate)
- key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(key, "", time.Second)
- defer redis.Close()
- fmt.Println(err)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
- return
- }
- schedule.Patient = patientInfo.Name
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": schedule,
- })
- return
-
- }
-
- func (c *StaffScheduleApiController) GetSolutionSchedule() {
-
- orgId := c.GetMobileAdminUserInfo().Org.Id
- scheduleDate := c.GetString("start_time")
- zoneid, _ := c.GetInt64("zoneid")
- classtype, _ := c.GetInt64("classtype")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
- schedule, _ := service.GetSolutionScheduleBySchedule(orgId, zoneid, classtype, theTime.Unix())
-
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- }
-
- func (c *StaffScheduleApiController) GetAllBedList() {
-
- orgId := c.GetMobileAdminUserInfo().Org.Id
- partition_id, _ := c.GetInt64("partition_id")
- list, _ := service.GetAllBedNumberTen(orgId, partition_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (c *StaffScheduleApiController) ChangeScheduleById() {
-
- id, _ := c.GetInt64("id")
- mode_id, _ := c.GetInt64("mode_id")
- schedule_date, _ := c.GetInt64("schedule_date")
- patient_id, _ := c.GetInt64("patient_id")
- org_id := c.GetMobileAdminUserInfo().Org.Id
- err := service.ChangeScheduleById(id, mode_id)
- fmt.Println("err", err)
- err = service.ChangeDialysisSolution(patient_id, schedule_date, org_id, mode_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- }
-
- func (c *StaffScheduleApiController) ChangeScheduleType() {
- schedule_type, _ := c.GetInt64("schedule_type")
- schedule_date, _ := c.GetInt64("schedule_date")
- patient_id, _ := c.GetInt64("patient_id")
- bed_id, _ := c.GetInt64("bed_id")
- //schedule_week, _ := c.GetInt64("schedule_week")
- mode_id, _ := c.GetInt64("mode_id")
- id, _ := c.GetInt64("id")
- org_id := c.GetMobileAdminUserInfo().Org.Id
- //查询该班次该床位是否已经存在患者
- schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
- //查询该床位所属分区
- //numberlist, _ := service.GetPartionId(bed_id, org_id)
- //存在
- if schedule.ID > 0 {
- order, _ := service.GetDialysisOrder(schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
- if order.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSchedule)
- return
- }
- //调换位置
- sch := models.Schedule{
- PatientId: schedule.PatientId,
- ModeId: schedule.ModeId,
- }
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(org_id, sch.PatientId, sch.ModeId)
- filedRecordOne, _ := service.FindFiledBy(org_id, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(org_id, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(org_id, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "*" + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "*" + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- sch.DialysisMachineName = DialysisMachineName
- schedu := models.Schedule{
- PatientId: patient_id,
- ModeId: mode_id,
- }
- var DialysisMachineName1 string
- so1, _ := service.GetDialysisSolutionTwo(org_id, schedu.PatientId, schedu.ModeId)
- filedRecordOne1, _ := service.FindFiledBy(org_id, "透析器")
- filedRecordTwo1, _ := service.FindFiledBy(org_id, "灌流器")
- filedRecordThree1, _ := service.FindFiledBy(org_id, "透析器/灌流器")
- if filedRecordOne1.IsShow == 1 {
- DialysisMachineName1 = so1.DialysisDialyszers
- }
- if filedRecordThree1.IsShow == 1 {
- if len(DialysisMachineName1) > 0 {
- DialysisMachineName1 = DialysisMachineName1 + "*" + so1.DialyzerPerfusionApparatus
- } else {
- DialysisMachineName1 = so1.DialyzerPerfusionApparatus
- }
- }
- if filedRecordTwo1.IsShow == 1 {
- if len(DialysisMachineName1) > 0 {
- DialysisMachineName1 = DialysisMachineName1 + "*" + so1.DialysisIrrigation
- } else {
- DialysisMachineName1 = so1.DialysisIrrigation
- }
- }
- schedu.DialysisMachineName = DialysisMachineName1
- err := service.UpdateScheduleById(schedule.ID, schedu, id, sch)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- } else {
- xtSchedule := models.Schedule{
- ScheduleDate: schedule_date,
- ScheduleType: schedule_type,
- PatientId: patient_id,
- UserOrgId: org_id,
- }
-
- err := service.ChangeScheduleClass(xtSchedule)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- }
- func (c *StaffScheduleApiController) ChangeScheduleBed() {
- schedule_type, _ := c.GetInt64("schedule_type")
- schedule_date, _ := c.GetInt64("schedule_date")
- patient_id, _ := c.GetInt64("patient_id")
- bed_id, _ := c.GetInt64("bed_id")
- schedule_week, _ := c.GetInt64("schedule_week")
- mode_id, _ := c.GetInt64("mode_id")
- id, _ := c.GetInt64("id")
- org_id := c.GetMobileAdminUserInfo().Org.Id
-
- temp_schedule, _ := service.GetScheduleByClassTypeTwo(schedule_type, schedule_date, patient_id, org_id)
- id = temp_schedule.ID
-
- //查询该班次该床位是否已经存在患者
- schedule, _ := service.GetScheduleByClassType(schedule_type, schedule_date, bed_id, org_id)
- //查询该床位所属分区
- numberlist, _ := service.GetPartionId(bed_id, org_id)
- //存在
- if schedule.ID > 0 {
-
- order, _ := service.GetDialysisOrder(schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
- if order.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSchedule)
- return
- }
- //调换位置
- sch := models.Schedule{
- PatientId: schedule.PatientId,
- ModeId: schedule.ModeId,
- DialysisMachineName: schedule.DialysisMachineName,
- }
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(org_id, sch.PatientId, sch.ModeId)
- filedRecordOne, _ := service.FindFiledBy(org_id, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(org_id, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(org_id, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "-" + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "-" + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- sch.DialysisMachineName = DialysisMachineName
-
- schedu := models.Schedule{
- PatientId: patient_id,
- ModeId: mode_id,
- DialysisMachineName: schedule.DialysisMachineName,
- }
- var DialysisMachineName1 string
- so1, _ := service.GetDialysisSolutionTwo(org_id, schedu.PatientId, schedu.ModeId)
- filedRecordOne1, _ := service.FindFiledBy(org_id, "透析器")
- filedRecordTwo1, _ := service.FindFiledBy(org_id, "灌流器")
- filedRecordThree1, _ := service.FindFiledBy(org_id, "透析器/灌流器")
-
- if filedRecordOne1.IsShow == 1 {
- DialysisMachineName1 = so1.DialysisDialyszers
- }
- if filedRecordThree1.IsShow == 1 {
- if len(DialysisMachineName1) > 0 {
- DialysisMachineName1 = DialysisMachineName1 + "-" + so1.DialyzerPerfusionApparatus
- } else {
- DialysisMachineName1 = so1.DialyzerPerfusionApparatus
- }
- }
- if filedRecordTwo1.IsShow == 1 {
- if len(DialysisMachineName1) > 0 {
- DialysisMachineName1 = DialysisMachineName1 + "-" + so1.DialysisIrrigation
- } else {
- DialysisMachineName1 = so1.DialysisIrrigation
- }
- }
- schedu.DialysisMachineName = DialysisMachineName1
- err := service.UpdateScheduleById(schedule.ID, schedu, id, sch)
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: org_id,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "手机端修改调班",
- Module: 4,
- AdminUserId: c.GetMobileAdminUserInfo().AdminUser.Id,
- }
- service.UpdateRepeatSchStatus(org_id, schedule_date)
- service.CreateScheduleLog(scheduleLog)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
-
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- } else {
- var str string
- //查找该机构用的是什么透析器
- filedConfig, _ := service.GetFiledConfig(org_id)
- if filedConfig.ID > 0 {
- solutionType, _ := service.GetLastDialysisSolutionType(org_id, patient_id, mode_id)
- str = solutionType.DialyzerPerfusionApparatus
- } else {
- solutionType, _ := service.GetLastDialysisSolutionType(org_id, patient_id, mode_id)
- str = solutionType.DialysisDialyszers + "/" + solutionType.DialysisIrrigation
- }
- xtSchedule := models.Schedule{
- UserOrgId: org_id,
- PartitionId: numberlist.ZoneId,
- BedId: bed_id,
- PatientId: patient_id,
- ScheduleDate: schedule_date,
- ScheduleType: schedule_type,
- ScheduleWeek: schedule_week,
- ModeId: mode_id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: 0,
- IsExport: 20000,
- DialysisMachineName: str,
- }
- var err error
- err = service.CreateSchedule(&xtSchedule, id)
- service.UpdateRepeatSchStatus(org_id, schedule_date)
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: org_id,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "手机端新建调班",
- Module: 1,
- AdminUserId: c.GetMobileAdminUserInfo().AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
- }
-
- func (c *StaffScheduleApiController) UpdateMobileSchedule() {
-
- id_one, _ := c.GetInt64("id_one")
- id_two, _ := c.GetInt64("id_two")
- schedule_date := c.GetString("schedule_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
-
- mode_id, _ := c.GetInt64("mode_id")
- bed_id, _ := c.GetInt64("bed_id")
- zone_id, _ := c.GetInt64("zone_id")
- schedule_type, _ := c.GetInt64("schedule_type")
- orgId := c.GetMobileAdminUserInfo().Org.Id
-
- schedule, _ := service.GetSchedulePatientIdByPatient(id_one, startTime.Unix(), orgId)
-
- if schedule.ID > 0 {
- service.UpdateMobileSchedule(id_two, mode_id, bed_id, zone_id, schedule_type, schedule.ID)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
|