Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
c41aec52ed

+ 11 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

@@ -382,6 +382,7 @@ func (this *StaffScheduleApiController) UpdateBloodSchedule() {
382 382
 	schedule_type, _ := this.GetInt64("schedule_type")
383 383
 	start_time := this.GetString("start_time")
384 384
 	dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
385
+	bed_id, _ := this.GetInt64("bed_id")
385 386
 	var startTime int64
386 387
 	if len(start_time) > 0 {
387 388
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
@@ -398,7 +399,16 @@ func (this *StaffScheduleApiController) UpdateBloodSchedule() {
398 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 414
 	_, errcode := service.GetDialyisSolution(patient_id, startTime)

+ 1 - 1
models/schedule_models.go View File

@@ -49,7 +49,7 @@ type Schedule struct {
49 49
 	DeviceNumber              DeviceNumber         `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
50 50
 	TreatmentMode             TreatmentMode        `json:"mode" gorm:"foreignkey:ModeId"`
51 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 53
 	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
54 54
 }
55 55
 

+ 13 - 0
service/doctor_schedule_service.go View File

@@ -689,6 +689,19 @@ func GetDialyisSolution(patientid int64, recorddate int64) (*models.DialysisPres
689 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 705
 func CreateDialysisPrescription(prescription models.DialysisPrescription) error {
693 706
 
694 707
 	err := XTReadDB().Create(&prescription).Error