Bladeren bron

医保对接

csx 2 jaren geleden
bovenliggende
commit
637f985b64

+ 4 - 0
controllers/his_api_controller.go Bestand weergeven

@@ -5234,6 +5234,8 @@ func (c *HisApiController) GetUploadInfo() {
5234 5234
 			PrivatePrice:          private_price,
5235 5235
 			SettleEndTime:         end_time,
5236 5236
 			SettleStartTime:       start_time,
5237
+			PsnPartAmt:            totals,
5238
+			PsnCashPay:            totals,
5237 5239
 			SettleType:            settle_accounts_type,
5238 5240
 			FaPiaoCode:            fapiao_code,
5239 5241
 			FaPiaoNumber:          fapiao_number,
@@ -7819,6 +7821,8 @@ func (c *HisApiController) PreSettle() {
7819 7821
 		SettleEndTime:      end_time,
7820 7822
 		SettleStartTime:    start_time,
7821 7823
 		SettleType:         settle_accounts_type,
7824
+		PsnPartAmt:         totals,
7825
+		PsnCashPay:         totals,
7822 7826
 		PType:              2,
7823 7827
 		IsPre:              1,
7824 7828
 		MedType:            strconv.Itoa(int(reg_type)),

+ 5 - 2
controllers/mobile_api_controllers/mobile_api_router_register.go Bestand weergeven

@@ -170,9 +170,12 @@ func MobileAPIControllersRegisterRouters() {
170 170
 	beego.Router("/m/api/savepatientsign", &DialysisAPIController{}, "Post:SavePatientSign")
171 171
 	beego.Router("/m/api/getpatientsign", &DialysisAPIController{}, "Get:GetPatientSign")
172 172
 
173
-	beego.Router("/m/api/checksch/get", &DialysisAPIController{}, "Get:CheckSchedule")
174
-
175 173
 	beego.Router("/m/api/patient/getschedulebypatient", &DialysisAPIController{}, "Get:GetScheduleByPatient")
176 174
 
177 175
 	beego.Router("/m/api/getdialysisrecordeorder", &DialysisAPIController{}, "Get:GetDialysisRecordOrder")
176
+
177
+	beego.Router("/m/api/getdialysisrecordeorder", &DialysisAPIController{}, "Get:GetDialysisRecordOrder")
178
+	beego.Router("/m/api/checksch/get", &DialysisAPIController{}, "Get:CheckSchedule")
179
+
180
+	//beego.Router("/m/api/getscheduletypebyidlist",&DialysisAPIController{},"Get:GetScheduleTypeByIdList")
178 181
 }

+ 36 - 0
controllers/patient_api_controller.go Bestand weergeven

@@ -840,6 +840,25 @@ func (c *PatientApiController) CreateDialysisSolution() {
840 840
 	solution.ParentId = 0
841 841
 	solution.SolutionStatus = 1
842 842
 
843
+	//records, _ := service.GetAllSchedules()
844
+
845
+	schs, _ := service.GetAllSchedulesByPatientInfo(adminUserInfo.CurrentOrgId, id, solution.ModeId)
846
+	for _, sch := range schs {
847
+		var DialysisMachineName string
848
+		if len(solution.DialysisDialyszers) > 0 {
849
+			DialysisMachineName = solution.DialysisDialyszers
850
+		}
851
+		if len(solution.DialyzerPerfusionApparatus) > 0 {
852
+			DialysisMachineName = DialysisMachineName + "," + solution.DialyzerPerfusionApparatus
853
+		}
854
+
855
+		if len(solution.DialysisIrrigation) > 0 {
856
+			DialysisMachineName = DialysisMachineName + "," + solution.DialysisIrrigation
857
+		}
858
+		sch.DialysisMachineName = DialysisMachineName
859
+		service.UpdateSch(sch)
860
+	}
861
+
843 862
 	err := service.CreatePatientDialysisSolution(&solution)
844 863
 
845 864
 	//获取最新1条
@@ -921,6 +940,23 @@ func (c *PatientApiController) UpdateDialysisSolution() {
921 940
 		service.UpdatePatientDialysisSolutionOne(solution.PatientId, adminUserInfo.CurrentOrgId, &prescription, todayTime.Unix())
922 941
 	}
923 942
 
943
+	schs, _ := service.GetAllSchedulesByPatientInfo(adminUserInfo.CurrentOrgId, solution.PatientId, solution.ModeId)
944
+	for _, sch := range schs {
945
+		var DialysisMachineName string
946
+		if len(solution.DialysisDialyszers) > 0 {
947
+			DialysisMachineName = solution.DialysisDialyszers
948
+		}
949
+		if len(solution.DialyzerPerfusionApparatus) > 0 {
950
+			DialysisMachineName = DialysisMachineName + "," + solution.DialyzerPerfusionApparatus
951
+		}
952
+
953
+		if len(solution.DialysisIrrigation) > 0 {
954
+			DialysisMachineName = DialysisMachineName + "," + solution.DialysisIrrigation
955
+		}
956
+		sch.DialysisMachineName = DialysisMachineName
957
+		service.UpdateSch(sch)
958
+	}
959
+
924 960
 	if err != nil {
925 961
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionUpdate)
926 962
 		return

+ 282 - 66
controllers/schedule_api_controller.go Bestand weergeven

@@ -498,6 +498,42 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
498 498
 						return
499 499
 					}
500 500
 
501
+					//daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, theTime.Unix(), theTime.Unix(), patient_id)
502
+					//if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
503
+					//	week_type, _ := items["week_type"].(string)
504
+					//	week_name, _ := items["week_name"].(string)
505
+					//
506
+					//	switch week_type {
507
+					//	case "1":
508
+					//		json := make(map[string]interface{})
509
+					//		json["msg"] = "本周" + week_name + "该床位已经有人排班,无法保存"
510
+					//		json["state"] = 0
511
+					//		c.Data["json"] = json
512
+					//		c.ServeJSON()
513
+					//		break
514
+					//	case "2":
515
+					//		json := make(map[string]interface{})
516
+					//		json["msg"] = "下周" + week_name + "当天该患者已经排班,无法保存"
517
+					//		json["state"] = 0
518
+					//		c.Data["json"] = json
519
+					//		c.ServeJSON()
520
+					//		break
521
+					//	case "3":
522
+					//		json := make(map[string]interface{})
523
+					//		json["msg"] = "下下周" + week_name + "当天该患者已经排班,无法保存"
524
+					//		json["state"] = 0
525
+					//		c.Data["json"] = json
526
+					//		c.ServeJSON()
527
+					//		break
528
+					//	}
529
+					//
530
+					//	return
531
+					//
532
+					//
533
+					//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
534
+					//	return
535
+					//}
536
+					//
501 537
 				}
502 538
 
503 539
 			}
@@ -629,21 +665,29 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
629 665
 
630 666
 					if filedRecordOne.IsShow == 1 {
631 667
 						schedule.DialysisMachineName = so.DialysisDialyszers
632
-						//service.UpdateSchDName(schedule)
633 668
 					}
634
-					if filedRecordTwo.IsShow == 1 {
635
-						schedule.DialysisMachineName = so.DialysisIrrigation
636
-						//service.UpdateSchDName(schedule)
669
+					if filedRecordThree.IsShow == 1 {
670
+						if len(schedule.DialysisMachineName) > 0 {
671
+							schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
672
+
673
+						} else {
674
+							schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
675
+
676
+						}
637 677
 					}
678
+					if filedRecordTwo.IsShow == 1 {
679
+						if len(schedule.DialysisMachineName) > 0 {
680
+							schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
638 681
 
639
-					if filedRecordThree.IsShow == 1 {
640
-						schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
641
-						//service.UpdateSchDName(schedule)
682
+						} else {
683
+							schedule.DialysisMachineName = so.DialysisIrrigation
684
+
685
+						}
642 686
 					}
643 687
 
644 688
 					service.SaveSch(schedule)
645
-
646 689
 				} else { //新的排班信息
690
+
647 691
 					if items["schedule_date"] == nil || reflect.TypeOf(items["schedule_date"]).String() != "string" {
648 692
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
649 693
 						return
@@ -663,6 +707,7 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
663 707
 						return
664 708
 					}
665 709
 					schedule.ScheduleDate = theTime.Unix()
710
+
666 711
 					timeNow := time.Now().Format("2006-01-02")
667 712
 					if timeNow > scheduleDate {
668 713
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
@@ -751,20 +796,37 @@ func (c *ScheduleApiController) BatchPostSmartSch() {
751 796
 
752 797
 					if filedRecordOne.IsShow == 1 {
753 798
 						schedule.DialysisMachineName = so.DialysisDialyszers
754
-						//service.UpdateSchDName(schedule)
755 799
 					}
756
-					if filedRecordTwo.IsShow == 1 {
757
-						schedule.DialysisMachineName = so.DialysisIrrigation
758
-						//service.UpdateSchDName(schedule)
759
-					}
760
-
761 800
 					if filedRecordThree.IsShow == 1 {
762
-						schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
763
-						//service.UpdateSchDName(schedule)
801
+						if len(schedule.DialysisMachineName) > 0 {
802
+							schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
803
+
804
+						} else {
805
+							schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
806
+
807
+						}
764 808
 					}
809
+					if filedRecordTwo.IsShow == 1 {
810
+						if len(schedule.DialysisMachineName) > 0 {
811
+							schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
765 812
 
766
-					service.CreateSchedule(&schedule)
813
+						} else {
814
+							schedule.DialysisMachineName = so.DialysisIrrigation
767 815
 
816
+						}
817
+					}
818
+
819
+					daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, theTime.Unix(), theTime.Unix(), patient_id)
820
+					if daySchedule.ID > 0 {
821
+						daySchedule.ModeId = schedule.ModeId
822
+						daySchedule.ScheduleType = schedule.ScheduleType
823
+						daySchedule.PartitionId = schedule.PartitionId
824
+						daySchedule.BedId = schedule.BedId
825
+						daySchedule.DialysisMachineName = schedule.DialysisMachineName
826
+						service.SaveSch(daySchedule)
827
+					} else {
828
+						service.CreateSchedule(&schedule)
829
+					}
768 830
 				}
769 831
 				c.ServeSuccessJSON(map[string]interface{}{
770 832
 					"msg": "保存成功",
@@ -919,12 +981,27 @@ func (c *ScheduleApiController) GetDevicesNumbers() {
919 981
 func (c *ScheduleApiController) GetWeekPanels() {
920 982
 
921 983
 	data, _ := c.GetInt64("data", 1)
922
-	patitionId, _ := c.GetInt64("patitionid")
984
+	patitionIdStr := c.GetString("patitionid")
985
+	var ids []string
986
+	if len(patitionIdStr) > 0 {
987
+		ids = strings.Split(patitionIdStr, ",")
988
+	}
989
+
923 990
 	adminInfo := c.GetAdminUserInfo()
924 991
 	thisTime := time.Now()
925 992
 	year, monthTime, day := thisTime.Date()
926 993
 	month := int(monthTime)
927 994
 	_, theWeek := thisTime.ISOWeek()
995
+
996
+	lastWeek := thisTime.AddDate(0, 0, -7)
997
+
998
+	nextWeek := thisTime.AddDate(0, 0, 7)
999
+	nextSecWeek := thisTime.AddDate(0, 0, 14)
1000
+
1001
+	_, theLastWeek := lastWeek.ISOWeek()
1002
+	_, theNextWeek := nextWeek.ISOWeek()
1003
+	_, theNextSecWeek := nextSecWeek.ISOWeek()
1004
+
928 1005
 	weekDay := int(thisTime.Weekday())
929 1006
 	if weekDay == 0 {
930 1007
 		weekDay = 7
@@ -941,16 +1018,24 @@ func (c *ScheduleApiController) GetWeekPanels() {
941 1018
 	}
942 1019
 
943 1020
 	returnData := map[string]interface{}{
944
-		"year":     year,
945
-		"month":    month,
946
-		"day":      day,
947
-		"theWeek":  theWeek,
948
-		"weekDay":  weekDay,
949
-		"weekDays": weekDays,
1021
+		"year":           year,
1022
+		"month":          month,
1023
+		"day":            day,
1024
+		"theWeek":        theWeek,
1025
+		"theNextWeek":    theNextWeek,
1026
+		"theNextSecWeek": theNextSecWeek,
1027
+		"theLastWeek":    theLastWeek,
1028
+		"weekDay":        weekDay,
1029
+		"weekDays":       weekDays,
950 1030
 	}
951 1031
 
952 1032
 	if data == 1 {
953
-		partitions, _ := service.GetSchedulePartitionPanelOne(adminInfo.CurrentOrgId, patitionId)
1033
+		fmt.Println(ids)
1034
+
1035
+		partitions, _ := service.GetSchedulePartitionPanelOne(adminInfo.CurrentOrgId, ids)
1036
+		fmt.Println("````~~")
1037
+		fmt.Println(partitions)
1038
+
954 1039
 		returnData["partitions"] = partitions
955 1040
 	}
956 1041
 
@@ -1184,17 +1269,26 @@ func (c *ScheduleApiController) CreateSchedule() {
1184 1269
 
1185 1270
 	if filedRecordOne.IsShow == 1 {
1186 1271
 		schedule.DialysisMachineName = so.DialysisDialyszers
1187
-		//service.UpdateSchDName(schedule)
1188 1272
 	}
1189
-	if filedRecordTwo.IsShow == 1 {
1190
-		schedule.DialysisMachineName = so.DialysisIrrigation
1191
-		//service.UpdateSchDName(schedule)
1273
+	if filedRecordThree.IsShow == 1 {
1274
+		if len(schedule.DialysisMachineName) > 0 {
1275
+			schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
1276
+
1277
+		} else {
1278
+			schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
1279
+
1280
+		}
1192 1281
 	}
1282
+	if filedRecordTwo.IsShow == 1 {
1283
+		if len(schedule.DialysisMachineName) > 0 {
1284
+			schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
1193 1285
 
1194
-	if filedRecordThree.IsShow == 1 {
1195
-		schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
1196
-		//service.UpdateSchDName(schedule)
1286
+		} else {
1287
+			schedule.DialysisMachineName = so.DialysisIrrigation
1288
+
1289
+		}
1197 1290
 	}
1291
+
1198 1292
 	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
1199 1293
 	if bed == nil {
1200 1294
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
@@ -1383,13 +1477,13 @@ func (c *ScheduleApiController) ChangeSchedule() {
1383 1477
 	if changeAction == "change_mode" {
1384 1478
 		if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
1385 1479
 			utils.ErrorLog("mode_id")
1386
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1480
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrongForSchMode)
1387 1481
 			return
1388 1482
 		}
1389 1483
 		modeId := int64(dataBody["mode_id"].(float64))
1390 1484
 		if modeId < 1 {
1391 1485
 			utils.ErrorLog("modeId < 1")
1392
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1486
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrongForSchMode)
1393 1487
 			return
1394 1488
 		}
1395 1489
 		schedule.ModeId = modeId
@@ -1401,16 +1495,24 @@ func (c *ScheduleApiController) ChangeSchedule() {
1401 1495
 
1402 1496
 		if filedRecordOne.IsShow == 1 {
1403 1497
 			schedule.DialysisMachineName = so.DialysisDialyszers
1404
-			//service.UpdateSchDName(schedule)
1405 1498
 		}
1406
-		if filedRecordTwo.IsShow == 1 {
1407
-			schedule.DialysisMachineName = so.DialysisIrrigation
1408
-			//service.UpdateSchDName(schedule)
1499
+		if filedRecordThree.IsShow == 1 {
1500
+			if len(schedule.DialysisMachineName) > 0 {
1501
+				schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
1502
+
1503
+			} else {
1504
+				schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
1505
+
1506
+			}
1409 1507
 		}
1508
+		if filedRecordTwo.IsShow == 1 {
1509
+			if len(schedule.DialysisMachineName) > 0 {
1510
+				schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
1410 1511
 
1411
-		if filedRecordThree.IsShow == 1 {
1412
-			schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
1413
-			//service.UpdateSchDName(schedule)
1512
+			} else {
1513
+				schedule.DialysisMachineName = so.DialysisIrrigation
1514
+
1515
+			}
1414 1516
 		}
1415 1517
 
1416 1518
 		order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
@@ -2321,17 +2423,26 @@ func (this *ScheduleApiController) ExportSchedule() {
2321 2423
 
2322 2424
 			if filedRecordOne.IsShow == 1 {
2323 2425
 				sch.DialysisMachineName = so.DialysisDialyszers
2324
-				//service.UpdateSchDName(schedule)
2325 2426
 			}
2326
-			if filedRecordTwo.IsShow == 1 {
2327
-				sch.DialysisMachineName = so.DialysisIrrigation
2328
-				//service.UpdateSchDName(schedule)
2427
+			if filedRecordThree.IsShow == 1 {
2428
+				if len(sch.DialysisMachineName) > 0 {
2429
+					sch.DialysisMachineName = sch.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
2430
+
2431
+				} else {
2432
+					sch.DialysisMachineName = so.DialyzerPerfusionApparatus
2433
+
2434
+				}
2329 2435
 			}
2436
+			if filedRecordTwo.IsShow == 1 {
2437
+				if len(sch.DialysisMachineName) > 0 {
2438
+					sch.DialysisMachineName = sch.DialysisMachineName + "," + so.DialysisIrrigation
2330 2439
 
2331
-			if filedRecordThree.IsShow == 1 {
2332
-				sch.DialysisMachineName = so.DialyzerPerfusionApparatus
2333
-				//service.UpdateSchDName(schedule)
2440
+				} else {
2441
+					sch.DialysisMachineName = so.DialysisIrrigation
2442
+
2443
+				}
2334 2444
 			}
2445
+
2335 2446
 			schedules = append(schedules, &sch)
2336 2447
 		}
2337 2448
 
@@ -2785,10 +2896,11 @@ func (this *ScheduleApiController) ExportScheduleTemplate() {
2785 2896
 				sch.Weekday = int8(schedule_week)
2786 2897
 
2787 2898
 			}
2788
-
2899
+			treat_mode, _ := schMapM["treat_mode"].(string)
2900
+			treat_mode_int, _ := strconv.ParseInt(treat_mode, 10, 64)
2789 2901
 			sch.CreateTime = time.Now().Unix()
2790 2902
 			sch.ModifyTime = time.Now().Unix()
2791
-			sch.TreatMode = 1
2903
+			sch.TreatMode = treat_mode_int
2792 2904
 			sch.Status = 1
2793 2905
 			sch.OrgID = this.GetAdminUserInfo().CurrentOrgId
2794 2906
 			sch.IsExport = 1
@@ -2797,22 +2909,26 @@ func (this *ScheduleApiController) ExportScheduleTemplate() {
2797 2909
 
2798 2910
 		errLogs, _ := service.FindSchedualTemplateExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
2799 2911
 
2912
+		//for _, item := range schedules {
2913
+		//
2914
+		//}
2915
+
2800 2916
 		if len(schedules) > 0 {
2801 2917
 			err := service.UpdateScheduleTemplateStatus(this.GetAdminUserInfo().CurrentOrgId)
2802 2918
 			if err == nil {
2803 2919
 				for _, item := range schedules {
2804 2920
 					service.CreateScheduleTemplate(item)
2805 2921
 				}
2806
-				//查询已经转出或者死亡的患者
2807
-				patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
2808
-				for _, it := range patientList {
2809
-					timeStr := time.Now().Format("2006-01-02")
2810
-					timeLayout := "2006-01-02 15:04:05"
2811
-					timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
2812
-					timenow := timeStringToTime.Unix()
2813
-					service.UpdateScheduleByDeathTime(it.ID, timenow)
2814
-					service.UpdateScheduleItemByPatientId(it.ID)
2815
-				}
2922
+				////查询已经转出或者死亡的患者
2923
+				//patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
2924
+				//for _, it := range patientList {
2925
+				//	timeStr := time.Now().Format("2006-01-02")
2926
+				//	timeLayout := "2006-01-02 15:04:05"
2927
+				//	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
2928
+				//	timenow := timeStringToTime.Unix()
2929
+				//	service.UpdateScheduleByDeathTime(it.ID, timenow)
2930
+				//	service.UpdateScheduleItemByPatientId(it.ID)
2931
+				//}
2816 2932
 				log := models.ExportLog{
2817 2933
 					LogType:    3,
2818 2934
 					UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
@@ -2883,9 +2999,13 @@ func (c *ScheduleApiController) GetInitExcelInitDate() {
2883 2999
 	thisTime := time.Now()
2884 3000
 	thisTime1 := time.Now()
2885 3001
 	thisTime2 := time.Now()
3002
+	thisTime3 := time.Now()
3003
+	thisTime4 := time.Now()
2886 3004
 
2887 3005
 	thisTime1 = thisTime1.AddDate(0, 0, 7)
2888 3006
 	thisTime2 = thisTime2.AddDate(0, 0, 14)
3007
+	thisTime3 = thisTime3.AddDate(0, 0, 21)
3008
+	thisTime4 = thisTime4.AddDate(0, 0, 28)
2889 3009
 
2890 3010
 	weekDay := int(thisTime.Weekday())
2891 3011
 	if weekDay == 0 {
@@ -2921,6 +3041,28 @@ func (c *ScheduleApiController) GetInitExcelInitDate() {
2921 3041
 		days = append(days, theDay.Format("2006-01-02"))
2922 3042
 	}
2923 3043
 
3044
+	weekDay3 := int(thisTime3.Weekday())
3045
+	if weekDay3 == 0 {
3046
+		weekDay3 = 7
3047
+	}
3048
+	weekEnd3 := 7 - weekDay3
3049
+	weekStart3 := weekEnd3 - 6
3050
+	for index := weekStart3; index <= weekEnd3; index++ {
3051
+		theDay := thisTime3.AddDate(0, 0, index)
3052
+		days = append(days, theDay.Format("2006-01-02"))
3053
+	}
3054
+
3055
+	weekDay4 := int(thisTime4.Weekday())
3056
+	if weekDay4 == 0 {
3057
+		weekDay4 = 7
3058
+	}
3059
+	weekEnd4 := 7 - weekDay4
3060
+	weekStart4 := weekEnd4 - 6
3061
+	for index := weekStart4; index <= weekEnd4; index++ {
3062
+		theDay := thisTime4.AddDate(0, 0, index)
3063
+		days = append(days, theDay.Format("2006-01-02"))
3064
+	}
3065
+
2924 3066
 	c.ServeSuccessJSON(map[string]interface{}{
2925 3067
 		"days": days,
2926 3068
 	})
@@ -3135,6 +3277,33 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
3135 3277
 			CreatedTime:  time.Now().Unix(),
3136 3278
 		}
3137 3279
 
3280
+		so, _ := service.GetDialysisSolutionTwo(adminUserInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
3281
+		filedRecordOne, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器")
3282
+		filedRecordTwo, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "灌流器")
3283
+		filedRecordThree, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器/灌流器")
3284
+
3285
+		if filedRecordOne.IsShow == 1 {
3286
+			schedule.DialysisMachineName = so.DialysisDialyszers
3287
+		}
3288
+		if filedRecordThree.IsShow == 1 {
3289
+			if len(schedule.DialysisMachineName) > 0 {
3290
+				schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
3291
+
3292
+			} else {
3293
+				schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
3294
+
3295
+			}
3296
+		}
3297
+		if filedRecordTwo.IsShow == 1 {
3298
+			if len(schedule.DialysisMachineName) > 0 {
3299
+				schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
3300
+
3301
+			} else {
3302
+				schedule.DialysisMachineName = so.DialysisIrrigation
3303
+
3304
+			}
3305
+		}
3306
+
3138 3307
 		err = service.AddPatientSchedule(&schedule)
3139 3308
 
3140 3309
 	}
@@ -3738,7 +3907,6 @@ func (c *ScheduleApiController) SynchroSchedule() {
3738 3907
 
3739 3908
 	recordDateStr := time.Now().Format("2006-01-02")
3740 3909
 	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
3741
-
3742 3910
 	nowtime := recordDate.Unix()
3743 3911
 	fmt.Println("今日时间", nowtime)
3744 3912
 	fmt.Println("后期日期", copy_startime)
@@ -3752,13 +3920,11 @@ func (c *ScheduleApiController) SynchroSchedule() {
3752 3920
 	if copy_startime > nowtime {
3753 3921
 		//清空该时间段的所有排班数据
3754 3922
 		service.DeletePatientSchedule(copy_startime, copy_endtime, orgId)
3755
-
3756 3923
 		tuesday = copy_startime + 86400
3757 3924
 		wednesday = copy_startime + 172800
3758 3925
 		thursday = copy_startime + 259200
3759 3926
 		friday = copy_startime + 345600
3760 3927
 		saturday = copy_startime + 432000
3761
-
3762 3928
 		for _, item := range list {
3763 3929
 			if item.Weekday == 1 {
3764 3930
 				item.ScheduleDate = copy_startime
@@ -3786,7 +3952,6 @@ func (c *ScheduleApiController) SynchroSchedule() {
3786 3952
 			number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
3787 3953
 			item.ZoneId = number.ZoneID
3788 3954
 		}
3789
-
3790 3955
 		for _, item := range list {
3791 3956
 			schedule := models.XtSchedule{
3792 3957
 				UserOrgId:    orgId,
@@ -3802,6 +3967,33 @@ func (c *ScheduleApiController) SynchroSchedule() {
3802 3967
 				UpdatedTime:  0,
3803 3968
 			}
3804 3969
 
3970
+			so, _ := service.GetDialysisSolutionTwo(c.GetAdminUserInfo().CurrentOrgId, schedule.PatientId, schedule.ModeId)
3971
+			filedRecordOne, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器")
3972
+			filedRecordTwo, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "灌流器")
3973
+			filedRecordThree, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器/灌流器")
3974
+
3975
+			if filedRecordOne.IsShow == 1 {
3976
+				schedule.DialysisMachineName = so.DialysisDialyszers
3977
+			}
3978
+			if filedRecordThree.IsShow == 1 {
3979
+				if len(schedule.DialysisMachineName) > 0 {
3980
+					schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
3981
+
3982
+				} else {
3983
+					schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
3984
+
3985
+				}
3986
+			}
3987
+			if filedRecordTwo.IsShow == 1 {
3988
+				if len(schedule.DialysisMachineName) > 0 {
3989
+					schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
3990
+
3991
+				} else {
3992
+					schedule.DialysisMachineName = so.DialysisIrrigation
3993
+
3994
+				}
3995
+			}
3996
+
3805 3997
 			service.CreatePatientSchedule(&schedule)
3806 3998
 		}
3807 3999
 	}
@@ -3848,7 +4040,6 @@ func (c *ScheduleApiController) SynchroSchedule() {
3848 4040
 			number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
3849 4041
 			item.ZoneId = number.ZoneID
3850 4042
 		}
3851
-
3852 4043
 		for _, item := range list {
3853 4044
 			// 同步今日以后的数据
3854 4045
 			if item.ScheduleDate > nowtime {
@@ -3865,10 +4056,35 @@ func (c *ScheduleApiController) SynchroSchedule() {
3865 4056
 					CreatedTime:  time.Now().Unix(),
3866 4057
 					UpdatedTime:  0,
3867 4058
 				}
4059
+				so, _ := service.GetDialysisSolutionTwo(c.GetAdminUserInfo().CurrentOrgId, schedule.PatientId, schedule.ModeId)
4060
+				filedRecordOne, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器")
4061
+				filedRecordTwo, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "灌流器")
4062
+				filedRecordThree, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器/灌流器")
4063
+
4064
+				if filedRecordOne.IsShow == 1 {
4065
+					schedule.DialysisMachineName = so.DialysisDialyszers
4066
+				}
4067
+				if filedRecordThree.IsShow == 1 {
4068
+					if len(schedule.DialysisMachineName) > 0 {
4069
+						schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialyzerPerfusionApparatus
4070
+
4071
+					} else {
4072
+						schedule.DialysisMachineName = so.DialyzerPerfusionApparatus
4073
+
4074
+					}
4075
+				}
4076
+				if filedRecordTwo.IsShow == 1 {
4077
+					if len(schedule.DialysisMachineName) > 0 {
4078
+						schedule.DialysisMachineName = schedule.DialysisMachineName + "," + so.DialysisIrrigation
4079
+
4080
+					} else {
4081
+						schedule.DialysisMachineName = so.DialysisIrrigation
4082
+
4083
+					}
4084
+				}
3868 4085
 				service.CreatePatientSchedule(&schedule)
3869 4086
 			}
3870 4087
 		}
3871
-
3872 4088
 	}
3873 4089
 
3874 4090
 	returnData := make(map[string]interface{}, 0)

+ 26 - 7
controllers/schedule_template_api_controller.go Bestand weergeven

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"encoding/json"
8 8
 	"fmt"
9
+	"strings"
9 10
 	"time"
10 11
 
11 12
 	"github.com/astaxie/beego"
@@ -53,6 +54,12 @@ type PatientScheduleTemplateAPIController struct {
53 54
 func (this *PatientScheduleTemplateAPIController) InitData() {
54 55
 	adminUserInfo := this.GetAdminUserInfo()
55 56
 
57
+	patitionIdStr := this.GetString("patitionid")
58
+	var ids []string
59
+	if len(patitionIdStr) > 0 {
60
+		ids = strings.Split(patitionIdStr, ",")
61
+	}
62
+
56 63
 	mode, getModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
57 64
 	if getModeErr != nil {
58 65
 		this.ErrorLog("获取排班模板启用模式失败:%v", getModeErr)
@@ -77,7 +84,7 @@ func (this *PatientScheduleTemplateAPIController) InitData() {
77 84
 		}
78 85
 	}
79 86
 
80
-	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId)
87
+	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId, ids)
81 88
 
82 89
 	fmt.Println("deviceNumbers233323232332232323223233223323232323", deviceNumbers)
83 90
 	if getDeviceNumbersErr != nil {
@@ -184,7 +191,7 @@ func (this *PatientScheduleTemplateAPIController) SetMode() {
184 191
 	templateMode.Week = int64(week_time)
185 192
 
186 193
 	if mode != templateMode.Mode {
187
-		if templateMode.Mode == 0 { // 0 -> 1 或 0 -> 2 则直接清除下四周的排班
194
+		if templateMode.Mode == 0 { // 0 -> 1 或 0 -> 2  则直接清除下四周的排班
188 195
 			templateMode.Mode = mode
189 196
 			templateMode.ExecuteTimes = 0
190 197
 			templateMode.ModifyTime = time.Now().Unix()
@@ -210,7 +217,7 @@ func (this *PatientScheduleTemplateAPIController) SetMode() {
210 217
 			templateMode.Mode = mode
211 218
 			templateMode.ExecuteTimes = 0
212 219
 			templateMode.ModifyTime = time.Now().Unix()
213
-			updateErr := service.SavePatientScheduleTemplateModeAndClearNextSecondWeekSchedules(templateMode)
220
+			updateErr := service.SavePatientScheduleTemplateModeAndClearNextTwoWeekSchedules(templateMode)
214 221
 			if updateErr != nil {
215 222
 				this.ErrorLog("更新排班模板启用方式(1 -> 2)时失败:%v", updateErr)
216 223
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -263,7 +270,7 @@ func (this *PatientScheduleTemplateAPIController) SetMode() {
263 270
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
264 271
 				return
265 272
 			}
266
-		} else if templateMode.Mode == 2 && mode == 3 { // 2 -> 1 清除第二周模板item,清除第二周排班
273
+		} else if templateMode.Mode == 2 && mode == 3 { //
267 274
 			templateMode.Mode = mode
268 275
 			templateMode.ExecuteTimes = 0
269 276
 			templateMode.ModifyTime = time.Now().Unix()
@@ -273,7 +280,7 @@ func (this *PatientScheduleTemplateAPIController) SetMode() {
273 280
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
274 281
 				return
275 282
 			}
276
-		} else if templateMode.Mode == 2 && mode == 4 { // 2 -> 1 清除第二周模板item,清除第二周排班
283
+		} else if templateMode.Mode == 2 && mode == 4 { //
277 284
 			templateMode.Mode = mode
278 285
 			templateMode.ExecuteTimes = 0
279 286
 			templateMode.ModifyTime = time.Now().Unix()
@@ -384,17 +391,29 @@ func (this *PatientScheduleTemplateAPIController) SetMode() {
384 391
 		}
385 392
 		templates, _ := service.GetOrgPatientScheduleTemplateIDs(adminUserInfo.CurrentOrgId)
386 393
 		//处理第几周数问题
387
-		if mode == 1 {
394
+		if mode == 0 {
395
+			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, 0)
396
+			service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, 0)
397
+			service.UpdateTemplateItemWeek(templates[2].OrgID, templates[2].ID, 0)
398
+			service.UpdateTemplateItemWeek(templates[3].OrgID, templates[3].ID, 0)
399
+
400
+		} else if mode == 1 {
388 401
 			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, week_time)
402
+			service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, 0)
403
+			service.UpdateTemplateItemWeek(templates[2].OrgID, templates[2].ID, 0)
404
+			service.UpdateTemplateItemWeek(templates[3].OrgID, templates[3].ID, 0)
389 405
 
390 406
 		} else if mode == 2 {
391 407
 			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, week_time)
392 408
 			service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, week_time+1)
409
+			service.UpdateTemplateItemWeek(templates[2].OrgID, templates[2].ID, 0)
410
+			service.UpdateTemplateItemWeek(templates[3].OrgID, templates[3].ID, 0)
393 411
 
394 412
 		} else if mode == 3 {
395 413
 			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, week_time)
396 414
 			service.UpdateTemplateItemWeek(templates[1].OrgID, templates[1].ID, week_time+1)
397 415
 			service.UpdateTemplateItemWeek(templates[2].OrgID, templates[2].ID, week_time+2)
416
+			service.UpdateTemplateItemWeek(templates[3].OrgID, templates[3].ID, 0)
398 417
 
399 418
 		} else if mode == 4 {
400 419
 			service.UpdateTemplateItemWeek(templates[0].OrgID, templates[0].ID, week_time)
@@ -593,7 +612,7 @@ func (this *PatientScheduleTemplateAPIController) UpdateSchedules() {
593 612
 	//	}
594 613
 	//}
595 614
 
596
-	updateErr := service.UpdateScheduleTemplate(adminUserInfo.CurrentOrgId, templateID, addTemplateItems, delTemplateItems, changeTemplateItems)
615
+	updateErr := service.UpdateScheduleTemplate(adminUserInfo.CurrentOrgId, templateID, addTemplateItems, delTemplateItems, changeTemplateItems, false, false)
597 616
 	if updateErr != nil {
598 617
 		this.ErrorLog("更新排班模板排班失败:%v", updateErr)
599 618
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)

+ 3 - 0
enums/error_code.go Bestand weergeven

@@ -266,6 +266,8 @@ const ( // ErrorCode
266 266
 	ErrorCodeCantDeleteScheduleBeforeNow = 40000001
267 267
 
268 268
 	ErrorCodeSchedule = 50000000
269
+
270
+	ErrorCodeParamWrongForSchMode = 40000002
269 271
 )
270 272
 
271 273
 var ErrCodeMsgs = map[int]string{
@@ -518,6 +520,7 @@ var ErrCodeMsgs = map[int]string{
518 520
 
519 521
 	ErrorCodeHisPatientNoRegException: "该患者尚未挂号,请先挂号",
520 522
 	ErrorCodeSchedule:                 "该班次该床位已有患者",
523
+	ErrorCodeParamWrongForSchMode:     "透析模式不能为空",
521 524
 }
522 525
 
523 526
 type SGJError struct {

+ 15 - 14
models/device_models.go Bestand weergeven

@@ -403,20 +403,21 @@ type Schedules struct {
403 403
 }
404 404
 
405 405
 type XtSchedule struct {
406
-	ID              int64                   `gorm:"column:id" json:"id" form:"id"`
407
-	UserOrgId       int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
408
-	PartitionId     int64                   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
409
-	BedId           int64                   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
410
-	PatientId       int64                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
411
-	ScheduleDate    int64                   `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
412
-	ScheduleType    int64                   `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
413
-	ScheduleWeek    int64                   `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
414
-	ModeId          int64                   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
415
-	Status          int64                   `gorm:"column:status" json:"status" form:"status"`
416
-	CreatedTime     int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
417
-	UpdatedTime     int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
418
-	IsExport        int64                   `gorm:"column:is_export" json:"is_export" form:"is_export"`
419
-	LastAfterWeight AssessmentAfterDislysis `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
406
+	ID                  int64                   `gorm:"column:id" json:"id" form:"id"`
407
+	UserOrgId           int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
408
+	PartitionId         int64                   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
409
+	BedId               int64                   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
410
+	PatientId           int64                   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
411
+	ScheduleDate        int64                   `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
412
+	ScheduleType        int64                   `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
413
+	ScheduleWeek        int64                   `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
414
+	ModeId              int64                   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
415
+	Status              int64                   `gorm:"column:status" json:"status" form:"status"`
416
+	CreatedTime         int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
417
+	UpdatedTime         int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
418
+	IsExport            int64                   `gorm:"column:is_export" json:"is_export" form:"is_export"`
419
+	LastAfterWeight     AssessmentAfterDislysis `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
420
+	DialysisMachineName string                  `gorm:"column:dialysis_machine_name" json:"dialysis_machine_name" form:"dialysis_machine_name"`
420 421
 }
421 422
 
422 423
 func (XtSchedule) TableName() string {

+ 4 - 6
models/patient_schedule_template_models.go Bestand weergeven

@@ -16,12 +16,10 @@ func (PatientScheduleTemplateMode) TableName() string {
16 16
 }
17 17
 
18 18
 type PatientScheduleTemplateId struct {
19
-	ID         int64 `gorm:"column:id" json:"id" form:"id"`
20
-	OrgID      int64 `gorm:"column:org_id" json:"-" form:"org_id"`
21
-	Status     int8  `gorm:"column:status" json:"-" form:"status"`
22
-	CreateTime int64 `gorm:"column:ctime" json:"-" form:"ctime"`
23
-	ModifyTime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
24
-	Week       int   `gorm:"column:week" json:"week" form:"week"`
19
+	ID     int64 `gorm:"column:id" json:"id" form:"id"`
20
+	OrgID  int64 `gorm:"column:org_id" json:"-" form:"org_id"`
21
+	Status int8  `gorm:"column:status" json:"-" form:"status"`
22
+	Week   int   `gorm:"column:week" json:"week" form:"week"`
25 23
 }
26 24
 
27 25
 func (PatientScheduleTemplateId) TableName() string {

+ 43 - 21
models/smart_sch.go Bestand weergeven

@@ -1,9 +1,11 @@
1 1
 package models
2 2
 
3 3
 type SmartSchPatient struct {
4
-	ID            int64            `gorm:"column:id" json:"id" form:"id"`
5
-	UserOrgId     int64            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
-	Name          string           `gorm:"column:name" json:"name" form:"name"`
4
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	Name       string `gorm:"column:name" json:"name" form:"name"`
7
+	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
8
+
7 9
 	SmartSchedule []*SmartSchedule `gorm:"-" json:"sch"`
8 10
 }
9 11
 
@@ -12,9 +14,11 @@ func (SmartSchPatient) TableName() string {
12 14
 }
13 15
 
14 16
 type SmartSchTemplatePatient struct {
15
-	ID                          int64  `gorm:"column:id" json:"id" form:"id"`
16
-	UserOrgId                   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
17
-	Name                        string `gorm:"column:name" json:"name" form:"name"`
17
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
18
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
19
+	Name       string `gorm:"column:name" json:"name" form:"name"`
20
+	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
21
+
18 22
 	XtPatientScheduleTemplateId []*XtPatientScheduleTemplateId
19 23
 }
20 24
 
@@ -23,21 +27,22 @@ func (SmartSchTemplatePatient) TableName() string {
23 27
 }
24 28
 
25 29
 type SmartSchedule struct {
26
-	ID           int64        `gorm:"column:id" json:"id" form:"id"`
27
-	UserOrgId    int64        `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
28
-	PartitionId  int64        `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
29
-	BedId        int64        `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
30
-	PatientId    int64        `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
31
-	ScheduleDate int64        `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
32
-	ScheduleType int64        `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
33
-	ScheduleWeek int64        `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
34
-	ModeId       int64        `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
35
-	Status       int64        `gorm:"column:status" json:"status" form:"status"`
36
-	CreatedTime  int64        `gorm:"column:created_time" json:"created_time" form:"created_time"`
37
-	UpdatedTime  int64        `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
38
-	IsExport     int64        `gorm:"column:is_export" json:"is_export" form:"is_export"`
39
-	DeviceZone   DeviceZone   `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
40
-	DeviceNumber DeviceNumber `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
30
+	ID                 int64              `gorm:"column:id" json:"id" form:"id"`
31
+	UserOrgId          int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
32
+	PartitionId        int64              `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
33
+	BedId              int64              `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
34
+	PatientId          int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
35
+	ScheduleDate       int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
36
+	ScheduleType       int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
37
+	ScheduleWeek       int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
38
+	ModeId             int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
39
+	Status             int64              `gorm:"column:status" json:"status" form:"status"`
40
+	CreatedTime        int64              `gorm:"column:created_time" json:"created_time" form:"created_time"`
41
+	UpdatedTime        int64              `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
42
+	IsExport           int64              `gorm:"column:is_export" json:"is_export" form:"is_export"`
43
+	DeviceZone         DeviceZone         `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
44
+	DeviceNumber       DeviceNumber       `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
45
+	SmSchDialysisOrder SmSchDialysisOrder `json:"order" gorm:"foreignkey:BedId,PatientId,DialysisDate;AssociationForeignKey:BedId,PatientId,ScheduleDate;"`
41 46
 }
42 47
 
43 48
 func (SmartSchedule) TableName() string {
@@ -77,3 +82,20 @@ type XtPatientScheduleTemplateItem struct {
77 82
 func (XtPatientScheduleTemplateItem) TableName() string {
78 83
 	return "xt_patient_schedule_template_item"
79 84
 }
85
+
86
+type SmSchDialysisOrder struct {
87
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
88
+	DialysisDate int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
89
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
90
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
91
+	Stage        int64  `gorm:"column:stage" json:"stage" form:"stage"`
92
+	Remark       string `gorm:"column:remark" json:"remark" form:"remark"`
93
+	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
94
+	StartNurse   int64  `gorm:"column:start_nurse" json:"start_nurse" form:"start_nurse"`
95
+	FinishNurse  int64  `gorm:"column:finish_nurse" json:"finish_nurse" form:"finish_nurse"`
96
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
97
+}
98
+
99
+func (SmSchDialysisOrder) TableName() string {
100
+	return "xt_dialysis_order"
101
+}

Diff onderdrukt omdat het te groot bestand
+ 636 - 193
service/auto_create_week_schedules_service.go


+ 16 - 3
service/device_service.go Bestand weergeven

@@ -390,10 +390,23 @@ func UpdateDeviceGroup(group *models.DeviceGroup) error {
390 390
 
391 391
 //////// 机号 Number
392 392
 
393
+type DeviceNumberVM struct {
394
+	ID     int64  `gorm:"column:id" json:"id"`
395
+	OrgID  int64  `gorm:"column:org_id" json:"-"`
396
+	Number string `gorm:"column:number" json:"number"`
397
+	ZoneID int64  `gorm:"column:zone_id" json:"zone_id"`
398
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
399
+}
400
+
401
+func (DeviceNumberVM) TableName() string {
402
+	return "xt_device_number"
403
+}
404
+
393 405
 type DeviceNumberViewModel struct {
394
-	models.DeviceNumber
395
-	ZoneName  string `gorm:"column:zone_name" json:"zone_name"`
396
-	GroupName string `gorm:"column:group_name" json:"group_name"`
406
+	DeviceNumberVM
407
+	ZoneName  string              `gorm:"column:zone_name" json:"zone_name"`
408
+	GroupName string              `gorm:"column:group_name" json:"group_name"`
409
+	Zone      models.VMDeviceZone `gorm:"ForeignKey:ZoneID" json:"zone"`
397 410
 }
398 411
 
399 412
 func GetAllValidDeviceNumbers(orgID int64) ([]*DeviceNumberViewModel, error) {

+ 9 - 8
service/mobile_dialysis_service.go Bestand weergeven

@@ -2642,14 +2642,15 @@ func (GoodsType) TableName() string {
2642 2642
 }
2643 2643
 
2644 2644
 type VMGoodInfo struct {
2645
-	ID                int64   `gorm:"column:id" json:"id"`
2646
-	SpecificationName string  `gorm:"column:specification_name" json:"specification_name"`
2647
-	GoodTypeId        int64   `gorm:"column:good_type_id" json:"good_type_id"`
2648
-	OrgId             int64   `gorm:"column:org_id" json:"org_id"`
2649
-	GoodName          string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
2650
-	GoodUnit          int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
2651
-	Total             float64 `gorm:"column:total" json:"total" form:"total"`
2652
-	PackingUnit       string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
2645
+	ID                     int64   `gorm:"column:id" json:"id"`
2646
+	SpecificationName      string  `gorm:"column:specification_name" json:"specification_name"`
2647
+	GoodTypeId             int64   `gorm:"column:good_type_id" json:"good_type_id"`
2648
+	OrgId                  int64   `gorm:"column:org_id" json:"org_id"`
2649
+	GoodName               string  `gorm:"column:good_name" json:"good_name" form:"good_name"`
2650
+	GoodUnit               int64   `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
2651
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
2652
+	PackingUnit            string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
2653
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
2653 2654
 }
2654 2655
 
2655 2656
 func (VMGoodInfo) TableName() string {

+ 76 - 38
service/patient_schedule_template_service.go Bestand weergeven

@@ -47,10 +47,22 @@ func GetOrgPatientScheduleTemplateIDByTemplateID(orgID int64, templateID int64)
47 47
 	return &id, nil
48 48
 }
49 49
 
50
+type PatientsTwo struct {
51
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
52
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
53
+	UserId    int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
54
+	Name      string `gorm:"column:name" json:"name" form:"name"`
55
+}
56
+
57
+func (PatientsTwo) TableName() string {
58
+	return "xt_patients"
59
+}
60
+
50 61
 type PatientScheduleTemplateItemViewModel struct {
51 62
 	models.PatientScheduleTemplateItem
52 63
 
53
-	Patient *models.Patients `gorm:"ForeignKey:PatientID" json:"patient"`
64
+	Patient               *PatientsTwo          `gorm:"ForeignKey:PatientID" json:"patient"`
65
+	DeviceNumberViewModel DeviceNumberViewModel `gorm:"ForeignKey:DeviceNumberID" json:"devices"`
54 66
 }
55 67
 
56 68
 type PatientScheduleTemplateViewModel struct {
@@ -72,6 +84,7 @@ func GetOrgPatientScheduleTemplateItems(orgID int64) ([]*PatientScheduleTemplate
72 84
 		Model(&PatientScheduleTemplateViewModel{}).
73 85
 		Preload("Items", "org_id = ? AND status = 1", orgID).
74 86
 		Preload("Items.Patient", "user_org_id = ? AND status = 1", orgID).
87
+		Preload("Items.DeviceNumberViewModel.Zone", "status = 1").
75 88
 		Where("org_id = ? AND status = 1", orgID).
76 89
 		Limit(4).
77 90
 		Find(&vms).
@@ -117,41 +130,44 @@ type ScheduleDeviceNumberViewModel struct {
117 130
 	Zone *models.DeviceZone `gorm:"ForeignKey:ZoneID" json:"zone"`
118 131
 }
119 132
 
120
-func GetScheduleValidDeviceNumbers(orgID int64) ([]*ScheduleDeviceNumberViewModel, error) {
121
-	var vms []*ScheduleDeviceNumberViewModel
122
-	err := readDb.Model(&ScheduleDeviceNumberViewModel{}).Preload("Zone", "status = 1").Where("org_id = ? AND status = 1", orgID).Order("zone_id asc").Order("id asc").Find(&vms).Error
123
-	if err != nil {
124
-		return nil, err
133
+func GetScheduleValidDeviceNumbers(orgID int64, ids []string) ([]*ScheduleDeviceNumberViewModel, error) {
134
+	if len(ids) == 0 {
135
+		var vms []*ScheduleDeviceNumberViewModel
136
+		err := readDb.Model(&ScheduleDeviceNumberViewModel{}).Preload("Zone", "status = 1").Where("org_id = ? AND status = 1", orgID).Order("zone_id asc").Order("id asc").Find(&vms).Error
137
+		if err != nil {
138
+			return nil, err
139
+		}
140
+		return vms, nil
141
+
142
+	} else {
143
+		var vms []*ScheduleDeviceNumberViewModel
144
+		err := readDb.Model(&ScheduleDeviceNumberViewModel{}).Preload("Zone", "status = 1 AND id in (?)", ids).Where("org_id = ? AND status = 1", orgID).Order("zone_id asc").Order("id asc").Find(&vms).Error
145
+		if err != nil {
146
+			return nil, err
147
+		}
148
+		return vms, nil
149
+
125 150
 	}
126
-	return vms, nil
151
+
127 152
 }
128 153
 
129 154
 // 创建两个默认模板
130 155
 func CreateTwoPatientScheduleTemplates(orgID int64) (*PatientScheduleTemplateViewModel, *PatientScheduleTemplateViewModel, *PatientScheduleTemplateViewModel, *PatientScheduleTemplateViewModel, error) {
131
-	now := time.Now().Unix()
132 156
 	firstTemp := models.PatientScheduleTemplateId{}
133 157
 	firstTemp.OrgID = orgID
134 158
 	firstTemp.Status = 1
135
-	firstTemp.CreateTime = now
136
-	firstTemp.ModifyTime = now
137 159
 
138 160
 	secondTemp := models.PatientScheduleTemplateId{}
139 161
 	secondTemp.OrgID = orgID
140 162
 	secondTemp.Status = 1
141
-	secondTemp.CreateTime = now
142
-	secondTemp.ModifyTime = now
143 163
 
144 164
 	thirdTemp := models.PatientScheduleTemplateId{}
145 165
 	thirdTemp.OrgID = orgID
146 166
 	thirdTemp.Status = 1
147
-	thirdTemp.CreateTime = now
148
-	thirdTemp.ModifyTime = now
149 167
 
150 168
 	fourTemp := models.PatientScheduleTemplateId{}
151 169
 	fourTemp.OrgID = orgID
152 170
 	fourTemp.Status = 1
153
-	fourTemp.CreateTime = now
154
-	fourTemp.ModifyTime = now
155 171
 
156 172
 	tx := writeDb.Begin()
157 173
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&firstTemp).Error; err != nil {
@@ -194,12 +210,9 @@ func CreateTwoPatientScheduleTemplates(orgID int64) (*PatientScheduleTemplateVie
194 210
 }
195 211
 
196 212
 func CreatePatientScheduleTemplate(orgID int64) (*PatientScheduleTemplateViewModel, *PatientScheduleTemplateViewModel, *PatientScheduleTemplateViewModel, error) {
197
-	now := time.Now().Unix()
198 213
 	temp := models.PatientScheduleTemplateId{}
199 214
 	temp.OrgID = orgID
200 215
 	temp.Status = 1
201
-	temp.CreateTime = now
202
-	temp.ModifyTime = now
203 216
 	tx := writeDb.Begin()
204 217
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&temp).Error; err != nil {
205 218
 		tx.Rollback()
@@ -209,8 +222,6 @@ func CreatePatientScheduleTemplate(orgID int64) (*PatientScheduleTemplateViewMod
209 222
 	thirdTemp := models.PatientScheduleTemplateId{}
210 223
 	thirdTemp.OrgID = orgID
211 224
 	thirdTemp.Status = 1
212
-	thirdTemp.CreateTime = now
213
-	thirdTemp.ModifyTime = now
214 225
 
215 226
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&thirdTemp).Error; err != nil {
216 227
 		tx.Rollback()
@@ -220,8 +231,6 @@ func CreatePatientScheduleTemplate(orgID int64) (*PatientScheduleTemplateViewMod
220 231
 	fourTemp := models.PatientScheduleTemplateId{}
221 232
 	fourTemp.OrgID = orgID
222 233
 	fourTemp.Status = 1
223
-	fourTemp.CreateTime = now
224
-	fourTemp.ModifyTime = now
225 234
 
226 235
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&fourTemp).Error; err != nil {
227 236
 		tx.Rollback()
@@ -244,15 +253,12 @@ func CreatePatientScheduleTemplate(orgID int64) (*PatientScheduleTemplateViewMod
244 253
 	return &vm, &vm3, &vm4, nil
245 254
 }
246 255
 func CreatePatientScheduleTemplateTwo(orgID int64) (*PatientScheduleTemplateViewModel, *PatientScheduleTemplateViewModel, error) {
247
-	now := time.Now().Unix()
248 256
 
249 257
 	tx := writeDb.Begin()
250 258
 
251 259
 	thirdTemp := models.PatientScheduleTemplateId{}
252 260
 	thirdTemp.OrgID = orgID
253 261
 	thirdTemp.Status = 1
254
-	thirdTemp.CreateTime = now
255
-	thirdTemp.ModifyTime = now
256 262
 
257 263
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&thirdTemp).Error; err != nil {
258 264
 		tx.Rollback()
@@ -262,8 +268,6 @@ func CreatePatientScheduleTemplateTwo(orgID int64) (*PatientScheduleTemplateView
262 268
 	fourTemp := models.PatientScheduleTemplateId{}
263 269
 	fourTemp.OrgID = orgID
264 270
 	fourTemp.Status = 1
265
-	fourTemp.CreateTime = now
266
-	fourTemp.ModifyTime = now
267 271
 
268 272
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&fourTemp).Error; err != nil {
269 273
 		tx.Rollback()
@@ -282,13 +286,10 @@ func CreatePatientScheduleTemplateTwo(orgID int64) (*PatientScheduleTemplateView
282 286
 	return &vm3, &vm4, nil
283 287
 }
284 288
 func CreatePatientScheduleTemplateThree(orgID int64) (*PatientScheduleTemplateViewModel, error) {
285
-	now := time.Now().Unix()
286 289
 	tx := writeDb.Begin()
287 290
 	fourTemp := models.PatientScheduleTemplateId{}
288 291
 	fourTemp.OrgID = orgID
289 292
 	fourTemp.Status = 1
290
-	fourTemp.CreateTime = now
291
-	fourTemp.ModifyTime = now
292 293
 	if err := tx.Model(&models.PatientScheduleTemplateId{}).Create(&fourTemp).Error; err != nil {
293 294
 		tx.Rollback()
294 295
 		return nil, err
@@ -302,8 +303,9 @@ func CreatePatientScheduleTemplateThree(orgID int64) (*PatientScheduleTemplateVi
302 303
 }
303 304
 
304 305
 type PatientScheduleTemplatePatientVM struct {
305
-	ID   int64  `gorm:"column:id" json:"id" form:"id"`
306
-	Name string `gorm:"column:name" json:"name" form:"name"`
306
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
307
+	Name       string `gorm:"column:name" json:"name" form:"name"`
308
+	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
307 309
 
308 310
 	Contagions []*PatientScheduleContagion `gorm:"ForeignKey:PatientID" json:"contagions"`
309 311
 }
@@ -313,9 +315,10 @@ func (PatientScheduleTemplatePatientVM) TableName() string {
313 315
 }
314 316
 
315 317
 type PatientScheduleContagion struct {
316
-	ID        int64 `gorm:"column:id" json:"id" form:"id"`
317
-	PatientID int64 `gorm:"column:patient_id" json:"-"`
318
-	DiseaseID int64 `gorm:"column:disease_id" json:"disease_id" form:"disease_id"`
318
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
319
+	PatientID  int64  `gorm:"column:patient_id" json:"-"`
320
+	DiseaseID  int64  `gorm:"column:disease_id" json:"disease_id" form:"disease_id"`
321
+	DialysisNo string `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
319 322
 }
320 323
 
321 324
 func (PatientScheduleContagion) TableName() string {
@@ -346,12 +349,21 @@ func UpdateScheduleTemplate(orgID int64, template_id int64,
346 349
 	now := time.Now()
347 350
 	tx := writeDb.Begin()
348 351
 
352
+	readDb.Model(&models.XtPatientScheduleTemplateItem{}).Where("template_id = ? AND weekday = ? AND patient_id = ?", template_id)
353
+
349 354
 	// 批量插入 add template item
350 355
 	if len(addTemplateItems) > 0 {
356
+
351 357
 		// utils.TraceLog("addTemplateItems len: %v", len(addTemplateItems))
352 358
 		valueStrs := make([]string, 0, len(addTemplateItems))
353 359
 		values := make([]interface{}, 0, len(addTemplateItems)*10)
354 360
 		for _, item := range addTemplateItems {
361
+			var pst []models.XtPatientScheduleTemplateItem
362
+			readDb.Model(&models.XtPatientScheduleTemplateItem{}).Where("template_id = ? AND weekday = ? AND patient_id = ? AND status = 1", template_id, item.Weekday, item.PatientID).Find(&pst)
363
+			for _, item := range pst {
364
+				item.Status = 0
365
+				writeDb.Save(item)
366
+			}
355 367
 			valueStrs = append(valueStrs, "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
356 368
 			values = append(values, orgID)
357 369
 			values = append(values, template_id)
@@ -585,8 +597,33 @@ func SavePatientScheduleTemplateModeAndClearNextTwoWeekSchedules(templateMode *m
585 597
 	return nil
586 598
 }
587 599
 
588
-// 1 -> 2 清除第二周排班
589
-func SavePatientScheduleTemplateModeAndClearNextSecondWeekSchedules(templateMode *models.PatientScheduleTemplateMode) error {
600
+// 1 -> 3 清除第二周排班
601
+func SavePatientScheduleTemplateModeAndClearNextThirfWeekSchedules(templateMode *models.PatientScheduleTemplateMode) error {
602
+	tx := writeDb.Begin()
603
+	saveErr := tx.Save(templateMode).Error
604
+	if saveErr != nil {
605
+		tx.Rollback()
606
+		return saveErr
607
+	}
608
+
609
+	now := time.Now()
610
+	nextSecWeek := now.AddDate(0, 0, 21)
611
+	nextSecMonday, nextSecSunday := utils.GetMondayAndSundayOfWeekDate(&nextSecWeek)
612
+
613
+	//tx.Model(&models.PatientScheduleTemplateId{}).Where("user_org_id = ? AND status = 1", templateMode.OrgID, nextSecMonday.Unix(), nextSecSunday.Unix()).Updates(map[string]interface{}{"status": 0, "updated_time": now.Unix()}).Error
614
+
615
+	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", templateMode.OrgID, nextSecMonday.Unix(), nextSecSunday.Unix()).Updates(map[string]interface{}{"status": 0, "updated_time": now.Unix()}).Error
616
+	if disableErr != nil {
617
+		tx.Rollback()
618
+		return disableErr
619
+	}
620
+
621
+	tx.Commit()
622
+	return nil
623
+}
624
+
625
+// 1 -> 4 清除第二周排班
626
+func SavePatientScheduleTemplateModeAndClearNextFourWeekSchedules(templateMode *models.PatientScheduleTemplateMode) error {
590 627
 	tx := writeDb.Begin()
591 628
 	saveErr := tx.Save(templateMode).Error
592 629
 	if saveErr != nil {
@@ -609,6 +646,7 @@ func SavePatientScheduleTemplateModeAndClearNextSecondWeekSchedules(templateMode
609 646
 	tx.Commit()
610 647
 	return nil
611 648
 }
649
+
612 650
 func SaveTemplateMode(templateMode *models.PatientScheduleTemplateMode) error {
613 651
 	err := writeDb.Model(&models.PatientScheduleTemplateMode{}).Where("id = ? AND status = 1", templateMode.ID).Updates(map[string]interface{}{"mode": templateMode.Mode, "mtime": templateMode.ModifyTime}).Error
614 652
 	return err

+ 17 - 1
service/patient_service.go Bestand weergeven

@@ -1907,7 +1907,7 @@ func FindRemindAdvice(user_org_id int64, advice_name string, advice_desc string,
1907 1907
 }
1908 1908
 
1909 1909
 func UpdateScheduleByDeathTime(patientid int64, shcheduledate int64) error {
1910
-	err := XTWriteDB().Model(models.XtSchedule{}).Where("patient_id = ? and schedule_date>?", patientid, shcheduledate).Updates(map[string]interface{}{"status": 0}).Error
1910
+	err := XTWriteDB().Model(models.XtSchedule{}).Where("patient_id = ? and schedule_date > ?", patientid, shcheduledate).Updates(map[string]interface{}{"status": 0}).Error
1911 1911
 	return err
1912 1912
 }
1913 1913
 
@@ -2675,3 +2675,19 @@ func GetDialysisSolutionDetailList(orgid int64, patient_id int64, mode_id int64,
2675 2675
 	err = db.Count(&total).Offset(offset).Limit(limit).Find(&solution).Order("created_time desc").Error
2676 2676
 	return solution, total, err
2677 2677
 }
2678
+
2679
+func GetAllSchedulesByPatientInfo(org_id int64, patient_id int64, mode_id int64) ([]Schedule, error) {
2680
+	var record []Schedule
2681
+	loc, _ := time.LoadLocation("Local")
2682
+	date, _ := time.ParseInLocation("2006-01-02 15:04:05", time.Now().Format("2006-01-02")+" 00:00:00", loc)
2683
+
2684
+	err := readDb.Model(&Schedule{}).Where("status = 1 AND schedule_date >= ? AND patient_id = ? AND user_org_id = ? AND mode_id= ?", date, patient_id, org_id, mode_id).Find(&record).Error
2685
+	if err != nil {
2686
+		if err == gorm.ErrRecordNotFound {
2687
+			return nil, nil
2688
+		} else {
2689
+			return nil, err
2690
+		}
2691
+	}
2692
+	return record, nil
2693
+}

+ 9 - 9
service/schedule_service.go Bestand weergeven

@@ -18,14 +18,14 @@ func GetSchedulePartitionPanel(orgID int64) (partitions []*models.Partition, err
18 18
 	return
19 19
 }
20 20
 
21
-func GetSchedulePartitionPanelOne(orgID int64, partionId int64) (partitions []*models.Partition, err error) {
21
+func GetSchedulePartitionPanelOne(orgID int64, partionId []string) (partitions []*models.Partition, err error) {
22 22
 
23
-	if partionId > 0 {
24
-		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1 and zone_id = ?", orgID, partionId).Where("org_id=? and status=1 and id = ?", orgID, partionId).Find(&partitions).Error
25
-	}
26
-	if partionId == 0 {
27
-		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Find(&partitions).Error
28
-	}
23
+	//if len(partionId) > 0 {
24
+	//	err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1 and zone_id in (?)", orgID, partionId).Where("org_id=? and status=1 and id  ?", orgID, partionId).Find(&partitions).Error
25
+	//}
26
+	//if len(partionId) == 0 {
27
+	err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Find(&partitions).Error
28
+	//}
29 29
 
30 30
 	return
31 31
 }
@@ -306,8 +306,8 @@ func UpdateScheduleTwo(schone models.Schedule, schtwo models.Schedule) {
306 306
 	tempPatientIDTwo = schtwo.PatientId
307 307
 	schone.PatientId = tempPatientIDTwo
308 308
 	schtwo.PatientId = tempPatientID
309
-	utx.Save(schone)
310
-	utx.Save(schtwo)
309
+	utx.Save(&schone)
310
+	utx.Save(&schtwo)
311 311
 
312 312
 }
313 313
 

+ 6 - 1
service/smart_sch.go Bestand weergeven

@@ -2,6 +2,7 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
5 6
 	"time"
6 7
 )
7 8
 
@@ -26,6 +27,7 @@ func GetSmartSchPatientByKeyWord(orgID int64, keywords string) (patient []*model
26 27
 		weekStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
27 28
 		readDb.Model(&models.SmartSchedule{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND schedule_date >= ?", orgID, item.ID, weekStart.Unix()).
28 29
 			Preload("DeviceZone", "status = 1").
30
+			Preload("SmSchDialysisOrder", "status = 1").
29 31
 			Preload("DeviceNumber", "status = 1").Find(&sch)
30 32
 		item.SmartSchedule = sch
31 33
 	}
@@ -79,12 +81,15 @@ func GetSmartSchPatientByID(orgID int64, patient_id int64) (schs []*models.Smart
79 81
 	weekStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, offset)
80 82
 	err = readDb.Model(&models.SmartSchedule{}).Where("user_org_id = ? AND status = 1 AND patient_id = ? AND schedule_date >= ?", orgID, patient_id, weekStart.Unix()).
81 83
 		Preload("DeviceZone", "status = 1").
84
+		Preload("SmSchDialysisOrder", "status = 1").
82 85
 		Preload("DeviceNumber", "status = 1").Find(&schs).Error
83 86
 	return
84 87
 }
85 88
 
86 89
 func GetSmartSchTemplatePatientByID(orgID int64, patient_id int64, count int) (schs []*models.XtPatientScheduleTemplateId, err error) {
87
-	err = readDb.Model(&models.XtPatientScheduleTemplateId{}).Preload("XtPatientScheduleTemplateItem", "status=1 AND patient_id = ?", patient_id).Where("org_id = ? AND status = 1", orgID).Limit(count).Find(&schs).Error
90
+	err = readDb.Model(&models.XtPatientScheduleTemplateId{}).Preload("XtPatientScheduleTemplateItem", func(db *gorm.DB) *gorm.DB {
91
+		return db.Where("status = 1 AND patient_id = ?", patient_id).Order("weekday")
92
+	}).Where("org_id = ? AND status = 1", orgID).Limit(count).Find(&schs).Error
88 93
 	for _, items := range schs {
89 94
 		for _, subItems := range items.XtPatientScheduleTemplateItem {
90 95
 			number, _ := GetBedNumberById(subItems.DeviceNumberId, subItems.OrgId)

+ 1 - 0
utils/tools.go Bestand weergeven

@@ -226,6 +226,7 @@ func GetMondayAndSundayOfWeekDate(date *time.Time) (time.Time, time.Time) {
226 226
 	}
227 227
 	loc, _ := time.LoadLocation("Local")
228 228
 	monday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 1-weekday).Format("2006-01-02")+" 00:00:00", loc)
229
+
229 230
 	sunday, _ := time.ParseInLocation("2006-01-02 15:04:05", date.AddDate(0, 0, 7-weekday).Format("2006-01-02")+" 23:59:59", loc)
230 231
 	return monday, sunday
231 232
 }