|
@@ -79,11 +79,8 @@ func ScheduleApiRegistRouters() {
|
79
|
79
|
beego.Router("/api/patient/smartpatientschtemplate", &ScheduleApiController{}, "Get:GetPatientSmartSchTemplate")
|
80
|
80
|
|
81
|
81
|
beego.Router("/api/device/get", &ScheduleApiController{}, "Get:GetDevicesNumbers")
|
82
|
|
-
|
83
|
82
|
beego.Router("/api/smartsch/batch", &ScheduleApiController{}, "Post:BatchPostSmartSch")
|
84
|
|
-
|
85
|
83
|
beego.Router("/api/smartsch/get", &ScheduleApiController{}, "Get:GetSmartSch")
|
86
|
|
-
|
87
|
84
|
beego.Router("/api/sch/exchange", &ScheduleApiController{}, "Get:ExchangeSch")
|
88
|
85
|
beego.Router("/api/sch/coversch", &ScheduleApiController{}, "Get:CoverSch")
|
89
|
86
|
beego.Router("/api/schedule/delete_two", &ScheduleApiController{}, "Delete:DeleteScheduleTwo")
|
|
@@ -122,13 +119,22 @@ func (c *ScheduleApiController) CoverSch() {
|
122
|
119
|
new_sch.ScheduleType = sch_two.ScheduleType
|
123
|
120
|
new_sch.ID = 0
|
124
|
121
|
//删除原来的排班
|
125
|
|
- service.SaveSchTwo(sch, sch_two)
|
|
122
|
+ err := service.SaveSchTwo(sch, sch_two)
|
126
|
123
|
//生成新的排班
|
127
|
|
- service.SaveSch(new_sch)
|
128
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
129
|
|
- "msg": "覆盖成功",
|
130
|
|
- })
|
131
|
|
-
|
|
124
|
+ if err == nil {
|
|
125
|
+ err2 := service.SaveSch(new_sch)
|
|
126
|
+ if err2 == nil {
|
|
127
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
128
|
+ "msg": "覆盖成功",
|
|
129
|
+ })
|
|
130
|
+ } else {
|
|
131
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
132
|
+ return
|
|
133
|
+ }
|
|
134
|
+ } else {
|
|
135
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
136
|
+ return
|
|
137
|
+ }
|
132
|
138
|
}
|
133
|
139
|
func (c *ScheduleApiController) ExchangeSch() {
|
134
|
140
|
id_one, _ := c.GetInt64("id_one")
|
|
@@ -161,10 +167,18 @@ func (c *ScheduleApiController) ExchangeSch() {
|
161
|
167
|
}
|
162
|
168
|
}
|
163
|
169
|
|
164
|
|
- service.UpdateScheduleThree(sch, sch_two)
|
165
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
166
|
|
- "msg": "交换成功",
|
167
|
|
- })
|
|
170
|
+ err := service.UpdateScheduleThree(sch, sch_two)
|
|
171
|
+ if err == nil {
|
|
172
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
173
|
+ "msg": "交换成功",
|
|
174
|
+ })
|
|
175
|
+
|
|
176
|
+ } else {
|
|
177
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
178
|
+ return
|
|
179
|
+
|
|
180
|
+ }
|
|
181
|
+
|
168
|
182
|
}
|
169
|
183
|
func (c *ScheduleApiController) BatchPostSmartSch() {
|
170
|
184
|
patient_id, _ := c.GetInt64("patient_id")
|
|
@@ -186,7 +200,6 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
|
186
|
200
|
|
187
|
201
|
//数据校验
|
188
|
202
|
if dataBody["smart_schs"] != nil && reflect.TypeOf(dataBody["smart_schs"]).String() == "[]interface {}" {
|
189
|
|
-
|
190
|
203
|
schs, _ := dataBody["smart_schs"].([]interface{})
|
191
|
204
|
if len(schs) > 0 {
|
192
|
205
|
for _, item := range schs {
|
|
@@ -1000,7 +1013,7 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
|
1000
|
1013
|
service.SaveSch(daySchedule)
|
1001
|
1014
|
} else {
|
1002
|
1015
|
existSchedule.IsExport = 3003
|
1003
|
|
- service.CreateSchedule(&schedule)
|
|
1016
|
+ service.CreateScheduleTwo(&schedule)
|
1004
|
1017
|
}
|
1005
|
1018
|
}
|
1006
|
1019
|
}
|
|
@@ -1527,7 +1540,7 @@ func (c *ScheduleApiController) CreateSchedule() {
|
1527
|
1540
|
|
1528
|
1541
|
redis := service.RedisClient()
|
1529
|
1542
|
schedule.IsExport = 1000
|
1530
|
|
- err = service.CreateSchedule(&schedule)
|
|
1543
|
+ err = service.CreateScheduleTwo(&schedule)
|
1531
|
1544
|
|
1532
|
1545
|
key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
|
1533
|
1546
|
|
|
@@ -2670,26 +2683,18 @@ func (this *ScheduleApiController) ExportSchedule() {
|
2670
|
2683
|
for _, item := range schedules {
|
2671
|
2684
|
if item.ScheduleDate > clear_schedule_date {
|
2672
|
2685
|
//查询该患者是否转出获取死亡
|
2673
|
|
- fmt.Println("11111323242423")
|
2674
|
|
-
|
2675
|
2686
|
//查找当天日期是否存在
|
2676
|
2687
|
_, errcode := service.GetTodayScheduleIsExistOne(item.PatientId, item.ScheduleDate, item.UserOrgId)
|
2677
|
2688
|
if errcode == gorm.ErrRecordNotFound {
|
2678
|
2689
|
//查询该床位是否有患者
|
2679
|
|
- fmt.Println("errcodes")
|
2680
|
2690
|
sch, errcodes := service.GetPatientByBed(item.ScheduleDate, item.BedId, item.ScheduleType, item.UserOrgId)
|
2681
|
|
- fmt.Println("errcodes")
|
2682
|
|
- fmt.Println(errcodes)
|
2683
|
|
- fmt.Println(sch)
|
2684
|
2691
|
|
2685
|
2692
|
if errcodes == gorm.ErrRecordNotFound {
|
2686
|
|
- fmt.Println("1111111")
|
2687
|
|
- service.CreateSchedule(item)
|
|
2693
|
+ service.CreateScheduleTwo(item)
|
2688
|
2694
|
} else if errcodes == nil {
|
2689
|
|
- fmt.Println("1111222222222")
|
2690
|
2695
|
//清除当天该床位已有的患者
|
2691
|
2696
|
service.ModeFyScheduleById(sch.ScheduleDate, sch.BedId, sch.ScheduleType, sch.UserOrgId)
|
2692
|
|
- service.CreateSchedule(item)
|
|
2697
|
+ service.CreateScheduleTwo(item)
|
2693
|
2698
|
}
|
2694
|
2699
|
|
2695
|
2700
|
} else if errcode == nil {
|
|
@@ -2704,8 +2709,6 @@ func (this *ScheduleApiController) ExportSchedule() {
|
2704
|
2709
|
Status: 1,
|
2705
|
2710
|
DialysisMachineName: item.DialysisMachineName,
|
2706
|
2711
|
}
|
2707
|
|
- fmt.Println("1111222222223333333333333333332")
|
2708
|
|
-
|
2709
|
2712
|
service.UpdateScheduleByOrgIdOne(item.PatientId, item.ScheduleDate, item.UserOrgId, &schedule)
|
2710
|
2713
|
}
|
2711
|
2714
|
}
|
|
@@ -4556,38 +4559,45 @@ func (c *ScheduleApiController) DeleteScheduleTwo() {
|
4556
|
4559
|
schedule.Status = 0
|
4557
|
4560
|
schedule.UpdatedTime = time.Now().Unix()
|
4558
|
4561
|
err = service.UpdateSchedule(schedule)
|
4559
|
|
- redis := service.RedisClient()
|
4560
|
4562
|
|
4561
|
|
- //处方
|
4562
|
|
- keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
|
4563
|
|
- redis.Set(keyOne, "", time.Second)
|
|
4563
|
+ if err == nil {
|
|
4564
|
+ redis := service.RedisClient()
|
|
4565
|
+ //处方
|
|
4566
|
+ keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
|
|
4567
|
+ redis.Set(keyOne, "", time.Second)
|
4564
|
4568
|
|
4565
|
|
- //医嘱
|
4566
|
|
- keyTwo := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
|
4567
|
|
- redis.Set(keyTwo, "", time.Second)
|
|
4569
|
+ //医嘱
|
|
4570
|
+ keyTwo := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
|
|
4571
|
+ redis.Set(keyTwo, "", time.Second)
|
4568
|
4572
|
|
4569
|
|
- keySix := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
|
4570
|
|
- redis.Set(keySix, "", time.Second)
|
4571
|
|
- keyThree := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
|
4572
|
|
- redis.Set(keyThree, "", time.Second)
|
|
4573
|
+ keySix := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
|
|
4574
|
+ redis.Set(keySix, "", time.Second)
|
|
4575
|
+ keyThree := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
|
|
4576
|
+ redis.Set(keyThree, "", time.Second)
|
4573
|
4577
|
|
4574
|
|
- keyFour := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
|
4575
|
|
- redis.Set(keyFour, "", time.Second)
|
|
4578
|
+ keyFour := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
|
|
4579
|
+ redis.Set(keyFour, "", time.Second)
|
4576
|
4580
|
|
4577
|
|
- keyFive := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
|
4578
|
|
- redis.Set(keyFive, "", time.Second)
|
|
4581
|
+ keyFive := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
|
|
4582
|
+ redis.Set(keyFive, "", time.Second)
|
4579
|
4583
|
|
4580
|
|
- keySeven := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
|
4581
|
|
- redis.Set(keySeven, "", time.Second)
|
4582
|
|
- fmt.Println(err)
|
4583
|
|
- defer redis.Close()
|
4584
|
|
- if err != nil {
|
4585
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
|
|
4584
|
+ keySeven := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
|
|
4585
|
+ redis.Set(keySeven, "", time.Second)
|
|
4586
|
+ defer redis.Close()
|
|
4587
|
+ if err != nil {
|
|
4588
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
|
|
4589
|
+ return
|
|
4590
|
+ }
|
|
4591
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
4592
|
+ "msg": "ok",
|
|
4593
|
+ "schedule": &schedule,
|
|
4594
|
+ })
|
|
4595
|
+
|
|
4596
|
+ } else {
|
|
4597
|
+
|
|
4598
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
4586
|
4599
|
return
|
|
4600
|
+
|
4587
|
4601
|
}
|
4588
|
4602
|
|
4589
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
4590
|
|
- "msg": "ok",
|
4591
|
|
- "schedule": &schedule,
|
4592
|
|
- })
|
4593
|
4603
|
}
|