Pārlūkot izejas kodu

11月8日库存管理

XMLWAN 3 gadus atpakaļ
vecāks
revīzija
c41aec52ed

+ 11 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Parādīt failu

382
 	schedule_type, _ := this.GetInt64("schedule_type")
382
 	schedule_type, _ := this.GetInt64("schedule_type")
383
 	start_time := this.GetString("start_time")
383
 	start_time := this.GetString("start_time")
384
 	dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
384
 	dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
385
+	bed_id, _ := this.GetInt64("bed_id")
385
 	var startTime int64
386
 	var startTime int64
386
 	if len(start_time) > 0 {
387
 	if len(start_time) > 0 {
387
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
388
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
398
 		ModeId:       mode_id,
399
 		ModeId:       mode_id,
399
 	}
400
 	}
400
 
401
 
401
-	service.UpdatedSchedule(schedule, id)
402
+	//查询该床位该班次是否存在排班
403
+	_, errschedulecode := service.GetPatientScheduleIsExist(patient_id, startTime, schedule_type, bed_id)
404
+	if errschedulecode == gorm.ErrRecordNotFound {
405
+		service.UpdatedSchedule(schedule, id)
406
+	} else if errschedulecode == nil {
407
+		this.ServeSuccessJSON(map[string]interface{}{
408
+			"msg":    "1",
409
+			"msgerr": "排班已存在",
410
+		})
411
+	}
402
 
412
 
403
 	//更改透析模式
413
 	//更改透析模式
404
 	_, errcode := service.GetDialyisSolution(patient_id, startTime)
414
 	_, errcode := service.GetDialyisSolution(patient_id, startTime)

+ 1 - 1
models/schedule_models.go Parādīt failu

49
 	DeviceNumber              DeviceNumber         `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
49
 	DeviceNumber              DeviceNumber         `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
50
 	TreatmentMode             TreatmentMode        `json:"mode" gorm:"foreignkey:ModeId"`
50
 	TreatmentMode             TreatmentMode        `json:"mode" gorm:"foreignkey:ModeId"`
51
 	DialysisOrder             DialysisOrder        `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
51
 	DialysisOrder             DialysisOrder        `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
52
-	DialysisPrescription      DialysisPrescription `json:"order" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId;"`
52
+	DialysisPrescription      DialysisPrescription `json:"dialysis_prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId;"`
53
 	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
53
 	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
54
 }
54
 }
55
 
55
 

+ 13 - 0
service/doctor_schedule_service.go Parādīt failu

689
 	return &prescription, nil
689
 	return &prescription, nil
690
 }
690
 }
691
 
691
 
692
+func GetPatientScheduleIsExist(patient_id int64, startime int64, schedule_type int64, bed_id int64) (*models.Schedule, error) {
693
+
694
+	schedule := models.Schedule{}
695
+	err := XTReadDB().Model(&schedule).Where("patient_id =? and schedule_date = ? and schedule_type = ? and bed_id = ? and status = 1", patient_id, startime, schedule_type, bed_id).Find(&schedule).Error
696
+	if err == gorm.ErrRecordNotFound {
697
+		return nil, err
698
+	}
699
+	if err != nil {
700
+		return nil, err
701
+	}
702
+	return &schedule, nil
703
+}
704
+
692
 func CreateDialysisPrescription(prescription models.DialysisPrescription) error {
705
 func CreateDialysisPrescription(prescription models.DialysisPrescription) error {
693
 
706
 
694
 	err := XTReadDB().Create(&prescription).Error
707
 	err := XTReadDB().Create(&prescription).Error