|
@@ -86,6 +86,7 @@ func ScheduleApiRegistRouters() {
|
86
|
86
|
|
87
|
87
|
beego.Router("/api/sch/exchange", &ScheduleApiController{}, "Get:ExchangeSch")
|
88
|
88
|
beego.Router("/api/sch/coversch", &ScheduleApiController{}, "Get:CoverSch")
|
|
89
|
+ beego.Router("/api/schedule/delete_two", &ScheduleApiController{}, "Delete:DeleteScheduleTwo")
|
89
|
90
|
|
90
|
91
|
}
|
91
|
92
|
func (c *ScheduleApiController) CoverSch() {
|
|
@@ -103,16 +104,13 @@ func (c *ScheduleApiController) CoverSch() {
|
103
|
104
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderTwo)
|
104
|
105
|
return
|
105
|
106
|
}
|
106
|
|
- count, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch_two.ScheduleDate, sch_two.PatientId)
|
107
|
|
- if count > 1 {
|
108
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
109
|
|
- return
|
110
|
|
- }
|
111
|
|
-
|
112
|
|
- count1, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch_two.ScheduleDate, sch.PatientId)
|
113
|
|
- if count1 > 0 {
|
114
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
115
|
|
- return
|
|
107
|
+ //替换者和被替换的排班日期不是同一天,则进行一个患者一天不能有多个排班提醒
|
|
108
|
+ if sch.ScheduleDate != sch_two.ScheduleDate && sch.PatientId != sch_two.PatientId {
|
|
109
|
+ count, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch_two.ScheduleDate, sch.PatientId)
|
|
110
|
+ if count > 0 {
|
|
111
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
|
112
|
+ return
|
|
113
|
+ }
|
116
|
114
|
}
|
117
|
115
|
|
118
|
116
|
var new_sch models.Schedule
|
|
@@ -148,16 +146,21 @@ func (c *ScheduleApiController) ExchangeSch() {
|
148
|
146
|
return
|
149
|
147
|
}
|
150
|
148
|
|
151
|
|
- //count1, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId,sch.ScheduleDate,sch.PatientId)
|
152
|
|
- //if count1 > 0 {
|
153
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
154
|
|
- // return
|
155
|
|
- //}
|
156
|
|
- //count2, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId,sch_two.ScheduleDate,sch_two.PatientId)
|
157
|
|
- //if count2 > 0 {
|
158
|
|
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
159
|
|
- // return
|
160
|
|
- //}
|
|
149
|
+ //替换者和被替换的排班日期不是同一天,则进行一个患者一天不能有多个排班提醒
|
|
150
|
+ if sch.ScheduleDate != sch_two.ScheduleDate && sch.PatientId != sch_two.PatientId {
|
|
151
|
+ count, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch_two.ScheduleDate, sch.PatientId)
|
|
152
|
+ if count > 0 {
|
|
153
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
|
154
|
+ return
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ count1, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch.ScheduleDate, sch_two.PatientId)
|
|
158
|
+ if count1 > 0 {
|
|
159
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
|
|
160
|
+ return
|
|
161
|
+ }
|
|
162
|
+ }
|
|
163
|
+
|
161
|
164
|
service.UpdateScheduleThree(sch, sch_two)
|
162
|
165
|
c.ServeSuccessJSON(map[string]interface{}{
|
163
|
166
|
"msg": "交换成功",
|
|
@@ -651,6 +654,13 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
|
651
|
654
|
sch_id := int64(items["sch_id"].(float64))
|
652
|
655
|
if sch_id > 0 { //修改排班信息
|
653
|
656
|
schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
|
|
657
|
+
|
|
658
|
+ order, _ := service.GetDialysisOrderByPatientAndBed(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.BedId, schedule.PatientId)
|
|
659
|
+ if order.ID > 0 {
|
|
660
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysis)
|
|
661
|
+ return
|
|
662
|
+ }
|
|
663
|
+
|
654
|
664
|
schedule.Status = 0
|
655
|
665
|
service.SaveSch(schedule)
|
656
|
666
|
}
|
|
@@ -1001,6 +1011,10 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
|
1001
|
1011
|
HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
|
1002
|
1012
|
|
1003
|
1013
|
}
|
|
1014
|
+ } else {
|
|
1015
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1016
|
+ "msg": "保存成功",
|
|
1017
|
+ })
|
1004
|
1018
|
}
|
1005
|
1019
|
}
|
1006
|
1020
|
|
|
@@ -4497,3 +4511,79 @@ func RemoveRepeatedScheduleTemplate(arr []*models.VmPatientScheduleTemplateItem)
|
4497
|
4511
|
}
|
4498
|
4512
|
return
|
4499
|
4513
|
}
|
|
4514
|
+
|
|
4515
|
+func (c *ScheduleApiController) DeleteScheduleTwo() {
|
|
4516
|
+ id, _ := c.GetInt64("id", 0)
|
|
4517
|
+ if id <= 0 {
|
|
4518
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
4519
|
+ return
|
|
4520
|
+ }
|
|
4521
|
+
|
|
4522
|
+ adminINfo := c.GetAdminUserInfo()
|
|
4523
|
+
|
|
4524
|
+ schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
|
|
4525
|
+ timeNow := time.Now().Format("2006-01-02")
|
|
4526
|
+ timeTemplate := "2006-01-02"
|
|
4527
|
+
|
|
4528
|
+ tm := time.Unix(int64(schedule.ScheduleDate), 0)
|
|
4529
|
+ timeStr := tm.Format(timeTemplate)
|
|
4530
|
+ if timeNow > timeStr {
|
|
4531
|
+ utils.ErrorLog(timeNow)
|
|
4532
|
+ utils.ErrorLog(timeStr)
|
|
4533
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
|
|
4534
|
+ return
|
|
4535
|
+ }
|
|
4536
|
+ if schedule == nil {
|
|
4537
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
|
|
4538
|
+ return
|
|
4539
|
+ }
|
|
4540
|
+
|
|
4541
|
+ order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
|
|
4542
|
+ if err != nil {
|
|
4543
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
4544
|
+ return
|
|
4545
|
+ }
|
|
4546
|
+
|
|
4547
|
+ if order != nil {
|
|
4548
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysisTwo)
|
|
4549
|
+ return
|
|
4550
|
+ }
|
|
4551
|
+
|
|
4552
|
+ schedule.Status = 0
|
|
4553
|
+ schedule.UpdatedTime = time.Now().Unix()
|
|
4554
|
+ err = service.UpdateSchedule(schedule)
|
|
4555
|
+ redis := service.RedisClient()
|
|
4556
|
+
|
|
4557
|
+ //处方
|
|
4558
|
+ keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
|
|
4559
|
+ redis.Set(keyOne, "", time.Second)
|
|
4560
|
+
|
|
4561
|
+ //医嘱
|
|
4562
|
+ keyTwo := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
|
|
4563
|
+ redis.Set(keyTwo, "", time.Second)
|
|
4564
|
+
|
|
4565
|
+ keySix := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
|
|
4566
|
+ redis.Set(keySix, "", time.Second)
|
|
4567
|
+ keyThree := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
|
|
4568
|
+ redis.Set(keyThree, "", time.Second)
|
|
4569
|
+
|
|
4570
|
+ keyFour := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
|
|
4571
|
+ redis.Set(keyFour, "", time.Second)
|
|
4572
|
+
|
|
4573
|
+ keyFive := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
|
|
4574
|
+ redis.Set(keyFive, "", time.Second)
|
|
4575
|
+
|
|
4576
|
+ keySeven := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
|
|
4577
|
+ redis.Set(keySeven, "", time.Second)
|
|
4578
|
+ fmt.Println(err)
|
|
4579
|
+ defer redis.Close()
|
|
4580
|
+ if err != nil {
|
|
4581
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
|
|
4582
|
+ return
|
|
4583
|
+ }
|
|
4584
|
+
|
|
4585
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
4586
|
+ "msg": "ok",
|
|
4587
|
+ "schedule": &schedule,
|
|
4588
|
+ })
|
|
4589
|
+}
|