|
@@ -70,6 +70,850 @@ func ScheduleApiRegistRouters() {
|
70
|
70
|
beego.Router("/api/schedule/synchroschedule", &ScheduleApiController{}, "Get:SynchroSchedule")
|
71
|
71
|
beego.Router("/api/schedule/getpatientscheduletemplate", &ScheduleApiController{}, "Get:GetPatientScheduleTempalate")
|
72
|
72
|
beego.Router("/api/schedule/getsolutionschedule", &ScheduleApiController{}, "Get:GetSolutionSchedule")
|
|
73
|
+
|
|
74
|
+ beego.Router("/api/schedule/smartpatientsch", &ScheduleApiController{}, "Get:GetPatientSch")
|
|
75
|
+ beego.Router("/api/schedule/smartpatientschtemplate", &ScheduleApiController{}, "Get:GetPatientSchTemplate")
|
|
76
|
+
|
|
77
|
+ beego.Router("/api/patient/smartpatientsch", &ScheduleApiController{}, "Get:GetPatientSmartSch")
|
|
78
|
+
|
|
79
|
+ beego.Router("/api/patient/smartpatientschtemplate", &ScheduleApiController{}, "Get:GetPatientSmartSchTemplate")
|
|
80
|
+
|
|
81
|
+ beego.Router("/api/device/get", &ScheduleApiController{}, "Get:GetDevicesNumbers")
|
|
82
|
+
|
|
83
|
+ beego.Router("/api/smartsch/batch", &ScheduleApiController{}, "Post:BatchPostSmartSch")
|
|
84
|
+
|
|
85
|
+}
|
|
86
|
+func (c *ScheduleApiController) BatchPostSmartSch() {
|
|
87
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
88
|
+ adminInfo := c.GetAdminUserInfo()
|
|
89
|
+
|
|
90
|
+ patientInfo, _ := service.FindPatientById(adminInfo.CurrentOrgId, patient_id)
|
|
91
|
+ if patientInfo.ID == 0 {
|
|
92
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
93
|
+ return
|
|
94
|
+ }
|
|
95
|
+
|
|
96
|
+ dataBody := make(map[string]interface{}, 0)
|
|
97
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
98
|
+ if err != nil {
|
|
99
|
+ utils.ErrorLog(err.Error())
|
|
100
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
101
|
+ return
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ //数据校验
|
|
105
|
+ if dataBody["smart_schs"] != nil && reflect.TypeOf(dataBody["smart_schs"]).String() == "[]interface {}" {
|
|
106
|
+
|
|
107
|
+ schs, _ := dataBody["smart_schs"].([]interface{})
|
|
108
|
+ if len(schs) > 0 {
|
|
109
|
+ for _, item := range schs {
|
|
110
|
+ items := item.(map[string]interface{})
|
|
111
|
+ if items["sch_id"] == nil || reflect.TypeOf(items["sch_id"]).String() != "float64" {
|
|
112
|
+ utils.ErrorLog("id")
|
|
113
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
114
|
+ return
|
|
115
|
+ }
|
|
116
|
+ var schedule models.Schedule
|
|
117
|
+ //var oldSchedule *models.Schedule
|
|
118
|
+ sch_id := int64(items["sch_id"].(float64))
|
|
119
|
+ if sch_id > 0 { //修改排班信息
|
|
120
|
+ schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
|
|
121
|
+
|
|
122
|
+ if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
|
|
123
|
+ utils.ErrorLog("mode_id")
|
|
124
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
125
|
+ return
|
|
126
|
+ }
|
|
127
|
+ modeId := int64(items["mode_id"].(float64))
|
|
128
|
+ if modeId < 1 {
|
|
129
|
+ utils.ErrorLog("modeId < 1")
|
|
130
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
131
|
+ return
|
|
132
|
+ }
|
|
133
|
+ schedule.ModeId = modeId
|
|
134
|
+
|
|
135
|
+ order, err := service.GetOneDialysisOrder(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
|
|
136
|
+ if err != nil {
|
|
137
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
138
|
+ return
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ if order != nil {
|
|
142
|
+ week_type, _ := items["week_type"].(string)
|
|
143
|
+ week_name, _ := items["week_name"].(string)
|
|
144
|
+
|
|
145
|
+ switch week_type {
|
|
146
|
+ case "1":
|
|
147
|
+ json := make(map[string]interface{})
|
|
148
|
+ json["msg"] = "本周" + week_name + "的床位已经有人上机,无法保存"
|
|
149
|
+ json["state"] = 0
|
|
150
|
+ c.Data["json"] = json
|
|
151
|
+ c.ServeJSON()
|
|
152
|
+ break
|
|
153
|
+ case "2":
|
|
154
|
+ json := make(map[string]interface{})
|
|
155
|
+ json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
|
|
156
|
+ json["state"] = 0
|
|
157
|
+ c.Data["json"] = json
|
|
158
|
+ c.ServeJSON()
|
|
159
|
+ break
|
|
160
|
+ case "3":
|
|
161
|
+ json := make(map[string]interface{})
|
|
162
|
+ json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
|
|
163
|
+ json["state"] = 0
|
|
164
|
+ c.Data["json"] = json
|
|
165
|
+ c.ServeJSON()
|
|
166
|
+ break
|
|
167
|
+
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ return
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ if order != nil {
|
|
174
|
+ week_type, _ := items["week_type"].(string)
|
|
175
|
+ week_name, _ := items["week_name"].(string)
|
|
176
|
+
|
|
177
|
+ switch week_type {
|
|
178
|
+ case "1":
|
|
179
|
+ json := make(map[string]interface{})
|
|
180
|
+ json["msg"] = "本周" + week_name + "的床位已经有人上机,无法保存"
|
|
181
|
+ json["state"] = 0
|
|
182
|
+ c.Data["json"] = json
|
|
183
|
+ c.ServeJSON()
|
|
184
|
+ break
|
|
185
|
+ case "2":
|
|
186
|
+ json := make(map[string]interface{})
|
|
187
|
+ json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
|
|
188
|
+ json["state"] = 0
|
|
189
|
+ c.Data["json"] = json
|
|
190
|
+ c.ServeJSON()
|
|
191
|
+ break
|
|
192
|
+ case "3":
|
|
193
|
+ json := make(map[string]interface{})
|
|
194
|
+ json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
|
|
195
|
+ json["state"] = 0
|
|
196
|
+ c.Data["json"] = json
|
|
197
|
+ c.ServeJSON()
|
|
198
|
+ break
|
|
199
|
+ }
|
|
200
|
+ return
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ if items["schedule_type"] == nil || reflect.TypeOf(items["schedule_type"]).String() != "float64" {
|
|
204
|
+ utils.ErrorLog("schedule_type")
|
|
205
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
206
|
+ return
|
|
207
|
+ }
|
|
208
|
+ scheduleType := int64(items["schedule_type"].(float64))
|
|
209
|
+ if scheduleType < 1 || scheduleType > 3 {
|
|
210
|
+ utils.ErrorLog("scheduleType < 3")
|
|
211
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
212
|
+ return
|
|
213
|
+ }
|
|
214
|
+ schedule.ScheduleType = scheduleType
|
|
215
|
+
|
|
216
|
+ if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
|
|
217
|
+ utils.ErrorLog("bed_id")
|
|
218
|
+ fmt.Println("~~~~~~333333333")
|
|
219
|
+
|
|
220
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
221
|
+ return
|
|
222
|
+ }
|
|
223
|
+ bedId := int64(items["bed_id"].(float64))
|
|
224
|
+ if bedId < 1 {
|
|
225
|
+ utils.ErrorLog("bedId < 1")
|
|
226
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
227
|
+ return
|
|
228
|
+ }
|
|
229
|
+ schedule.BedId = bedId
|
|
230
|
+
|
|
231
|
+ if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
|
|
232
|
+ utils.ErrorLog("zone_id")
|
|
233
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
234
|
+ return
|
|
235
|
+ }
|
|
236
|
+ partitionId := int64(items["zone_id"].(float64))
|
|
237
|
+ if partitionId < 1 {
|
|
238
|
+ utils.ErrorLog("partitionId < 1")
|
|
239
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
240
|
+ return
|
|
241
|
+ }
|
|
242
|
+ schedule.PartitionId = partitionId
|
|
243
|
+
|
|
244
|
+ bed, _ := service.GetDeviceNumberByID(adminInfo.CurrentOrgId, schedule.BedId)
|
|
245
|
+ if bed == nil {
|
|
246
|
+
|
|
247
|
+ week_type, _ := items["week_type"].(string)
|
|
248
|
+ week_name, _ := items["week_name"].(string)
|
|
249
|
+
|
|
250
|
+ switch week_type {
|
|
251
|
+ case "1":
|
|
252
|
+ json := make(map[string]interface{})
|
|
253
|
+ json["msg"] = "本周" + week_name + "的机号不存在,无法保存"
|
|
254
|
+ json["state"] = 0
|
|
255
|
+ c.Data["json"] = json
|
|
256
|
+ c.ServeJSON()
|
|
257
|
+ break
|
|
258
|
+ case "2":
|
|
259
|
+ json := make(map[string]interface{})
|
|
260
|
+ json["msg"] = "下周" + week_name + "的机号不存在,无法保存"
|
|
261
|
+ json["state"] = 0
|
|
262
|
+ c.Data["json"] = json
|
|
263
|
+ c.ServeJSON()
|
|
264
|
+ break
|
|
265
|
+ case "3":
|
|
266
|
+ json := make(map[string]interface{})
|
|
267
|
+ json["msg"] = "下周" + week_name + "的机号不存在,无法保存"
|
|
268
|
+ json["state"] = 0
|
|
269
|
+ c.Data["json"] = json
|
|
270
|
+ c.ServeJSON()
|
|
271
|
+ break
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ return
|
|
275
|
+ }
|
|
276
|
+ if bed.ZoneID != schedule.PartitionId {
|
|
277
|
+
|
|
278
|
+ week_type, _ := items["week_type"].(string)
|
|
279
|
+ week_name, _ := items["week_name"].(string)
|
|
280
|
+
|
|
281
|
+ switch week_type {
|
|
282
|
+ case "1":
|
|
283
|
+ json := make(map[string]interface{})
|
|
284
|
+ json["msg"] = "本周" + week_name + "所选机号不在选择分区中,无法保存"
|
|
285
|
+ json["state"] = 0
|
|
286
|
+ c.Data["json"] = json
|
|
287
|
+ c.ServeJSON()
|
|
288
|
+ break
|
|
289
|
+ case "2":
|
|
290
|
+ json := make(map[string]interface{})
|
|
291
|
+ json["msg"] = "下周" + week_name + "所选机号不在选择分区中,无法保存"
|
|
292
|
+ json["state"] = 0
|
|
293
|
+ c.Data["json"] = json
|
|
294
|
+ c.ServeJSON()
|
|
295
|
+ break
|
|
296
|
+ case "3":
|
|
297
|
+ json := make(map[string]interface{})
|
|
298
|
+ json["msg"] = "下周" + week_name + "所选机号不在选择分区中,无法保存"
|
|
299
|
+ json["state"] = 0
|
|
300
|
+ c.Data["json"] = json
|
|
301
|
+ c.ServeJSON()
|
|
302
|
+ break
|
|
303
|
+ }
|
|
304
|
+
|
|
305
|
+ return
|
|
306
|
+ }
|
|
307
|
+
|
|
308
|
+ startTime := schedule.ScheduleDate
|
|
309
|
+ endTime := startTime + 86399
|
|
310
|
+
|
|
311
|
+ //一天只有排班一次
|
|
312
|
+ daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, startTime, endTime, schedule.PatientId)
|
|
313
|
+ if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
|
|
314
|
+ week_type, _ := items["week_type"].(string)
|
|
315
|
+ week_name, _ := items["week_name"].(string)
|
|
316
|
+
|
|
317
|
+ switch week_type {
|
|
318
|
+ case "1":
|
|
319
|
+ json := make(map[string]interface{})
|
|
320
|
+ json["msg"] = "本周" + week_name + "已有排班,同一天不可有两次排班,无法保存"
|
|
321
|
+ json["state"] = 0
|
|
322
|
+ c.Data["json"] = json
|
|
323
|
+ c.ServeJSON()
|
|
324
|
+ break
|
|
325
|
+ case "2":
|
|
326
|
+ json := make(map[string]interface{})
|
|
327
|
+ json["msg"] = "下周" + week_name + "已有排班,同一天不可有两次排班,无法保存"
|
|
328
|
+ json["state"] = 0
|
|
329
|
+ c.Data["json"] = json
|
|
330
|
+ c.ServeJSON()
|
|
331
|
+ break
|
|
332
|
+ case "3":
|
|
333
|
+ json := make(map[string]interface{})
|
|
334
|
+ json["msg"] = "下下周" + week_name + "已有排班,同一天不可有两次排班,无法保存"
|
|
335
|
+ json["state"] = 0
|
|
336
|
+ c.Data["json"] = json
|
|
337
|
+ c.ServeJSON()
|
|
338
|
+ break
|
|
339
|
+ }
|
|
340
|
+
|
|
341
|
+ return
|
|
342
|
+ }
|
|
343
|
+
|
|
344
|
+ //同天同位置只能排一个
|
|
345
|
+ pointSchedule, err := service.GetPointSchedule(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
|
|
346
|
+ if err != nil {
|
|
347
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
348
|
+ return
|
|
349
|
+ }
|
|
350
|
+ if pointSchedule.ID > 0 && pointSchedule.PatientId != patient_id {
|
|
351
|
+ week_type, _ := items["week_type"].(string)
|
|
352
|
+ week_name, _ := items["week_name"].(string)
|
|
353
|
+
|
|
354
|
+ switch week_type {
|
|
355
|
+ case "1":
|
|
356
|
+ json := make(map[string]interface{})
|
|
357
|
+ json["msg"] = "本周" + week_name + "所先位置排班已经存在,无法保存"
|
|
358
|
+ json["state"] = 0
|
|
359
|
+ c.Data["json"] = json
|
|
360
|
+ c.ServeJSON()
|
|
361
|
+ break
|
|
362
|
+ case "2":
|
|
363
|
+ json := make(map[string]interface{})
|
|
364
|
+ json["msg"] = "下周" + week_name + "所先位置排班已经存在,无法保存"
|
|
365
|
+ json["state"] = 0
|
|
366
|
+ c.Data["json"] = json
|
|
367
|
+ c.ServeJSON()
|
|
368
|
+ break
|
|
369
|
+ case "3":
|
|
370
|
+ json := make(map[string]interface{})
|
|
371
|
+ json["msg"] = "下下周" + week_name + "所先位置排班已经存在,无法保存"
|
|
372
|
+ json["state"] = 0
|
|
373
|
+ c.Data["json"] = json
|
|
374
|
+ c.ServeJSON()
|
|
375
|
+ break
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+ return
|
|
379
|
+ }
|
|
380
|
+
|
|
381
|
+ } else { //新的排班信息
|
|
382
|
+
|
|
383
|
+ if items["schedule_date"] == nil || reflect.TypeOf(items["schedule_date"]).String() != "string" {
|
|
384
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
385
|
+ return
|
|
386
|
+ }
|
|
387
|
+ scheduleDate, _ := items["schedule_date"].(string)
|
|
388
|
+ if len(scheduleDate) == 0 {
|
|
389
|
+ utils.ErrorLog("len(schedule_date) == 0")
|
|
390
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
391
|
+ return
|
|
392
|
+ }
|
|
393
|
+ timeLayout := "2006-01-02"
|
|
394
|
+ loc, _ := time.LoadLocation("Local")
|
|
395
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
|
|
396
|
+ if err != nil {
|
|
397
|
+ utils.ErrorLog(err.Error())
|
|
398
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
399
|
+ return
|
|
400
|
+ }
|
|
401
|
+ schedule.ScheduleDate = theTime.Unix()
|
|
402
|
+ timeNow := time.Now().Format("2006-01-02")
|
|
403
|
+ if timeNow > scheduleDate {
|
|
404
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
|
|
405
|
+ return
|
|
406
|
+ }
|
|
407
|
+ scheduleType := int64(items["schedule_type"].(float64))
|
|
408
|
+ if scheduleType < 1 || scheduleType > 3 {
|
|
409
|
+ utils.ErrorLog("scheduleType < 3")
|
|
410
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
411
|
+ return
|
|
412
|
+ }
|
|
413
|
+ schedule.ScheduleType = scheduleType
|
|
414
|
+
|
|
415
|
+ if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
|
|
416
|
+ fmt.Println("~~~~~~22222")
|
|
417
|
+ utils.ErrorLog("bed_id")
|
|
418
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
419
|
+ return
|
|
420
|
+ }
|
|
421
|
+ bedId := int64(items["bed_id"].(float64))
|
|
422
|
+ if bedId < 1 {
|
|
423
|
+ utils.ErrorLog("bedId < 1")
|
|
424
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
425
|
+ return
|
|
426
|
+ }
|
|
427
|
+ schedule.BedId = bedId
|
|
428
|
+
|
|
429
|
+ if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
|
|
430
|
+ utils.ErrorLog("zone_id")
|
|
431
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
432
|
+ return
|
|
433
|
+ }
|
|
434
|
+ partitionId := int64(items["zone_id"].(float64))
|
|
435
|
+ if partitionId < 1 {
|
|
436
|
+ utils.ErrorLog("zone_id < 1")
|
|
437
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
438
|
+ return
|
|
439
|
+ }
|
|
440
|
+ schedule.PartitionId = partitionId
|
|
441
|
+
|
|
442
|
+ if items["schedule_week"] == nil || reflect.TypeOf(items["schedule_week"]).String() != "float64" {
|
|
443
|
+ utils.ErrorLog("schedule_week")
|
|
444
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
445
|
+ return
|
|
446
|
+ }
|
|
447
|
+ scheduleWeek := int64(items["schedule_week"].(float64))
|
|
448
|
+ if scheduleWeek < 1 || scheduleWeek > 7 {
|
|
449
|
+ utils.ErrorLog("scheduleWeek < 1")
|
|
450
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
451
|
+ return
|
|
452
|
+ }
|
|
453
|
+ schedule.ScheduleWeek = scheduleWeek
|
|
454
|
+
|
|
455
|
+ if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
|
|
456
|
+ utils.ErrorLog("mode_id")
|
|
457
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
458
|
+ return
|
|
459
|
+ }
|
|
460
|
+ modeId := int64(items["mode_id"].(float64))
|
|
461
|
+ if modeId < 1 && modeId > 14 {
|
|
462
|
+ utils.ErrorLog("modeId < 1")
|
|
463
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
464
|
+ return
|
|
465
|
+ }
|
|
466
|
+ //校验当天改床位是否有排班,如果有排班则不能替换排班
|
|
467
|
+
|
|
468
|
+ sch, _ := service.GetScheduleByZoneAndBed(adminInfo.CurrentOrgId, partitionId, bedId, schedule.ScheduleDate, schedule.ScheduleType)
|
|
469
|
+
|
|
470
|
+ if sch.ID > 0 {
|
|
471
|
+ week_type, _ := items["week_type"].(string)
|
|
472
|
+ week_name, _ := items["week_name"].(string)
|
|
473
|
+
|
|
474
|
+ switch week_type {
|
|
475
|
+ case "1":
|
|
476
|
+ json := make(map[string]interface{})
|
|
477
|
+ json["msg"] = "本周" + week_name + "该床位已经有人排班,无法保存"
|
|
478
|
+ json["state"] = 0
|
|
479
|
+ c.Data["json"] = json
|
|
480
|
+ c.ServeJSON()
|
|
481
|
+ break
|
|
482
|
+ case "2":
|
|
483
|
+ json := make(map[string]interface{})
|
|
484
|
+ json["msg"] = "下周" + week_name + "该床位已经有人排班,无法保存"
|
|
485
|
+ json["state"] = 0
|
|
486
|
+ c.Data["json"] = json
|
|
487
|
+ c.ServeJSON()
|
|
488
|
+ break
|
|
489
|
+ case "3":
|
|
490
|
+ json := make(map[string]interface{})
|
|
491
|
+ json["msg"] = "下下周" + week_name + "该床位已经有人排班,无法保存"
|
|
492
|
+ json["state"] = 0
|
|
493
|
+ c.Data["json"] = json
|
|
494
|
+ c.ServeJSON()
|
|
495
|
+ break
|
|
496
|
+ }
|
|
497
|
+
|
|
498
|
+ return
|
|
499
|
+ }
|
|
500
|
+
|
|
501
|
+ }
|
|
502
|
+
|
|
503
|
+ }
|
|
504
|
+ }
|
|
505
|
+ }
|
|
506
|
+
|
|
507
|
+ if dataBody["smart_schs"] != nil && reflect.TypeOf(dataBody["smart_schs"]).String() == "[]interface {}" {
|
|
508
|
+
|
|
509
|
+ schs, _ := dataBody["smart_schs"].([]interface{})
|
|
510
|
+ if len(schs) > 0 {
|
|
511
|
+ for _, item := range schs {
|
|
512
|
+ items := item.(map[string]interface{})
|
|
513
|
+ if items["sch_id"] == nil || reflect.TypeOf(items["sch_id"]).String() != "float64" {
|
|
514
|
+ utils.ErrorLog("id")
|
|
515
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
516
|
+ return
|
|
517
|
+ }
|
|
518
|
+ var schedule models.Schedule
|
|
519
|
+ //var oldSchedule *models.Schedule
|
|
520
|
+ sch_id := int64(items["sch_id"].(float64))
|
|
521
|
+ if sch_id > 0 { //修改排班信息
|
|
522
|
+ fmt.Println("!!!!!!!")
|
|
523
|
+ schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
|
|
524
|
+ if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
|
|
525
|
+ fmt.Println(reflect.TypeOf(items["mode_id"]))
|
|
526
|
+
|
|
527
|
+ utils.ErrorLog("mode_id")
|
|
528
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
529
|
+ return
|
|
530
|
+ }
|
|
531
|
+ modeId := int64(items["mode_id"].(float64))
|
|
532
|
+ if modeId < 1 {
|
|
533
|
+ utils.ErrorLog("modeId < 1")
|
|
534
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
535
|
+ return
|
|
536
|
+ }
|
|
537
|
+ schedule.ModeId = modeId
|
|
538
|
+
|
|
539
|
+ order, err := service.GetOneDialysisOrder(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
|
|
540
|
+ if err != nil {
|
|
541
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
542
|
+ return
|
|
543
|
+ }
|
|
544
|
+
|
|
545
|
+ if order != nil {
|
|
546
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeMode)
|
|
547
|
+ return
|
|
548
|
+ }
|
|
549
|
+
|
|
550
|
+ if order != nil {
|
|
551
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeDeviceNumber)
|
|
552
|
+ return
|
|
553
|
+ }
|
|
554
|
+
|
|
555
|
+ if items["schedule_type"] == nil || reflect.TypeOf(items["schedule_type"]).String() != "float64" {
|
|
556
|
+ utils.ErrorLog("schedule_type")
|
|
557
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
558
|
+ return
|
|
559
|
+ }
|
|
560
|
+ scheduleType := int64(items["schedule_type"].(float64))
|
|
561
|
+ if scheduleType < 1 || scheduleType > 3 {
|
|
562
|
+ utils.ErrorLog("scheduleType < 3")
|
|
563
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
564
|
+ return
|
|
565
|
+ }
|
|
566
|
+ schedule.ScheduleType = scheduleType
|
|
567
|
+
|
|
568
|
+ if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
|
|
569
|
+ utils.ErrorLog("bed_id")
|
|
570
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
571
|
+ return
|
|
572
|
+ }
|
|
573
|
+ bedId := int64(items["bed_id"].(float64))
|
|
574
|
+ if bedId < 1 {
|
|
575
|
+ utils.ErrorLog("bedId < 1")
|
|
576
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
577
|
+ return
|
|
578
|
+ }
|
|
579
|
+ schedule.BedId = bedId
|
|
580
|
+
|
|
581
|
+ if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
|
|
582
|
+ utils.ErrorLog("zone_id")
|
|
583
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
584
|
+ return
|
|
585
|
+ }
|
|
586
|
+ partitionId := int64(items["zone_id"].(float64))
|
|
587
|
+ if partitionId < 1 {
|
|
588
|
+ utils.ErrorLog("partitionId < 1")
|
|
589
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
590
|
+ return
|
|
591
|
+ }
|
|
592
|
+ schedule.PartitionId = partitionId
|
|
593
|
+
|
|
594
|
+ bed, _ := service.GetDeviceNumberByID(adminInfo.CurrentOrgId, schedule.BedId)
|
|
595
|
+ if bed == nil {
|
|
596
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
|
|
597
|
+ return
|
|
598
|
+ }
|
|
599
|
+ if bed.ZoneID != schedule.PartitionId {
|
|
600
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
|
|
601
|
+ return
|
|
602
|
+ }
|
|
603
|
+
|
|
604
|
+ startTime := schedule.ScheduleDate
|
|
605
|
+ endTime := startTime + 86399
|
|
606
|
+
|
|
607
|
+ //一天只有排班一次
|
|
608
|
+ daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, startTime, endTime, schedule.PatientId)
|
|
609
|
+ if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
|
|
610
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
|
|
611
|
+ return
|
|
612
|
+ }
|
|
613
|
+
|
|
614
|
+ //同天同位置只能排一个
|
|
615
|
+ pointSchedule, err := service.GetPointSchedule(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
|
|
616
|
+ if err != nil {
|
|
617
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
618
|
+ return
|
|
619
|
+ }
|
|
620
|
+ if pointSchedule.ID > 0 && pointSchedule.PatientId != patient_id {
|
|
621
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
|
|
622
|
+ return
|
|
623
|
+ }
|
|
624
|
+
|
|
625
|
+ so, _ := service.GetDialysisSolutionTwo(adminInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
|
|
626
|
+ filedRecordOne, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器")
|
|
627
|
+ filedRecordTwo, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "灌流器")
|
|
628
|
+ filedRecordThree, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器/灌流器")
|
|
629
|
+
|
|
630
|
+ if filedRecordOne.IsShow == 1 {
|
|
631
|
+ schedule.DialysisMachineName = so.DialysisDialyszers
|
|
632
|
+ //service.UpdateSchDName(schedule)
|
|
633
|
+ }
|
|
634
|
+ if filedRecordTwo.IsShow == 1 {
|
|
635
|
+ schedule.DialysisMachineName = so.DialysisIrrigation
|
|
636
|
+ //service.UpdateSchDName(schedule)
|
|
637
|
+ }
|
|
638
|
+
|
|
639
|
+ if filedRecordThree.IsShow == 1 {
|
|
640
|
+ schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
|
|
641
|
+ //service.UpdateSchDName(schedule)
|
|
642
|
+ }
|
|
643
|
+
|
|
644
|
+ service.SaveSch(schedule)
|
|
645
|
+
|
|
646
|
+ } else { //新的排班信息
|
|
647
|
+ if items["schedule_date"] == nil || reflect.TypeOf(items["schedule_date"]).String() != "string" {
|
|
648
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
649
|
+ return
|
|
650
|
+ }
|
|
651
|
+ scheduleDate, _ := items["schedule_date"].(string)
|
|
652
|
+ if len(scheduleDate) == 0 {
|
|
653
|
+ utils.ErrorLog("len(schedule_date) == 0")
|
|
654
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
655
|
+ return
|
|
656
|
+ }
|
|
657
|
+ timeLayout := "2006-01-02"
|
|
658
|
+ loc, _ := time.LoadLocation("Local")
|
|
659
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
|
|
660
|
+ if err != nil {
|
|
661
|
+ utils.ErrorLog(err.Error())
|
|
662
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
663
|
+ return
|
|
664
|
+ }
|
|
665
|
+ schedule.ScheduleDate = theTime.Unix()
|
|
666
|
+ timeNow := time.Now().Format("2006-01-02")
|
|
667
|
+ if timeNow > scheduleDate {
|
|
668
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
|
|
669
|
+ return
|
|
670
|
+ }
|
|
671
|
+ scheduleType := int64(items["schedule_type"].(float64))
|
|
672
|
+ if scheduleType < 1 || scheduleType > 3 {
|
|
673
|
+ utils.ErrorLog("scheduleType < 3")
|
|
674
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
675
|
+ return
|
|
676
|
+ }
|
|
677
|
+ schedule.ScheduleType = scheduleType
|
|
678
|
+
|
|
679
|
+ if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
|
|
680
|
+ utils.ErrorLog("bed_id")
|
|
681
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
682
|
+ return
|
|
683
|
+ }
|
|
684
|
+ bedId := int64(items["bed_id"].(float64))
|
|
685
|
+ if bedId < 1 {
|
|
686
|
+ utils.ErrorLog("bedId < 1")
|
|
687
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
688
|
+ return
|
|
689
|
+ }
|
|
690
|
+ schedule.BedId = bedId
|
|
691
|
+
|
|
692
|
+ if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
|
|
693
|
+ utils.ErrorLog("zone_id")
|
|
694
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
695
|
+ return
|
|
696
|
+ }
|
|
697
|
+ partitionId := int64(items["zone_id"].(float64))
|
|
698
|
+ if partitionId < 1 {
|
|
699
|
+ utils.ErrorLog("zone_id < 1")
|
|
700
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
701
|
+ return
|
|
702
|
+ }
|
|
703
|
+ schedule.PartitionId = partitionId
|
|
704
|
+
|
|
705
|
+ if items["schedule_week"] == nil || reflect.TypeOf(items["schedule_week"]).String() != "float64" {
|
|
706
|
+ utils.ErrorLog("schedule_week")
|
|
707
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
708
|
+ return
|
|
709
|
+ }
|
|
710
|
+ scheduleWeek := int64(items["schedule_week"].(float64))
|
|
711
|
+ if scheduleWeek < 1 || scheduleWeek > 7 {
|
|
712
|
+ utils.ErrorLog("scheduleWeek < 1")
|
|
713
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
714
|
+ return
|
|
715
|
+ }
|
|
716
|
+ schedule.ScheduleWeek = scheduleWeek
|
|
717
|
+
|
|
718
|
+ if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
|
|
719
|
+ fmt.Println(reflect.TypeOf(items["mode_id"]))
|
|
720
|
+
|
|
721
|
+ utils.ErrorLog("mode_id")
|
|
722
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
723
|
+ return
|
|
724
|
+ }
|
|
725
|
+ modeId := int64(items["mode_id"].(float64))
|
|
726
|
+ if modeId < 1 && modeId > 14 {
|
|
727
|
+ utils.ErrorLog("modeId < 1")
|
|
728
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
729
|
+ return
|
|
730
|
+ }
|
|
731
|
+ //校验当天改床位是否有排班,如果有排班则不能替换排班
|
|
732
|
+
|
|
733
|
+ sch, _ := service.GetScheduleByZoneAndBed(adminInfo.CurrentOrgId, partitionId, bedId, schedule.ScheduleDate, schedule.ScheduleType)
|
|
734
|
+
|
|
735
|
+ if sch.ID > 0 {
|
|
736
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
|
|
737
|
+ return
|
|
738
|
+ }
|
|
739
|
+
|
|
740
|
+ schedule.ModeId = modeId
|
|
741
|
+ schedule.PatientId = patient_id
|
|
742
|
+ schedule.CreatedTime = time.Now().Unix()
|
|
743
|
+ schedule.UpdatedTime = time.Now().Unix()
|
|
744
|
+ schedule.Status = 1
|
|
745
|
+ schedule.UserOrgId = adminInfo.CurrentOrgId
|
|
746
|
+
|
|
747
|
+ so, _ := service.GetDialysisSolutionTwo(adminInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
|
|
748
|
+ filedRecordOne, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器")
|
|
749
|
+ filedRecordTwo, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "灌流器")
|
|
750
|
+ filedRecordThree, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器/灌流器")
|
|
751
|
+
|
|
752
|
+ if filedRecordOne.IsShow == 1 {
|
|
753
|
+ schedule.DialysisMachineName = so.DialysisDialyszers
|
|
754
|
+ //service.UpdateSchDName(schedule)
|
|
755
|
+ }
|
|
756
|
+ if filedRecordTwo.IsShow == 1 {
|
|
757
|
+ schedule.DialysisMachineName = so.DialysisIrrigation
|
|
758
|
+ //service.UpdateSchDName(schedule)
|
|
759
|
+ }
|
|
760
|
+
|
|
761
|
+ if filedRecordThree.IsShow == 1 {
|
|
762
|
+ schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
|
|
763
|
+ //service.UpdateSchDName(schedule)
|
|
764
|
+ }
|
|
765
|
+
|
|
766
|
+ service.CreateSchedule(&schedule)
|
|
767
|
+
|
|
768
|
+ }
|
|
769
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
770
|
+ "msg": "保存成功",
|
|
771
|
+ })
|
|
772
|
+
|
|
773
|
+ HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
|
|
774
|
+
|
|
775
|
+ }
|
|
776
|
+ }
|
|
777
|
+ }
|
|
778
|
+}
|
|
779
|
+func HandleRedis(org_id int64, sch_date int64) {
|
|
780
|
+ redis := service.RedisClient()
|
|
781
|
+ //处方
|
|
782
|
+ keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":prescriptions_list_all"
|
|
783
|
+ redis.Set(keyOne, "", time.Second)
|
|
784
|
+ //医嘱
|
|
785
|
+ keyTwo := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":advice_list_all"
|
|
786
|
+ redis.Set(keyTwo, "", time.Second)
|
|
787
|
+ keySix := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":assessment_befores_list_all"
|
|
788
|
+ redis.Set(keySix, "", time.Second)
|
|
789
|
+ keyThree := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":assessment_after_dislysis_list_all"
|
|
790
|
+ redis.Set(keyThree, "", time.Second)
|
|
791
|
+ keyFour := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":monitor_record_list_all"
|
|
792
|
+ redis.Set(keyFour, "", time.Second)
|
|
793
|
+ keyFive := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":treatment_summarys_list_all"
|
|
794
|
+ redis.Set(keyFive, "", time.Second)
|
|
795
|
+ keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":dialysis_orders_list_all"
|
|
796
|
+ redis.Set(keySeven, "", time.Second)
|
|
797
|
+ defer redis.Close()
|
|
798
|
+
|
|
799
|
+}
|
|
800
|
+
|
|
801
|
+func (c *ScheduleApiController) GetPatientSch() {
|
|
802
|
+ keyWord := c.GetString("keyword")
|
|
803
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
804
|
+ patient, err := service.GetSmartSchPatientByKeyWord(adminUserInfo.CurrentOrgId, keyWord)
|
|
805
|
+ if err != nil {
|
|
806
|
+ utils.ErrorLog(err.Error())
|
|
807
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
808
|
+ return
|
|
809
|
+ }
|
|
810
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
811
|
+ "patient": patient,
|
|
812
|
+ })
|
|
813
|
+}
|
|
814
|
+
|
|
815
|
+func (c *ScheduleApiController) GetPatientSchTemplate() {
|
|
816
|
+ keyWord := c.GetString("keyword")
|
|
817
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
818
|
+ patient, err := service.GetSmartSchTemplatePatientByKeyWord(adminUserInfo.CurrentOrgId, keyWord)
|
|
819
|
+ if err != nil {
|
|
820
|
+ utils.ErrorLog(err.Error())
|
|
821
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
822
|
+ return
|
|
823
|
+ }
|
|
824
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
825
|
+ "patient": patient,
|
|
826
|
+ })
|
|
827
|
+}
|
|
828
|
+
|
|
829
|
+func (c *ScheduleApiController) GetPatientSmartSch() {
|
|
830
|
+ patient_id, _ := c.GetInt64("patient_id", 0)
|
|
831
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
832
|
+ schs, err := service.GetSmartSchPatientByID(adminUserInfo.CurrentOrgId, patient_id)
|
|
833
|
+ if err != nil {
|
|
834
|
+ utils.ErrorLog(err.Error())
|
|
835
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
836
|
+ return
|
|
837
|
+ }
|
|
838
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
839
|
+ "schedules": schs,
|
|
840
|
+ })
|
|
841
|
+}
|
|
842
|
+func (c *ScheduleApiController) GetPatientSmartSchTemplate() {
|
|
843
|
+ patient_id, _ := c.GetInt64("patient_id", 0)
|
|
844
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
845
|
+ mode, _ := service.GetOrgPatientScheduleTemplateModeTwo(adminUserInfo.CurrentOrgId)
|
|
846
|
+ if mode.ID > 0 {
|
|
847
|
+ if mode.Mode == 0 {
|
|
848
|
+ //schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id)
|
|
849
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
850
|
+ "status": 0,
|
|
851
|
+ })
|
|
852
|
+
|
|
853
|
+ } else if mode.Mode == 1 {
|
|
854
|
+ schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 1)
|
|
855
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
856
|
+ "status": 0,
|
|
857
|
+ "schedules_template": schs,
|
|
858
|
+ })
|
|
859
|
+
|
|
860
|
+ } else if mode.Mode == 2 {
|
|
861
|
+ schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 2)
|
|
862
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
863
|
+ "status": 1,
|
|
864
|
+ "schedules_template": schs,
|
|
865
|
+ })
|
|
866
|
+
|
|
867
|
+ } else if mode.Mode == 3 {
|
|
868
|
+
|
|
869
|
+ schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 3)
|
|
870
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
871
|
+ "status": 1,
|
|
872
|
+ "schedules_template": schs,
|
|
873
|
+ })
|
|
874
|
+ } else if mode.Mode == 4 {
|
|
875
|
+
|
|
876
|
+ schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 4)
|
|
877
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
878
|
+ "status": 1,
|
|
879
|
+ "schedules_template": schs,
|
|
880
|
+ })
|
|
881
|
+ }
|
|
882
|
+
|
|
883
|
+ } else {
|
|
884
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
885
|
+ "status": 0,
|
|
886
|
+ })
|
|
887
|
+
|
|
888
|
+ }
|
|
889
|
+}
|
|
890
|
+
|
|
891
|
+func (c *ScheduleApiController) GetDevicesNumbers() {
|
|
892
|
+ sch_type, _ := c.GetInt("sch_type", 0)
|
|
893
|
+ zone_id, _ := c.GetInt64("zone_id", 0)
|
|
894
|
+ patient_id, _ := c.GetInt64("patient_id", 0)
|
|
895
|
+
|
|
896
|
+ schedule_date := c.GetString("schedule_date")
|
|
897
|
+
|
|
898
|
+ timeLayout := "2006-01-02"
|
|
899
|
+ loc, _ := time.LoadLocation("Local")
|
|
900
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
|
|
901
|
+ if err != nil {
|
|
902
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
903
|
+ return
|
|
904
|
+ }
|
|
905
|
+ recordDateTime := theTime.Unix()
|
|
906
|
+
|
|
907
|
+ deviceNumbers, getDeviceNumbersErr := service.GetAllAvaildDeviceNumbersByZone(c.GetAdminUserInfo().CurrentOrgId, recordDateTime, sch_type, zone_id, patient_id)
|
|
908
|
+ if getDeviceNumbersErr != nil {
|
|
909
|
+ c.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
|
|
910
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
911
|
+ return
|
|
912
|
+ }
|
|
913
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
914
|
+ "devices": deviceNumbers,
|
|
915
|
+ })
|
|
916
|
+
|
73
|
917
|
}
|
74
|
918
|
|
75
|
919
|
func (c *ScheduleApiController) GetWeekPanels() {
|
|
@@ -333,6 +1177,24 @@ func (c *ScheduleApiController) CreateSchedule() {
|
333
|
1177
|
schedule.Status = 1
|
334
|
1178
|
schedule.UserOrgId = adminUserInfo.CurrentOrgId
|
335
|
1179
|
|
|
1180
|
+ so, _ := service.GetDialysisSolutionTwo(adminUserInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
|
|
1181
|
+ filedRecordOne, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器")
|
|
1182
|
+ filedRecordTwo, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "灌流器")
|
|
1183
|
+ filedRecordThree, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器/灌流器")
|
|
1184
|
+
|
|
1185
|
+ if filedRecordOne.IsShow == 1 {
|
|
1186
|
+ schedule.DialysisMachineName = so.DialysisDialyszers
|
|
1187
|
+ //service.UpdateSchDName(schedule)
|
|
1188
|
+ }
|
|
1189
|
+ if filedRecordTwo.IsShow == 1 {
|
|
1190
|
+ schedule.DialysisMachineName = so.DialysisIrrigation
|
|
1191
|
+ //service.UpdateSchDName(schedule)
|
|
1192
|
+ }
|
|
1193
|
+
|
|
1194
|
+ if filedRecordThree.IsShow == 1 {
|
|
1195
|
+ schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
|
|
1196
|
+ //service.UpdateSchDName(schedule)
|
|
1197
|
+ }
|
336
|
1198
|
bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
|
337
|
1199
|
if bed == nil {
|
338
|
1200
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
|
|
@@ -422,6 +1284,17 @@ func (c *ScheduleApiController) DeleteSchedule() {
|
422
|
1284
|
adminINfo := c.GetAdminUserInfo()
|
423
|
1285
|
|
424
|
1286
|
schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
|
|
1287
|
+ timeNow := time.Now().Format("2006-01-02")
|
|
1288
|
+ timeTemplate := "2006-01-02"
|
|
1289
|
+
|
|
1290
|
+ tm := time.Unix(int64(schedule.ScheduleDate), 0)
|
|
1291
|
+ timeStr := tm.Format(timeTemplate)
|
|
1292
|
+ if timeNow > timeStr {
|
|
1293
|
+ utils.ErrorLog(timeNow)
|
|
1294
|
+ utils.ErrorLog(timeStr)
|
|
1295
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
|
|
1296
|
+ return
|
|
1297
|
+ }
|
425
|
1298
|
if schedule == nil {
|
426
|
1299
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
|
427
|
1300
|
return
|
|
@@ -521,6 +1394,25 @@ func (c *ScheduleApiController) ChangeSchedule() {
|
521
|
1394
|
}
|
522
|
1395
|
schedule.ModeId = modeId
|
523
|
1396
|
|
|
1397
|
+ so, _ := service.GetDialysisSolutionTwo(adminINfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
|
|
1398
|
+ filedRecordOne, _ := service.FindFiledBy(adminINfo.CurrentOrgId, "透析器")
|
|
1399
|
+ filedRecordTwo, _ := service.FindFiledBy(adminINfo.CurrentOrgId, "灌流器")
|
|
1400
|
+ filedRecordThree, _ := service.FindFiledBy(adminINfo.CurrentOrgId, "透析器/灌流器")
|
|
1401
|
+
|
|
1402
|
+ if filedRecordOne.IsShow == 1 {
|
|
1403
|
+ schedule.DialysisMachineName = so.DialysisDialyszers
|
|
1404
|
+ //service.UpdateSchDName(schedule)
|
|
1405
|
+ }
|
|
1406
|
+ if filedRecordTwo.IsShow == 1 {
|
|
1407
|
+ schedule.DialysisMachineName = so.DialysisIrrigation
|
|
1408
|
+ //service.UpdateSchDName(schedule)
|
|
1409
|
+ }
|
|
1410
|
+
|
|
1411
|
+ if filedRecordThree.IsShow == 1 {
|
|
1412
|
+ schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
|
|
1413
|
+ //service.UpdateSchDName(schedule)
|
|
1414
|
+ }
|
|
1415
|
+
|
524
|
1416
|
order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
|
525
|
1417
|
if err != nil {
|
526
|
1418
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -533,7 +1425,6 @@ func (c *ScheduleApiController) ChangeSchedule() {
|
533
|
1425
|
}
|
534
|
1426
|
|
535
|
1427
|
} else if changeAction == "change_device" {
|
536
|
|
-
|
537
|
1428
|
order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
|
538
|
1429
|
if err != nil {
|
539
|
1430
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
@@ -1423,6 +2314,24 @@ func (this *ScheduleApiController) ExportSchedule() {
|
1423
|
2314
|
sch.Status = 1
|
1424
|
2315
|
sch.UserOrgId = this.GetAdminUserInfo().CurrentOrgId
|
1425
|
2316
|
sch.IsExport = 1
|
|
2317
|
+ so, _ := service.GetDialysisSolutionTwo(sch.UserOrgId, sch.PatientId, sch.ModeId)
|
|
2318
|
+ filedRecordOne, _ := service.FindFiledBy(sch.UserOrgId, "透析器")
|
|
2319
|
+ filedRecordTwo, _ := service.FindFiledBy(sch.UserOrgId, "灌流器")
|
|
2320
|
+ filedRecordThree, _ := service.FindFiledBy(sch.UserOrgId, "透析器/灌流器")
|
|
2321
|
+
|
|
2322
|
+ if filedRecordOne.IsShow == 1 {
|
|
2323
|
+ sch.DialysisMachineName = so.DialysisDialyszers
|
|
2324
|
+ //service.UpdateSchDName(schedule)
|
|
2325
|
+ }
|
|
2326
|
+ if filedRecordTwo.IsShow == 1 {
|
|
2327
|
+ sch.DialysisMachineName = so.DialysisIrrigation
|
|
2328
|
+ //service.UpdateSchDName(schedule)
|
|
2329
|
+ }
|
|
2330
|
+
|
|
2331
|
+ if filedRecordThree.IsShow == 1 {
|
|
2332
|
+ sch.DialysisMachineName = so.DialyzerPerfusionApparatus
|
|
2333
|
+ //service.UpdateSchDName(schedule)
|
|
2334
|
+ }
|
1426
|
2335
|
schedules = append(schedules, &sch)
|
1427
|
2336
|
}
|
1428
|
2337
|
|