|
@@ -2039,6 +2039,9 @@ func (this *DialysisRecordAPIController) StartDialysis() {
|
2039
|
2039
|
|
2040
|
2040
|
schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
|
2041
|
2041
|
|
|
2042
|
+
|
|
2043
|
+ order, order_err := service.GetDialysisOrderByBedId(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
|
|
2044
|
+
|
2042
|
2045
|
if err == gorm.ErrRecordNotFound {
|
2043
|
2046
|
|
2044
|
2047
|
daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
|
|
@@ -2056,17 +2059,42 @@ func (this *DialysisRecordAPIController) StartDialysis() {
|
2056
|
2059
|
|
2057
|
2060
|
} else if err == nil {
|
2058
|
2061
|
if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 {
|
2059
|
|
- daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
|
2060
|
|
- if daySchedule.ID > 0 {
|
2061
|
|
- daySchedule.PartitionId = deviceNumber.ZoneID
|
2062
|
|
- daySchedule.BedId = bedID
|
2063
|
|
- daySchedule.ScheduleType = schedual_type
|
2064
|
|
- daySchedule.UpdatedTime = time.Now().Unix()
|
2065
|
|
- err := service.UpdateSchedule(&daySchedule)
|
2066
|
|
- if err != nil {
|
2067
|
|
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2062
|
+
|
|
2063
|
+ if order_err == nil {
|
|
2064
|
+ if order.ID > 0 {
|
|
2065
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
|
2068
|
2066
|
return
|
|
2067
|
+
|
|
2068
|
+ } else {
|
|
2069
|
+ daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
|
|
2070
|
+ if daySchedule.ID > 0 {
|
|
2071
|
+ daySchedule.PartitionId = deviceNumber.ZoneID
|
|
2072
|
+ daySchedule.BedId = bedID
|
|
2073
|
+ daySchedule.ScheduleType = schedual_type
|
|
2074
|
+ daySchedule.UpdatedTime = time.Now().Unix()
|
|
2075
|
+ err := service.UpdateSchedule(&daySchedule)
|
|
2076
|
+ if err != nil {
|
|
2077
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2078
|
+ return
|
|
2079
|
+ }
|
|
2080
|
+ }
|
2069
|
2081
|
}
|
|
2082
|
+ } else if order_err == gorm.ErrRecordNotFound {
|
|
2083
|
+ daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
|
|
2084
|
+ if daySchedule.ID > 0 {
|
|
2085
|
+ daySchedule.PartitionId = deviceNumber.ZoneID
|
|
2086
|
+ daySchedule.BedId = bedID
|
|
2087
|
+ daySchedule.ScheduleType = schedual_type
|
|
2088
|
+ daySchedule.UpdatedTime = time.Now().Unix()
|
|
2089
|
+ err := service.UpdateSchedule(&daySchedule)
|
|
2090
|
+ if err != nil {
|
|
2091
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2092
|
+ return
|
|
2093
|
+ }
|
|
2094
|
+ }
|
|
2095
|
+ } else if order_err != nil {
|
|
2096
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
2097
|
+ return
|
2070
|
2098
|
}
|
2071
|
2099
|
} else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 {
|
2072
|
2100
|
this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
|