|
@@ -548,14 +548,32 @@ func (c *ScheduleApiController) ChangeSchedule() {
|
548
|
548
|
|
549
|
549
|
schedule.UpdatedTime = time.Now().Unix()
|
550
|
550
|
err = service.UpdateSchedule(schedule)
|
551
|
|
- if err != nil {
|
552
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeScheduleFail)
|
553
|
|
- return
|
|
551
|
+
|
|
552
|
+ prescription := models.DialysisPrescription{
|
|
553
|
+ ModeId: schedule.ModeId,
|
|
554
|
+ }
|
|
555
|
+ _, errcode := service.GetDialysisPrescribe(schedule.UserOrgId, schedule.PatientId, schedule.ScheduleDate)
|
|
556
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
557
|
+ if err != nil {
|
|
558
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeScheduleFail)
|
|
559
|
+ return
|
|
560
|
+ }
|
|
561
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
562
|
+ "msg": "ok",
|
|
563
|
+ "schedule": &schedule,
|
|
564
|
+ })
|
|
565
|
+ } else if errcode == nil {
|
|
566
|
+ err = service.UpdatedDialysisPrescription(&prescription, schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
|
|
567
|
+
|
|
568
|
+ if err != nil {
|
|
569
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeScheduleFail)
|
|
570
|
+ return
|
|
571
|
+ }
|
|
572
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
573
|
+ "msg": "ok",
|
|
574
|
+ "schedule": &schedule,
|
|
575
|
+ })
|
554
|
576
|
}
|
555
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
556
|
|
- "msg": "ok",
|
557
|
|
- "schedule": &schedule,
|
558
|
|
- })
|
559
|
577
|
}
|
560
|
578
|
|
561
|
579
|
// /api/schedule/print/initdata [get]
|