test_user 2 年之前
父節點
當前提交
7a688fb942

+ 60 - 3
controllers/schedule_api_controller.go 查看文件

84
 
84
 
85
 	beego.Router("/api/smartsch/get", &ScheduleApiController{}, "Get:GetSmartSch")
85
 	beego.Router("/api/smartsch/get", &ScheduleApiController{}, "Get:GetSmartSch")
86
 
86
 
87
+	beego.Router("/api/sch/exchange", &ScheduleApiController{}, "Get:ExchangeSch")
88
+	beego.Router("/api/sch/coversch", &ScheduleApiController{}, "Get:CoverSch")
89
+
90
+}
91
+func (c *ScheduleApiController) CoverSch() {
92
+	id_one, _ := c.GetInt64("id_one")
93
+	id_two, _ := c.GetInt64("id_two")
94
+	sch, _ := service.GetSchedule(c.GetAdminUserInfo().CurrentOrgId, id_one)
95
+	sch_two, _ := service.GetSchedule(c.GetAdminUserInfo().CurrentOrgId, id_two)
96
+	order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
97
+	if order.ID > 0 {
98
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderOne)
99
+		return
100
+	}
101
+	order2, _ := service.GetDialysisOrder(sch_two.ScheduleDate, sch_two.PatientId, sch_two.UserOrgId)
102
+	if order2.ID > 0 {
103
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderTwo)
104
+		return
105
+	}
106
+
107
+	var new_sch *models.Schedule
108
+	new_sch = sch
109
+	new_sch.BedId = sch_two.BedId
110
+	new_sch.ScheduleDate = sch_two.ScheduleDate
111
+	new_sch.ScheduleWeek = sch_two.ScheduleWeek
112
+	new_sch.PartitionId = sch_two.PartitionId
113
+	new_sch.ScheduleType = sch_two.ScheduleType
114
+	new_sch.ID = 0
115
+	sch_two.Status = 0
116
+	sch.Status = 0
117
+	//删除原来的排班
118
+	service.SaveSchTwo(sch_two)
119
+	service.SaveSchTwo(sch)
120
+	//生成新的排班
121
+	service.SaveSchTwo(new_sch)
122
+	//service.UpdateScheduleThree(sch,sch_two)
123
+	c.ServeSuccessJSON(map[string]interface{}{
124
+		"msg": "覆盖成功",
125
+	})
126
+
127
+}
128
+func (c *ScheduleApiController) ExchangeSch() {
129
+	id_one, _ := c.GetInt64("id_one")
130
+	id_two, _ := c.GetInt64("id_two")
131
+	sch, _ := service.GetSchedule(c.GetAdminUserInfo().CurrentOrgId, id_one)
132
+	sch_two, _ := service.GetSchedule(c.GetAdminUserInfo().CurrentOrgId, id_two)
133
+	order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
134
+	if order.ID > 0 {
135
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderOne)
136
+		return
137
+	}
138
+	order2, _ := service.GetDialysisOrder(sch_two.ScheduleDate, sch_two.PatientId, sch_two.UserOrgId)
139
+	if order2.ID > 0 {
140
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderTwo)
141
+		return
142
+	}
143
+	service.UpdateScheduleThree(sch, sch_two)
144
+	c.ServeSuccessJSON(map[string]interface{}{
145
+		"msg": "替换成功",
146
+	})
87
 }
147
 }
88
 func (c *ScheduleApiController) BatchPostSmartSch() {
148
 func (c *ScheduleApiController) BatchPostSmartSch() {
89
 	patient_id, _ := c.GetInt64("patient_id")
149
 	patient_id, _ := c.GetInt64("patient_id")
576
 					schedule.Status = 0
636
 					schedule.Status = 0
577
 					service.SaveSch(schedule)
637
 					service.SaveSch(schedule)
578
 				}
638
 				}
579
-
580
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
639
 				HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
581
-
582
 			}
640
 			}
583
 		}
641
 		}
584
 	}
642
 	}
911
 							daySchedule.BedId = schedule.BedId
969
 							daySchedule.BedId = schedule.BedId
912
 							daySchedule.DialysisMachineName = schedule.DialysisMachineName
970
 							daySchedule.DialysisMachineName = schedule.DialysisMachineName
913
 							existSchedule.IsExport = 3002
971
 							existSchedule.IsExport = 3002
914
-
915
 							service.SaveSch(daySchedule)
972
 							service.SaveSch(daySchedule)
916
 						} else {
973
 						} else {
917
 							existSchedule.IsExport = 3003
974
 							existSchedule.IsExport = 3003

+ 9 - 3
controllers/schedule_template_api_controller.go 查看文件

694
 
694
 
695
 func (this *PatientScheduleTemplateAPIController) UpdateSchedulesTemplate() {
695
 func (this *PatientScheduleTemplateAPIController) UpdateSchedulesTemplate() {
696
 	addOrEditSchedulesJSON := this.GetString("edit_schs")
696
 	addOrEditSchedulesJSON := this.GetString("edit_schs")
697
-	//delSchedulesJSON := this.GetString("del_schs")
697
+	delSchedulesJSON := this.GetString("del_schs")
698
 
698
 
699
 	fmt.Println(addOrEditSchedulesJSON)
699
 	fmt.Println(addOrEditSchedulesJSON)
700
 	var addOrEditSchedules []*ParamModelEditSchedule
700
 	var addOrEditSchedules []*ParamModelEditSchedule
701
-	//var delSchedules []*ParamModelEditSchedule
701
+	var delSchedules []*ParamModelEditSchedule
702
 
702
 
703
 	parseErr := json.Unmarshal([]byte(addOrEditSchedulesJSON), &addOrEditSchedules)
703
 	parseErr := json.Unmarshal([]byte(addOrEditSchedulesJSON), &addOrEditSchedules)
704
-	//parseDelErr := json.Unmarshal([]byte(delSchedulesJSON), &delSchedules)
704
+	json.Unmarshal([]byte(delSchedulesJSON), &delSchedules)
705
 
705
 
706
 	fmt.Println(parseErr)
706
 	fmt.Println(parseErr)
707
 	if parseErr != nil {
707
 	if parseErr != nil {
714
 	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
714
 	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
715
 	//	return
715
 	//	return
716
 	//}
716
 	//}
717
+	for _, item := range delSchedules {
718
+		src_template, _ := service.GetScheduleTemplateItem(item.ID)
719
+		src_template.Status = 0
720
+		service.SaveSchTemplateItem(src_template)
721
+
722
+	}
717
 
723
 
718
 	for _, item := range addOrEditSchedules {
724
 	for _, item := range addOrEditSchedules {
719
 
725
 

+ 6 - 0
enums/error_code.go 查看文件

268
 	ErrorCodeSchedule = 50000000
268
 	ErrorCodeSchedule = 50000000
269
 
269
 
270
 	ErrorCodeParamWrongForSchMode = 40000002
270
 	ErrorCodeParamWrongForSchMode = 40000002
271
+
272
+	ErrorCodePatientDialysisOrderOne = 60000000
273
+	ErrorCodePatientDialysisOrderTwo = 60000001
271
 )
274
 )
272
 
275
 
273
 var ErrCodeMsgs = map[int]string{
276
 var ErrCodeMsgs = map[int]string{
521
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
524
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
522
 	ErrorCodeSchedule:                 "该班次该床位已有患者",
525
 	ErrorCodeSchedule:                 "该班次该床位已有患者",
523
 	ErrorCodeParamWrongForSchMode:     "透析模式不能为空",
526
 	ErrorCodeParamWrongForSchMode:     "透析模式不能为空",
527
+
528
+	ErrorCodePatientDialysisOrderOne: "替换的患者已经上机,无法替换排班",
529
+	ErrorCodePatientDialysisOrderTwo: "被替换的患者已经上机,无法替换排班",
524
 }
530
 }
525
 
531
 
526
 type SGJError struct {
532
 type SGJError struct {

+ 1 - 0
models/his_models.go 查看文件

131
 	Diagnosis              string  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
131
 	Diagnosis              string  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
132
 	SickType               int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
132
 	SickType               int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
133
 	PatientInfo            string  `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
133
 	PatientInfo            string  `gorm:"column:patient_info" json:"patient_info" form:"patient_info"`
134
+	InsuplcAdmdvs          string  `gorm:"column:insuplc_admdvs" json:"insuplc_admdvs" form:"insuplc_admdvs"`
134
 }
135
 }
135
 
136
 
136
 func (HisPatient) TableName() string {
137
 func (HisPatient) TableName() string {

+ 29 - 13
service/app_version.go 查看文件

679
 }
679
 }
680
 
680
 
681
 func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
681
 func GetHisPatient11111(orgid int64) (paitent []*models.HisHospitalCheckRecord, err error) {
682
-	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2022-11-01 00:00:00' AND in_hosptial_time <= '2022-11-30 23:59:59'", orgid).Find(&paitent).Error
682
+	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and status = 1 AND in_hosptial_time >= '2022-12-01 00:00:00' AND in_hosptial_time <= '2022-12-31 23:59:59'", orgid).Find(&paitent).Error
683
 	return paitent, err
683
 	return paitent, err
684
 }
684
 }
685
 
685
 
890
 		return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
890
 		return db.Where("status = 1 AND order_status = 2").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
891
 			return db.Where("status = 1").Preload("VMHisProject")
891
 			return db.Where("status = 1").Preload("VMHisProject")
892
 		})
892
 		})
893
-	}).Where("settle_accounts_date >= 1656604800 AND settle_accounts_date <= 1664553599 AND status = 1 AND order_status =2  AND user_org_id = 10138").Find(&order).Error
893
+	}).Where("settle_accounts_date >= 1664553600 AND settle_accounts_date <= 1672416000 AND status = 1 AND order_status =2  AND user_org_id = 10278").Find(&order).Error
894
 	return
894
 	return
895
 }
895
 }
896
 
896
 
913
 }
913
 }
914
 
914
 
915
 func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
915
 func GetHisOrderDetail10106(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
916
-	err = readDb.Model(&HisOrder9504{}).Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
916
+	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
917
 		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
917
 		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
918
 			return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
918
 			return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
919
 		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
919
 		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
923
 	return
923
 	return
924
 }
924
 }
925
 
925
 
926
+func GetHisOrderDetail10318(start_time int64, end_time int64) (order []*HisOrder9504, err error) {
927
+	err = readDb.Model(&HisOrder9504{}).Preload("Patients", "status = 1").Preload("VmHisOrderInfo9504", func(db *gorm.DB) *gorm.DB {
928
+		return db.Where("status = 1").Preload("HisPrescriptionProjectTen", func(db *gorm.DB) *gorm.DB {
929
+			return db.Where("status = 1").Preload("VMHisProject").Preload("VMGoodInfo")
930
+		}).Preload("HisDoctorAdviceInfoTen", func(db *gorm.DB) *gorm.DB {
931
+			return db.Where("status = 1").Preload("Drug")
932
+		})
933
+	}).Where("settle_accounts_date >= ? AND settle_accounts_date <= ? AND status = 1 AND order_status =2  AND user_org_id = 10318", start_time, end_time).Find(&order).Order("setl_time").Error
934
+	return
935
+}
936
+
926
 func GetLongSolution() {
937
 func GetLongSolution() {
927
 	records, _ := GetAllSchedules()
938
 	records, _ := GetAllSchedules()
928
 	fmt.Println(records)
939
 	fmt.Println(records)
929
 	for _, item := range records {
940
 	for _, item := range records {
941
+		var DialysisMachineName string
930
 		//1.透析器   2.灌流器     3.透析器/灌流器
942
 		//1.透析器   2.灌流器     3.透析器/灌流器
931
 		so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
943
 		so, _ := GetDialysisSolutionTwo(item.UserOrgId, item.PatientId, item.ModeId)
932
 		filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
944
 		filedRecordOne, _ := FindFiledBy(item.UserOrgId, "透析器")
933
 		filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
945
 		filedRecordTwo, _ := FindFiledBy(item.UserOrgId, "灌流器")
934
 		filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
946
 		filedRecordThree, _ := FindFiledBy(item.UserOrgId, "透析器/灌流器")
935
 		if filedRecordOne.IsShow == 1 {
947
 		if filedRecordOne.IsShow == 1 {
936
-			item.DialysisMachineName = so.DialysisDialyszers
948
+			DialysisMachineName = so.DialysisDialyszers
937
 		}
949
 		}
938
 		if filedRecordThree.IsShow == 1 {
950
 		if filedRecordThree.IsShow == 1 {
939
-			if len(item.DialysisMachineName) > 0 {
940
-				item.DialysisMachineName = item.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
951
+			if len(DialysisMachineName) > 0 {
952
+				DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
941
 
953
 
942
 			} else {
954
 			} else {
943
-				item.DialysisMachineName = so.DialyzerPerfusionApparatus
955
+				DialysisMachineName = so.DialyzerPerfusionApparatus
944
 
956
 
945
 			}
957
 			}
946
 		}
958
 		}
947
 		if filedRecordTwo.IsShow == 1 {
959
 		if filedRecordTwo.IsShow == 1 {
948
-			if len(item.DialysisMachineName) > 0 {
949
-				item.DialysisMachineName = item.DialysisMachineName + "," + so.DialysisIrrigation
960
+			if len(DialysisMachineName) > 0 {
961
+				DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
950
 
962
 
951
 			} else {
963
 			} else {
952
-				item.DialysisMachineName = so.DialysisIrrigation
964
+				DialysisMachineName = so.DialysisIrrigation
953
 
965
 
954
 			}
966
 			}
955
 		}
967
 		}
956
-
968
+		item.DialysisMachineName = DialysisMachineName
957
 		UpdateSch(item)
969
 		UpdateSch(item)
958
-
959
 	}
970
 	}
960
 }
971
 }
961
 
972
 
990
 func GetAllSchedules() ([]Schedule, error) {
1001
 func GetAllSchedules() ([]Schedule, error) {
991
 	var record []Schedule
1002
 	var record []Schedule
992
 
1003
 
993
-	err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date > 1670774400").Find(&record).Error
1004
+	err := readDb.Model(&Schedule{}).Where("user_org_id = 10290 AND status = 1 AND schedule_date > 1672934400").Find(&record).Error
994
 	if err != nil {
1005
 	if err != nil {
995
 		if err == gorm.ErrRecordNotFound {
1006
 		if err == gorm.ErrRecordNotFound {
996
 			return nil, nil
1007
 			return nil, nil
1022
 	err = writeDb.Save(&sch).Error
1033
 	err = writeDb.Save(&sch).Error
1023
 	return
1034
 	return
1024
 }
1035
 }
1036
+
1037
+func SaveSchTwo(sch *models.Schedule) (err error) {
1038
+	err = writeDb.Save(&sch).Error
1039
+	return
1040
+}

+ 60 - 0
service/schedule_service.go 查看文件

360
 
360
 
361
 }
361
 }
362
 
362
 
363
+func UpdateScheduleThree(schone *models.Schedule, schtwo *models.Schedule) {
364
+	utx := XTWriteDB()
365
+	//床位
366
+	var tempBedID int64
367
+	var tempBedIDTwo int64
368
+
369
+	//分區
370
+	var tempPID int64
371
+	var tempPIDTwo int64
372
+
373
+	//上下午
374
+	var tempTypeID int64
375
+	var tempTypeTwo int64
376
+
377
+	//日期
378
+	var sch_date_one int64
379
+	var sch_date_two int64
380
+
381
+	//周数
382
+	var sch_week_one int64
383
+	var sch_week_two int64
384
+
385
+	tempBedID = schone.BedId
386
+	tempBedIDTwo = schtwo.BedId
387
+
388
+	tempPID = schone.PartitionId
389
+	tempPIDTwo = schtwo.PartitionId
390
+
391
+	tempTypeID = schone.ScheduleType
392
+	tempTypeTwo = schtwo.ScheduleType
393
+
394
+	sch_date_one = schone.ScheduleDate
395
+	sch_date_two = schtwo.ScheduleDate
396
+
397
+	sch_week_one = schone.ScheduleWeek
398
+	sch_week_two = schtwo.ScheduleWeek
399
+
400
+	schone.BedId = tempBedIDTwo
401
+	schtwo.BedId = tempBedID
402
+
403
+	schone.PartitionId = tempPIDTwo
404
+	schtwo.PartitionId = tempPID
405
+
406
+	schone.ScheduleType = tempTypeTwo
407
+	schtwo.ScheduleType = tempTypeID
408
+
409
+	schone.ScheduleDate = sch_date_two
410
+	schtwo.ScheduleDate = sch_date_one
411
+
412
+	schone.ScheduleWeek = sch_week_two
413
+	schtwo.ScheduleWeek = sch_week_one
414
+
415
+	schone.IsExport = 9000
416
+	schtwo.IsExport = 9000
417
+
418
+	utx.Model(&models.Schedule{}).Where("id = ?", schone.ID).Updates(map[string]interface{}{"partition_id": schone.PartitionId, "bed_id": schone.BedId, "schedule_type": schone.ScheduleType, "schedule_date": schone.ScheduleDate, "schedule_week": schone.ScheduleWeek, "is_export": 9000})
419
+	utx.Model(&models.Schedule{}).Where("id = ?", schtwo.ID).Updates(map[string]interface{}{"partition_id": schtwo.PartitionId, "bed_id": schtwo.BedId, "schedule_type": schtwo.ScheduleType, "schedule_date": schtwo.ScheduleDate, "schedule_week": schtwo.ScheduleWeek, "is_export": 9000})
420
+
421
+}
422
+
363
 func GetPatientScheduleFormToday(orgId, id, start int64) (schedules []*models.PatientSchedule, err error) {
423
 func GetPatientScheduleFormToday(orgId, id, start int64) (schedules []*models.PatientSchedule, err error) {
364
 
424
 
365
 	err = readDb.Table("xt_schedule as s").
425
 	err = readDb.Table("xt_schedule as s").