Browse Source

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

陈少旭 1 year ago
parent
commit
fa2afc7185
36 changed files with 1401 additions and 100 deletions
  1. 167 16
      controllers/dialysis_api_controller.go
  2. 6 7
      controllers/dialysis_record_api_controller.go
  3. 45 0
      controllers/doctors_api_controller.go
  4. 54 2
      controllers/his_api_controller.go
  5. 4 0
      controllers/his_project_api_controller.go
  6. 285 0
      controllers/manage_api_controller.go
  7. 3 0
      controllers/mobile_api_controllers/check_weight_api_controller.go
  8. 92 15
      controllers/mobile_api_controllers/dialysis_api_controller.go
  9. 3 3
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  10. 0 2
      controllers/mobile_api_controllers/mobile_api_base_controller.go
  11. 12 9
      controllers/mobile_api_controllers/patient_api_controller.go
  12. 12 0
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  13. 31 10
      controllers/patient_api_controller.go
  14. 52 1
      controllers/patient_dataconfig_api_controller.go
  15. 10 5
      controllers/print_data_api_controller.go
  16. 0 1
      controllers/schedule_api_controller.go
  17. 27 0
      controllers/self_drug_api_congtroller.go
  18. 3 1
      controllers/stock_in_api_controller.go
  19. 1 1
      main.go
  20. 23 0
      models/device_models.go
  21. 1 0
      models/dialysis.go
  22. 2 0
      models/his_models.go
  23. 26 4
      models/patient_models.go
  24. 24 0
      models/schedule_models.go
  25. 28 0
      service/dialysis_solution_service.go
  26. 17 0
      service/doctor_schedule_service.go
  27. 1 1
      service/his_project_service.go
  28. 1 1
      service/his_service.go
  29. 4 4
      service/inspection_service.go
  30. 1 1
      service/manage_center_service.go
  31. 53 0
      service/manage_service.go
  32. 305 9
      service/mobile_dialysis_service.go
  33. 47 4
      service/patient_service.go
  34. 24 1
      service/self_drug_service.go
  35. 36 1
      service/stock_service.go
  36. 1 1
      service/user_service.go

+ 167 - 16
controllers/dialysis_api_controller.go View File

121
 	beego.Router("/api/patient/checkdialysisinformation", &DialysisApiController{}, "Get:CheckDialysisInformation")
121
 	beego.Router("/api/patient/checkdialysisinformation", &DialysisApiController{}, "Get:CheckDialysisInformation")
122
 
122
 
123
 	beego.Router("/api/dialysis/patientsflow", &DialysisApiController{}, "Get:GetDialysisPatientsFlow")
123
 	beego.Router("/api/dialysis/patientsflow", &DialysisApiController{}, "Get:GetDialysisPatientsFlow")
124
+
125
+	beego.Router("/api/patient/getlongdialysisadvicetoday", &DialysisApiController{}, "Get:GetLongDialysisAdviceToday")
124
 }
126
 }
125
 
127
 
126
 func (c *DialysisApiController) GetQueueCall() {
128
 func (c *DialysisApiController) GetQueueCall() {
623
 		// 查询信息规挡的设置天数
625
 		// 查询信息规挡的设置天数
624
 
626
 
625
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
627
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
626
-		if infor.ID > 0 {
628
+		if infor.ID > 0 && infor.WeekDay > 0 {
627
 
629
 
628
 			var cha_time int64
630
 			var cha_time int64
629
 
631
 
738
 		// 查询信息规挡的设置天数
740
 		// 查询信息规挡的设置天数
739
 
741
 
740
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
742
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
741
-		if infor.ID > 0 {
743
+		if infor.ID > 0 && infor.WeekDay > 0 {
742
 
744
 
743
 			var cha_time int64
745
 			var cha_time int64
744
 
746
 
762
 
764
 
763
 		updateErr := service.UpDateDialysisPrescription(&prescription)
765
 		updateErr := service.UpDateDialysisPrescription(&prescription)
764
 
766
 
767
+		//创建步骤表
768
+		finish := models.XtDialysisFinish{
769
+			IsFinish:   1,
770
+			UserOrgId:  adminUserInfo.CurrentOrgId,
771
+			Status:     1,
772
+			Ctime:      time.Now().Unix(),
773
+			Mtime:      0,
774
+			Module:     1,
775
+			RecordDate: recordDate.Unix(),
776
+			Sourse:     1,
777
+			PatientId:  patient,
778
+		}
779
+
780
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1, patient)
781
+		if dialysisFinish.ID == 0 {
782
+			service.CreateDialysisFinish(finish)
783
+		}
765
 		//修改处方
784
 		//修改处方
766
 		if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 10340 {
785
 		if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 10340 {
767
 			// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
786
 			// 患者的临时医嘱里查找是否有抗凝剂临时医嘱
976
 	// 查询信息规挡的设置天数
995
 	// 查询信息规挡的设置天数
977
 
996
 
978
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
997
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
979
-	if infor.ID > 0 {
998
+	if infor.ID > 0 && infor.WeekDay > 0 {
980
 		var cha_time int64
999
 		var cha_time int64
981
 
1000
 
982
 		timeNowStr := time.Now().Format("2006-01-02")
1001
 		timeNowStr := time.Now().Format("2006-01-02")
1327
 
1346
 
1328
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
1347
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
1329
 
1348
 
1349
+	//创建步骤表
1350
+	finishOne := models.XtDialysisFinish{
1351
+		IsFinish:   1,
1352
+		UserOrgId:  adminUserInfo.CurrentOrgId,
1353
+		Status:     1,
1354
+		Ctime:      time.Now().Unix(),
1355
+		Mtime:      0,
1356
+		Module:     1,
1357
+		RecordDate: recordDate.Unix(),
1358
+		Sourse:     1,
1359
+		PatientId:  patient,
1360
+	}
1361
+
1362
+	dialysisFinishOne, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1, patient)
1363
+	if dialysisFinishOne.ID == 0 {
1364
+		service.CreateDialysisFinish(finishOne)
1365
+	}
1330
 	//获取最新1条
1366
 	//获取最新1条
1331
 	dialysisSolution, _ := service.GetLastPatientDialysisSolution(patient, adminUserInfo.CurrentOrgId)
1367
 	dialysisSolution, _ := service.GetLastPatientDialysisSolution(patient, adminUserInfo.CurrentOrgId)
1332
 
1368
 
1571
 	// 查询信息规挡的设置天数
1607
 	// 查询信息规挡的设置天数
1572
 
1608
 
1573
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1609
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1574
-	if infor.ID > 0 {
1610
+	if infor.ID > 0 && infor.WeekDay > 0 {
1575
 
1611
 
1576
 		var cha_time int64
1612
 		var cha_time int64
1577
 
1613
 
1777
 	// 查询信息规挡的设置天数
1813
 	// 查询信息规挡的设置天数
1778
 
1814
 
1779
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1815
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1780
-	if infor.ID > 0 {
1816
+	if infor.ID > 0 && infor.WeekDay > 0 {
1781
 
1817
 
1782
 		var cha_time int64
1818
 		var cha_time int64
1783
 
1819
 
1846
 		//	}
1882
 		//	}
1847
 		//}
1883
 		//}
1848
 
1884
 
1885
+		// 查询信息规挡的设置天数
1886
+
1887
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1888
+		if infor.ID > 0 && infor.WeekDay > 0 {
1889
+			var cha_time int64
1890
+			timeNowStr := time.Now().Format("2006-01-02")
1891
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1892
+
1893
+			//今日的日期减去设置的日期
1894
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1895
+
1896
+			if cha_time >= recordDate.Unix() {
1897
+				//查询审核是否允许
1898
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
1899
+				//申请状态不允许的情况 拒绝修改
1900
+				if infor.ApplicationStatus != 1 {
1901
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1902
+					return
1903
+				}
1904
+
1905
+			}
1906
+		}
1907
+
1849
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
1908
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
1850
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
1909
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
1851
 		receiveTreatmentAsses.UpdateTime = time.Now().Unix()
1910
 		receiveTreatmentAsses.UpdateTime = time.Now().Unix()
2298
 		// 查询信息规挡的设置天数
2357
 		// 查询信息规挡的设置天数
2299
 
2358
 
2300
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2359
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2301
-		if infor.ID > 0 {
2360
+		if infor.ID > 0 && infor.WeekDay > 0 {
2302
 
2361
 
2303
 			var cha_time int64
2362
 			var cha_time int64
2304
 
2363
 
2432
 				newprescribe.RecordDate = recordDate.Unix()
2491
 				newprescribe.RecordDate = recordDate.Unix()
2433
 				newprescribe.DewaterAmount = dewater_amount
2492
 				newprescribe.DewaterAmount = dewater_amount
2434
 				newprescribe.TargetUltrafiltration = dewater_amount
2493
 				newprescribe.TargetUltrafiltration = dewater_amount
2494
+				newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2435
 				newprescribe.Status = 1
2495
 				newprescribe.Status = 1
2436
 
2496
 
2437
 				err := service.AddSigleRecord(&newprescribe)
2497
 				err := service.AddSigleRecord(&newprescribe)
2490
 					newprescribe.Status = 1
2550
 					newprescribe.Status = 1
2491
 					newprescribe.Creater = adminUserInfo.AdminUser.Id
2551
 					newprescribe.Creater = adminUserInfo.AdminUser.Id
2492
 					newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
2552
 					newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
2553
+					newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2493
 
2554
 
2494
 					err := service.AddSigleRecord(&newprescribe)
2555
 					err := service.AddSigleRecord(&newprescribe)
2495
 					key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2556
 					key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2687
 			newprescribe.RecordDate = recordDate.Unix()
2748
 			newprescribe.RecordDate = recordDate.Unix()
2688
 			newprescribe.DewaterAmount = dewater_amount
2749
 			newprescribe.DewaterAmount = dewater_amount
2689
 			newprescribe.TargetUltrafiltration = dewater_amount
2750
 			newprescribe.TargetUltrafiltration = dewater_amount
2751
+			newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2690
 			newprescribe.Status = 1
2752
 			newprescribe.Status = 1
2691
 
2753
 
2692
 			err := service.AddSigleRecord(&newprescribe)
2754
 			err := service.AddSigleRecord(&newprescribe)
2742
 				newprescribe.RecordDate = recordDate.Unix()
2804
 				newprescribe.RecordDate = recordDate.Unix()
2743
 				newprescribe.DewaterAmount = dewater_amount
2805
 				newprescribe.DewaterAmount = dewater_amount
2744
 				newprescribe.TargetUltrafiltration = dewater_amount
2806
 				newprescribe.TargetUltrafiltration = dewater_amount
2807
+				newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2745
 				newprescribe.Status = 1
2808
 				newprescribe.Status = 1
2746
 
2809
 
2747
 				err := service.AddSigleRecord(&newprescribe)
2810
 				err := service.AddSigleRecord(&newprescribe)
2814
 		}
2877
 		}
2815
 
2878
 
2816
 		err := service.UpadatePredialysisEvaluation(&assessmentBeforeDislysis)
2879
 		err := service.UpadatePredialysisEvaluation(&assessmentBeforeDislysis)
2880
+
2881
+		//创建步骤表
2882
+		finish := models.XtDialysisFinish{
2883
+			IsFinish:   1,
2884
+			UserOrgId:  adminUserInfo.CurrentOrgId,
2885
+			Status:     1,
2886
+			Ctime:      time.Now().Unix(),
2887
+			Mtime:      0,
2888
+			Module:     3,
2889
+			RecordDate: recordDate.Unix(),
2890
+			Sourse:     1,
2891
+			PatientId:  patient,
2892
+		}
2893
+
2894
+		dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 3, patient)
2895
+		if dialysisFinish.ID == 0 {
2896
+			service.CreateDialysisFinish(finish)
2897
+		}
2817
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
2898
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
2818
 		redis := service.RedisClient()
2899
 		redis := service.RedisClient()
2819
 		//清空key 值
2900
 		//清空key 值
2895
 		// 查询信息规挡的设置天数
2976
 		// 查询信息规挡的设置天数
2896
 
2977
 
2897
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2978
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2898
-		if infor.ID > 0 {
2979
+		if infor.ID > 0 && infor.WeekDay > 0 {
2899
 
2980
 
2900
 			var cha_time int64
2981
 			var cha_time int64
2901
 
2982
 
2964
 		//	}
3045
 		//	}
2965
 		//}
3046
 		//}
2966
 
3047
 
3048
+		// 查询信息规挡的设置天数
3049
+
3050
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3051
+		if infor.ID > 0 && infor.WeekDay > 0 {
3052
+			var cha_time int64
3053
+			timeNowStr := time.Now().Format("2006-01-02")
3054
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
3055
+
3056
+			//今日的日期减去设置的日期
3057
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
3058
+
3059
+			if cha_time >= recordDate.Unix() {
3060
+				//查询审核是否允许
3061
+				infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
3062
+				//申请状态不允许的情况 拒绝修改
3063
+				if infor.ApplicationStatus != 1 {
3064
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
3065
+					return
3066
+				}
3067
+			}
3068
+		}
3069
+
2967
 		treatmentSummary.Creater = tempTreatmentSummary.Creater
3070
 		treatmentSummary.Creater = tempTreatmentSummary.Creater
2968
 		treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
3071
 		treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
2969
 		treatmentSummary.UpdatedTime = time.Now().Unix()
3072
 		treatmentSummary.UpdatedTime = time.Now().Unix()
3465
 	// 查询信息规挡的设置天数
3568
 	// 查询信息规挡的设置天数
3466
 
3569
 
3467
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.CurrentOrgId)
3570
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.CurrentOrgId)
3468
-	if infor.ID > 0 {
3571
+	if infor.ID > 0 && infor.WeekDay > 0 {
3469
 
3572
 
3470
 		var cha_time int64
3573
 		var cha_time int64
3471
 
3574
 
3612
 	// 查询信息规挡的设置天数
3715
 	// 查询信息规挡的设置天数
3613
 
3716
 
3614
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3717
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3615
-	if infor.ID > 0 {
3718
+	if infor.ID > 0 && infor.WeekDay > 0 {
3616
 
3719
 
3617
 		var cha_time int64
3720
 		var cha_time int64
3618
 
3721
 
6731
 
6834
 
6732
 	patient_id, _ := this.GetInt64("patient_id")
6835
 	patient_id, _ := this.GetInt64("patient_id")
6733
 	record_date, _ := this.GetInt64("record_date")
6836
 	record_date, _ := this.GetInt64("record_date")
6734
-	adviceDate := this.GetString("selected_date")
6735
-	timeLayout2 := "2006-01-02"
6736
-	loc2, _ := time.LoadLocation("Local")
6737
-	theTime, _ := time.ParseInLocation(timeLayout2, adviceDate, loc2)
6738
-	AdviceDate := theTime.Unix()
6837
+	startTime := this.GetString("selected_date")
6838
+
6839
+	timeLayout := "2006-01-02 15:04"
6840
+	loc, _ := time.LoadLocation("Local")
6841
+
6842
+	if len(startTime) == 0 {
6843
+		utils.ErrorLog("len(start_time) == 0")
6844
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6845
+		return
6846
+	}
6847
+	theTime, err := time.ParseInLocation(timeLayout, startTime, loc)
6848
+	if err != nil {
6849
+		utils.ErrorLog(err.Error())
6850
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
6851
+		return
6852
+	}
6853
+	StartTime := theTime.Unix()
6854
+	fmt.Println("startime-------------", StartTime)
6739
 
6855
 
6740
 	module, _ := this.GetInt64("module")
6856
 	module, _ := this.GetInt64("module")
6741
 
6857
 
6748
 		Module:            module,
6864
 		Module:            module,
6749
 		PatientId:         patient_id,
6865
 		PatientId:         patient_id,
6750
 		RecordDate:        record_date,
6866
 		RecordDate:        record_date,
6751
-		ApplicationDate:   AdviceDate,
6867
+		ApplicationDate:   StartTime,
6752
 		Creater:           creater,
6868
 		Creater:           creater,
6753
 		ApplicationStatus: 2,
6869
 		ApplicationStatus: 2,
6754
 		Checker:           0,
6870
 		Checker:           0,
6771
 		}
6887
 		}
6772
 	}
6888
 	}
6773
 	if infor.ID > 0 {
6889
 	if infor.ID > 0 {
6774
-		err := service.UpdateDialysisInformationById(patient_id, record_date, orgId, module, AdviceDate, remark)
6890
+		err := service.UpdateDialysisInformationById(patient_id, record_date, orgId, module, StartTime, remark)
6775
 		if err == nil {
6891
 		if err == nil {
6776
 			this.ServeSuccessJSON(map[string]interface{}{
6892
 			this.ServeSuccessJSON(map[string]interface{}{
6777
 				"information": information,
6893
 				"information": information,
6781
 	}
6897
 	}
6782
 
6898
 
6783
 }
6899
 }
6900
+
6901
+func (this *DialysisApiController) GetLongDialysisAdviceToday() {
6902
+
6903
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6904
+
6905
+	schedule_type, _ := this.GetInt64("schedule_type")
6906
+
6907
+	partion_type := this.GetString("partion_type")
6908
+	var ids []string
6909
+	ids = strings.Split(partion_type, ",")
6910
+	start_time := this.GetString("selected_date")
6911
+	timeLayout := "2006-01-02"
6912
+	loc, _ := time.LoadLocation("Local")
6913
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
6914
+
6915
+	list, err := service.GetLongDialysisAdviceToday(orgId, schedule_type, ids, startTime.Unix())
6916
+
6917
+	drug, _ := service.GetAllBaseDrugListTwenty(orgId)
6918
+	_, config := service.FindXTHisRecordByOrgId(orgId)
6919
+	appId := this.GetAdminUserInfo().CurrentAppId
6920
+	doctorList, _ := service.GetAllAdminUsers(orgId, appId)
6921
+	if err == nil {
6922
+		this.ServeSuccessJSON(map[string]interface{}{
6923
+			"list":       list,
6924
+			"drug":       drug,
6925
+			"config":     config,
6926
+			"doctorList": doctorList,
6927
+		})
6928
+		return
6929
+
6930
+	} else {
6931
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
6932
+		return
6933
+	}
6934
+}

+ 6 - 7
controllers/dialysis_record_api_controller.go View File

638
 	// 查询信息规挡的设置天数
638
 	// 查询信息规挡的设置天数
639
 
639
 
640
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
640
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
641
-	if infor.ID > 0 {
641
+	if infor.ID > 0 && infor.WeekDay > 0 {
642
 
642
 
643
 		var cha_time int64
643
 		var cha_time int64
644
 
644
 
647
 
647
 
648
 		//今日的日期减去设置的日期
648
 		//今日的日期减去设置的日期
649
 		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
649
 		cha_time = timeNewDate.Unix() - infor.WeekDay*86400
650
-
651
-		if cha_time >= scheduleDate {
650
+		if cha_time >= scheduleDate && infor.WeekDay != 0 {
652
 			//查询审核是否允许
651
 			//查询审核是否允许
653
 			infor, _ := service.GetDialysisInformationByRecordDate(patientID, scheduleDate, adminUserInfo.CurrentOrgId)
652
 			infor, _ := service.GetDialysisInformationByRecordDate(patientID, scheduleDate, adminUserInfo.CurrentOrgId)
654
 			//申请状态不允许的情况 拒绝修改
653
 			//申请状态不允许的情况 拒绝修改
1055
 	// 查询信息规挡的设置天数
1054
 	// 查询信息规挡的设置天数
1056
 
1055
 
1057
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1056
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1058
-	if infor.ID > 0 {
1057
+	if infor.ID > 0 && infor.WeekDay > 0 {
1059
 
1058
 
1060
 		var cha_time int64
1059
 		var cha_time int64
1061
 
1060
 
1691
 	// 查询信息规挡的设置天数
1690
 	// 查询信息规挡的设置天数
1692
 
1691
 
1693
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1692
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1694
-	if infor.ID > 0 {
1693
+	if infor.ID > 0 && infor.WeekDay > 0 {
1695
 
1694
 
1696
 		var cha_time int64
1695
 		var cha_time int64
1697
 
1696
 
1952
 	}
1951
 	}
1953
 
1952
 
1954
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1953
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1955
-	if infor.ID > 0 {
1954
+	if infor.ID > 0 && infor.WeekDay > 0 {
1956
 
1955
 
1957
 		var cha_time int64
1956
 		var cha_time int64
1958
 
1957
 
2110
 	// 查询信息规挡的设置天数
2109
 	// 查询信息规挡的设置天数
2111
 
2110
 
2112
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2111
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2113
-	if infor.ID > 0 {
2112
+	if infor.ID > 0 && infor.WeekDay > 0 {
2114
 
2113
 
2115
 		var cha_time int64
2114
 		var cha_time int64
2116
 
2115
 

+ 45 - 0
controllers/doctors_api_controller.go View File

65
 	beego.Router("/api/patient/getfirstdetailbyid", &DoctorsApiController{}, "Get:GetFirstDetailById")
65
 	beego.Router("/api/patient/getfirstdetailbyid", &DoctorsApiController{}, "Get:GetFirstDetailById")
66
 	beego.Router("/api/patient/updatefirstdisease", &DoctorsApiController{}, "Post:UpdateFirstDisease")
66
 	beego.Router("/api/patient/updatefirstdisease", &DoctorsApiController{}, "Post:UpdateFirstDisease")
67
 	beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
67
 	beego.Router("/api/patient/deletefirstdisease", &DoctorsApiController{}, "Get:DeleteFirstDisease")
68
+
69
+	beego.Router("/api/schedule/new/long/advices", &DoctorsApiController{}, "Get:GetLongScheduleAdvicesList")
68
 }
70
 }
69
 
71
 
70
 func (c *DoctorsApiController) ScheduleAdvices() {
72
 func (c *DoctorsApiController) ScheduleAdvices() {
1626
 	c.ServeSuccessJSON(returnData)
1628
 	c.ServeSuccessJSON(returnData)
1627
 	return
1629
 	return
1628
 }
1630
 }
1631
+
1632
+func (c *DoctorsApiController) GetLongScheduleAdvicesList() {
1633
+
1634
+	schedualDate := c.GetString("date")
1635
+	adviceType, _ := c.GetInt("advice_type")
1636
+	patientType, _ := c.GetInt("patient_type")
1637
+	delivery_way := c.GetString("delivery_way")
1638
+	schedule_type, _ := c.GetInt64("schedule_type")
1639
+	partition_type, _ := c.GetInt64("partition_type")
1640
+	patient_id, _ := c.GetInt64("patient_id")
1641
+	excution_way, _ := c.GetInt64("excution_way")
1642
+	cost_type, _ := c.GetInt64("cost_type")
1643
+	execution_frequency := c.GetString("execution_frequency")
1644
+
1645
+	date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
1646
+	if parseDateErr != nil {
1647
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1648
+		return
1649
+	}
1650
+
1651
+	adminUserInfo := c.GetAdminUserInfo()
1652
+	orgID := adminUserInfo.CurrentOrgId
1653
+
1654
+	scheduals, err := service.MobileGetLongScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way, cost_type, execution_frequency)
1655
+
1656
+	adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
1657
+	if err != nil {
1658
+		c.ErrorLog("获取排班信息失败:%v", err)
1659
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1660
+	} else {
1661
+		filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
1662
+		for _, schedual := range scheduals {
1663
+			if len(schedual.DoctorAdvices) > 0 {
1664
+				filtedScheduals = append(filtedScheduals, schedual)
1665
+			}
1666
+		}
1667
+		c.ServeSuccessJSON(map[string]interface{}{
1668
+			"scheduals": filtedScheduals,
1669
+			"adminUser": adminUser,
1670
+		})
1671
+	}
1672
+
1673
+}

+ 54 - 2
controllers/his_api_controller.go View File

2636
 			PatientDiagnosis:   patient_diagnose,
2636
 			PatientDiagnosis:   patient_diagnose,
2637
 		}
2637
 		}
2638
 		service.SavePatientPrescriptionInfo(hpInfo)
2638
 		service.SavePatientPrescriptionInfo(hpInfo)
2639
+		//创建步骤表
2640
+		finish := models.XtDialysisFinish{
2641
+			IsFinish:   1,
2642
+			UserOrgId:  adminInfo.CurrentOrgId,
2643
+			Status:     1,
2644
+			Ctime:      time.Now().Unix(),
2645
+			Mtime:      0,
2646
+			Module:     4,
2647
+			RecordDate: theTime.Unix(),
2648
+			Sourse:     1,
2649
+			PatientId:  patient_id,
2650
+		}
2651
+
2652
+		dialysisFinish, _ := service.GetDialysisFinish(adminInfo.CurrentOrgId, theTime.Unix(), 4, patient_id)
2653
+		if dialysisFinish.ID == 0 {
2654
+			service.CreateDialysisFinish(finish)
2655
+		}
2639
 		redis := service.RedisClient()
2656
 		redis := service.RedisClient()
2640
 		key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
2657
 		key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
2641
 		redis.Set(key, "", time.Second)
2658
 		redis.Set(key, "", time.Second)
2669
 			PatientDiagnosis:   patient_diagnose,
2686
 			PatientDiagnosis:   patient_diagnose,
2670
 		}
2687
 		}
2671
 		service.SavePatientPrescriptionInfo(hpInfo)
2688
 		service.SavePatientPrescriptionInfo(hpInfo)
2689
+		//创建步骤表
2690
+		finish := models.XtDialysisFinish{
2691
+			IsFinish:   1,
2692
+			UserOrgId:  adminInfo.CurrentOrgId,
2693
+			Status:     1,
2694
+			Ctime:      time.Now().Unix(),
2695
+			Mtime:      0,
2696
+			Module:     4,
2697
+			RecordDate: info.RecordDate,
2698
+			Sourse:     1,
2699
+			PatientId:  info.PatientId,
2700
+		}
2701
+
2702
+		dialysisFinish, _ := service.GetDialysisFinish(adminInfo.CurrentOrgId, info.RecordDate, 4, info.PatientId)
2703
+		if dialysisFinish.ID == 0 {
2704
+			service.CreateDialysisFinish(finish)
2705
+		}
2672
 		redis := service.RedisClient()
2706
 		redis := service.RedisClient()
2673
 		key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
2707
 		key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
2674
 		redis.Set(key, "", time.Second)
2708
 		redis.Set(key, "", time.Second)
2846
 							if s.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
2880
 							if s.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
2847
 								total_count += prescribingNumberSeven
2881
 								total_count += prescribingNumberSeven
2848
 							}
2882
 							}
2883
+							if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 3877 {
2884
+								storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
2885
+								lastWarehouse, _ := service.FindLastDrugWarehousingInfoByID(s.DrugId, storeConfig.DrugStorehouseOut)
2886
+								if s.Price != lastWarehouse.RetailPrice {
2887
+									s.Price = lastWarehouse.RetailPrice
2888
+								}
2889
+							}
2890
+
2849
 							service.CreateHisDoctorAdvice(&s)
2891
 							service.CreateHisDoctorAdvice(&s)
2850
 
2892
 
2851
 							//存储切片中
2893
 							//存储切片中
2907
 								projectDetail, _ := service.GetHisPrescriptonProjectById(p.ID)
2949
 								projectDetail, _ := service.GetHisPrescriptonProjectById(p.ID)
2908
 								p.IsOut = projectDetail.IsOut
2950
 								p.IsOut = projectDetail.IsOut
2909
 							}
2951
 							}
2952
+							if adminInfo.CurrentOrgId == 10215 || adminInfo.CurrentOrgId == 3877 {
2953
+								storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
2954
+								if p.Type == 3 {
2955
+									lastWarehouse, _ := service.FindFirstWarehousingInfoByStockThree(p.ProjectId, storeConfig.DrugStorehouseOut)
2956
+									if p.Price != lastWarehouse.PackingPrice {
2957
+										p.Price = lastWarehouse.PackingPrice
2958
+									}
2959
+								}
2960
+
2961
+							}
2962
+
2910
 							service.CreateHisProjectTwo(&p)
2963
 							service.CreateHisProjectTwo(&p)
2911
 							projectList = append(projectList, p)
2964
 							projectList = append(projectList, p)
2912
 							var randNum int
2965
 							var randNum int
3012
 		//查询今日该患者开的药品处方
3065
 		//查询今日该患者开的药品处方
3013
 		hisdoctorlist, _ := service.GetHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId)
3066
 		hisdoctorlist, _ := service.GetHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId)
3014
 
3067
 
3015
-		fmt.Println("今日出库2333333333333333333333333333333333333333")
3016
 		drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3068
 		drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
3017
 		//药品出库
3069
 		//药品出库
3018
 		if drugOutConfig.IsOpen == 1 {
3070
 		if drugOutConfig.IsOpen == 1 {
3021
 
3073
 
3022
 				// 查询该药品最后一次出库记录
3074
 				// 查询该药品最后一次出库记录
3023
 				druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID)
3075
 				druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID)
3024
-				fmt.Println("今日最后出库2333333333333333333333333333333333333333", druginfo)
3076
+
3025
 				if len(druginfo) > 0 {
3077
 				if len(druginfo) > 0 {
3026
 					//回退库存
3078
 					//回退库存
3027
 					for _, it := range druginfo {
3079
 					for _, it := range druginfo {

+ 4 - 0
controllers/his_project_api_controller.go View File

125
 	specail_project, _ := this.GetInt64("specail_project")
125
 	specail_project, _ := this.GetInt64("specail_project")
126
 	social_security_directory_code := this.GetString("social_security_directory_code")
126
 	social_security_directory_code := this.GetString("social_security_directory_code")
127
 	record_date := this.GetString("record_date")
127
 	record_date := this.GetString("record_date")
128
+	is_print, _ := this.GetInt64("is_print")
128
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
129
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
129
 	adminUserInfo := this.GetAdminUserInfo()
130
 	adminUserInfo := this.GetAdminUserInfo()
130
 	orgId := adminUserInfo.CurrentOrgId
131
 	orgId := adminUserInfo.CurrentOrgId
164
 		SpecailProject:              specail_project,
165
 		SpecailProject:              specail_project,
165
 		SocialSecurityDirectoryCode: social_security_directory_code,
166
 		SocialSecurityDirectoryCode: social_security_directory_code,
166
 		RecordDate:                  theTime.Unix(),
167
 		RecordDate:                  theTime.Unix(),
168
+		IsPrint:                     is_print,
167
 	}
169
 	}
168
 	//查询项目名称是否存在
170
 	//查询项目名称是否存在
169
 	_, errcode := service.GetHisProjectIsExist(project_name, orgId)
171
 	_, errcode := service.GetHisProjectIsExist(project_name, orgId)
258
 	specail_project, _ := this.GetInt64("specail_project")
260
 	specail_project, _ := this.GetInt64("specail_project")
259
 	social_security_directory_code := this.GetString("social_security_directory_code")
261
 	social_security_directory_code := this.GetString("social_security_directory_code")
260
 	record_date := this.GetString("record_date")
262
 	record_date := this.GetString("record_date")
263
+	is_print, _ := this.GetInt64("is_print")
261
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
264
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
262
 	hisProject := models.XtHisProject{
265
 	hisProject := models.XtHisProject{
263
 		ProjectName:                 project_name,
266
 		ProjectName:                 project_name,
293
 		SpecailProject:              specail_project,
296
 		SpecailProject:              specail_project,
294
 		SocialSecurityDirectoryCode: social_security_directory_code,
297
 		SocialSecurityDirectoryCode: social_security_directory_code,
295
 		RecordDate:                  theTime.Unix(),
298
 		RecordDate:                  theTime.Unix(),
299
+		IsPrint:                     is_print,
296
 	}
300
 	}
297
 
301
 
298
 	err := service.UpdatedProject(id, &hisProject)
302
 	err := service.UpdatedProject(id, &hisProject)

+ 285 - 0
controllers/manage_api_controller.go View File

147
 	beego.Router("/api/manage/deleteobjecttabledisinfect", &MachineApiController{}, "Get:DeleteObjectTableDisinfect")
147
 	beego.Router("/api/manage/deleteobjecttabledisinfect", &MachineApiController{}, "Get:DeleteObjectTableDisinfect")
148
 	beego.Router("/api/manage/getairdisinfectionlongtime", &MachineApiController{}, "Get:GetAirDisinfectionLongTime")
148
 	beego.Router("/api/manage/getairdisinfectionlongtime", &MachineApiController{}, "Get:GetAirDisinfectionLongTime")
149
 	beego.Router("/api/manage/getobjcttabledisinfectlongtime", &MachineApiController{}, "Get:GetObjectDisInfectionLongTime")
149
 	beego.Router("/api/manage/getobjcttabledisinfectlongtime", &MachineApiController{}, "Get:GetObjectDisInfectionLongTime")
150
+
151
+	beego.Router("/api/manage/getinformationmanalist", &MachineApiController{}, "Get:GetInformationmanalist")
152
+
153
+	beego.Router("/api/manage/saveobjectregistration", &MachineApiController{}, "Post:SaveObjectRegistration")
154
+	beego.Router("/api/manage/getregistrationdisinfectlist", &MachineApiController{}, "Get:GetRegistrationDisinfectList")
155
+	beego.Router("/api/manage/getobjectregistrationbyidlist", &MachineApiController{}, "Get:GetObjectRegistrationByIdList")
156
+	beego.Router("/api/manage/updateobjectregistration", &MachineApiController{}, "Post:UpdateObjectRegistration")
157
+	beego.Router("/api/manage/deleteobjectregistration", &MachineApiController{}, "Get:DeleteObjectTregistration")
150
 }
158
 }
151
 
159
 
152
 func (this *MachineApiController) SaveManageInfo() {
160
 func (this *MachineApiController) SaveManageInfo() {
4292
 
4300
 
4293
 	appId := this.GetAdminUserInfo().CurrentAppId
4301
 	appId := this.GetAdminUserInfo().CurrentAppId
4294
 	adminRole, err := service.GetAllDoctorTwo(orgId, appId)
4302
 	adminRole, err := service.GetAllDoctorTwo(orgId, appId)
4303
+	operators, err := service.GetAdminUserEsOne(orgId)
4295
 	if err != nil {
4304
 	if err != nil {
4296
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
4305
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
4297
 		return
4306
 		return
4300
 		"list":      list,
4309
 		"list":      list,
4301
 		"total":     total,
4310
 		"total":     total,
4302
 		"adminRole": adminRole,
4311
 		"adminRole": adminRole,
4312
+		"operators": operators,
4303
 	})
4313
 	})
4304
 }
4314
 }
4305
 
4315
 
5407
 		"list": list,
5417
 		"list": list,
5408
 	})
5418
 	})
5409
 }
5419
 }
5420
+
5421
+func (this *MachineApiController) GetInformationmanalist() {
5422
+
5423
+	//获取5月1日到5月27日的上机患者
5424
+
5425
+	list, _ := service.GetDialysisOrderPatient(9538)
5426
+
5427
+	for _, dialysisOrder := range list {
5428
+
5429
+		//根据床位号获取设备型号
5430
+		unitType, _ := service.GetUnitType(dialysisOrder.BedId, dialysisOrder.UserOrgId)
5431
+		//查询使用消毒最后一条消毒记录
5432
+		_, err := service.GetLaseDeviceInfomation(dialysisOrder.UserOrgId, dialysisOrder.BedId, dialysisOrder.DialysisDate, dialysisOrder.SchedualType)
5433
+		fmt.Println("err", err)
5434
+		if err == gorm.ErrRecordNotFound {
5435
+			//查找排班
5436
+			scheduleByPatient, _ := service.GetScheduleByPatient(dialysisOrder.PatientId, dialysisOrder.DialysisDate, dialysisOrder.UserOrgId)
5437
+			//查询改设备是否有消毒计划
5438
+			plan, errcode := service.GetDisInfectionTime(dialysisOrder.UserOrgId, unitType.UnitType, dialysisOrder.SchedualType, scheduleByPatient.ScheduleWeek)
5439
+
5440
+			//根据床位号获取设备id
5441
+			addmacher, _ := service.GetEquimentIDTwo(dialysisOrder.BedId, dialysisOrder.UserOrgId)
5442
+
5443
+			//查询病人信息
5444
+			patients, _ := service.GetPatientInfoMation(dialysisOrder.PatientId)
5445
+			var con = ""
5446
+			if patients.IsInfectious == 0 {
5447
+				con = ""
5448
+			}
5449
+			if patients.IsInfectious == 1 {
5450
+				con = "无"
5451
+			}
5452
+			if patients.IsInfectious == 2 {
5453
+				con = "有"
5454
+			}
5455
+
5456
+			if errcode == nil {
5457
+				var end_time int64
5458
+				end_time = dialysisOrder.EndTime + plan.DisinfecTime*60
5459
+				//新增消毒
5460
+				information := models.DeviceInformation{
5461
+					Date:                  dialysisOrder.DialysisDate,
5462
+					Zone:                  dialysisOrder.ZoneId,
5463
+					Class:                 dialysisOrder.SchedualType,
5464
+					BedNumber:             dialysisOrder.BedId,
5465
+					PatientId:             dialysisOrder.PatientId,
5466
+					DialysisMode:          scheduleByPatient.ModeId,
5467
+					LongTime:              strconv.FormatInt(plan.DisinfecTime, 10),
5468
+					Disinfection:          1,
5469
+					DialysisConcentration: 1,
5470
+					DisinfectionStatus:    1,
5471
+					Move:                  1,
5472
+					UserOrgId:             dialysisOrder.UserOrgId,
5473
+					DisinfectType:         plan.Way,
5474
+					DisinfectantType:      plan.MachineDisinfectant,
5475
+					FluidPath:             plan.DisinfectanWay, //液路消毒方式
5476
+					Disinfectant:          plan.Disinfectant,
5477
+					Ctime:                 time.Now().Unix(),
5478
+					Status:                1,
5479
+					SignName:              dialysisOrder.FinishNurse,
5480
+					EquimentId:            addmacher.ID,
5481
+					DisinfectionResidue:   2,
5482
+					Bed:                   addmacher.BedNumber,
5483
+					StartTime:             dialysisOrder.StartTime,
5484
+					EndTime:               dialysisOrder.EndTime,
5485
+					Contagion:             con,
5486
+					WeightLoss:            0,
5487
+					Hyperfiltratio:        0,
5488
+					DialysisHour:          "",
5489
+					MachineRun:            1,
5490
+					DisinfecStartime:      dialysisOrder.EndTime,
5491
+					DisinfecEndtime:       end_time,
5492
+				}
5493
+				err := service.CreateInformationTwo(&information)
5494
+				fmt.Println("报错", err)
5495
+			}
5496
+		}
5497
+	}
5498
+
5499
+	this.ServeSuccessJSON(map[string]interface{}{
5500
+		"list": list,
5501
+	})
5502
+}
5503
+
5504
+func (this *MachineApiController) SaveObjectRegistration() {
5505
+
5506
+	timeLayout := "2006-01-02"
5507
+	loc, _ := time.LoadLocation("Local")
5508
+	dataBody := make(map[string]interface{}, 0)
5509
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
5510
+	fmt.Println(err)
5511
+	record_date := dataBody["record_date"].(string)
5512
+
5513
+	recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
5514
+	recorddateunix := recorddate.Unix()
5515
+
5516
+	model_number := dataBody["model_number"].(string)
5517
+	user_count := dataBody["user_count"].(string)
5518
+
5519
+	product_date := dataBody["product_date"].(string)
5520
+
5521
+	productdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
5522
+	productdateunix := productdate.Unix()
5523
+
5524
+	expiry_date := dataBody["expiry_date"].(string)
5525
+
5526
+	expirydate, _ := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
5527
+	expirydateunix := expirydate.Unix()
5528
+
5529
+	packaging_identification := int64(dataBody["packaging_identification"].(float64))
5530
+
5531
+	destroy_people := int64(dataBody["destroy_people"].(float64))
5532
+
5533
+	destroy_nubmer := dataBody["destroy_nubmer"].(string)
5534
+
5535
+	destroy_way := int64(dataBody["destroy_way"].(float64))
5536
+
5537
+	leader := int64(dataBody["leader"].(float64))
5538
+
5539
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5540
+	registration := models.XtDialysisRegistration{
5541
+		RecordDate:              recorddateunix,
5542
+		ModelNumber:             model_number,
5543
+		UserCount:               user_count,
5544
+		ProductDate:             productdateunix,
5545
+		ExpiryDate:              expirydateunix,
5546
+		PackagingIdentification: packaging_identification,
5547
+		DestroyPeople:           destroy_people,
5548
+		DestroyNubmer:           destroy_nubmer,
5549
+		DestroyWay:              destroy_way,
5550
+		Leader:                  leader,
5551
+		UserOrgId:               orgId,
5552
+		Status:                  1,
5553
+		Ctime:                   time.Now().Unix(),
5554
+		Mtime:                   0,
5555
+	}
5556
+
5557
+	err = service.CreateObjectRegistration(registration)
5558
+
5559
+	this.ServeSuccessJSON(map[string]interface{}{
5560
+		"registration": registration,
5561
+	})
5562
+
5563
+}
5564
+
5565
+func (this *MachineApiController) GetRegistrationDisinfectList() {
5566
+
5567
+	timeLayout := "2006-01-02"
5568
+	loc, _ := time.LoadLocation("Local")
5569
+	start_time := this.GetString("start_time")
5570
+	end_time := this.GetString("end_time")
5571
+	limit, _ := this.GetInt64("limit")
5572
+	page, _ := this.GetInt64("page")
5573
+	var startTime int64
5574
+	if len(start_time) > 0 {
5575
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
5576
+		if err != nil {
5577
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5578
+			return
5579
+		}
5580
+		startTime = theTime.Unix()
5581
+	}
5582
+	var endTime int64
5583
+	if len(end_time) > 0 {
5584
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
5585
+		if err != nil {
5586
+			utils.ErrorLog(err.Error())
5587
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
5588
+			return
5589
+		}
5590
+		endTime = theTime.Unix()
5591
+	}
5592
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5593
+	list, total, err := service.GetRegistrationDisinfectList(limit, page, startTime, endTime, orgId)
5594
+
5595
+	if err != nil {
5596
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
5597
+		return
5598
+	}
5599
+	this.ServeSuccessJSON(map[string]interface{}{
5600
+		"list":  list,
5601
+		"total": total,
5602
+	})
5603
+}
5604
+
5605
+func (this *MachineApiController) GetObjectRegistrationByIdList() {
5606
+
5607
+	id, _ := this.GetInt64("id")
5608
+
5609
+	list, err := service.GetObjectRegistrationByIdList(id)
5610
+
5611
+	if err != nil {
5612
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
5613
+		return
5614
+	}
5615
+	this.ServeSuccessJSON(map[string]interface{}{
5616
+		"list": list,
5617
+	})
5618
+}
5619
+
5620
+func (this *MachineApiController) UpdateObjectRegistration() {
5621
+
5622
+	timeLayout := "2006-01-02"
5623
+	loc, _ := time.LoadLocation("Local")
5624
+	dataBody := make(map[string]interface{}, 0)
5625
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
5626
+	fmt.Println(err)
5627
+	record_date := dataBody["record_date"].(string)
5628
+
5629
+	recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
5630
+	recorddateunix := recorddate.Unix()
5631
+
5632
+	model_number := dataBody["model_number"].(string)
5633
+	user_count := dataBody["user_count"].(string)
5634
+
5635
+	product_date := dataBody["product_date"].(string)
5636
+
5637
+	productdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
5638
+	productdateunix := productdate.Unix()
5639
+
5640
+	expiry_date := dataBody["expiry_date"].(string)
5641
+
5642
+	expirydate, _ := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
5643
+	expirydateunix := expirydate.Unix()
5644
+
5645
+	packaging_identification := int64(dataBody["packaging_identification"].(float64))
5646
+
5647
+	destroy_people := int64(dataBody["destroy_people"].(float64))
5648
+
5649
+	destroy_nubmer := dataBody["destroy_nubmer"].(string)
5650
+
5651
+	destroy_way := int64(dataBody["destroy_way"].(float64))
5652
+
5653
+	leader := int64(dataBody["leader"].(float64))
5654
+
5655
+	id := int64(dataBody["id"].(float64))
5656
+	orgId := this.GetAdminUserInfo().CurrentOrgId
5657
+	registration := models.XtDialysisRegistration{
5658
+		ID:                      id,
5659
+		RecordDate:              recorddateunix,
5660
+		ModelNumber:             model_number,
5661
+		UserCount:               user_count,
5662
+		ProductDate:             productdateunix,
5663
+		ExpiryDate:              expirydateunix,
5664
+		PackagingIdentification: packaging_identification,
5665
+		DestroyPeople:           destroy_people,
5666
+		DestroyNubmer:           destroy_nubmer,
5667
+		DestroyWay:              destroy_way,
5668
+		Leader:                  leader,
5669
+		UserOrgId:               orgId,
5670
+		Status:                  1,
5671
+		Ctime:                   time.Now().Unix(),
5672
+		Mtime:                   0,
5673
+	}
5674
+
5675
+	service.UpdateObjectRegistration(registration)
5676
+
5677
+	this.ServeSuccessJSON(map[string]interface{}{
5678
+		"registration": registration,
5679
+	})
5680
+}
5681
+
5682
+func (this *MachineApiController) DeleteObjectTregistration() {
5683
+
5684
+	id, _ := this.GetInt64("id")
5685
+	err := service.DeleteObjectTregistration(id)
5686
+	if err != nil {
5687
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
5688
+		return
5689
+	}
5690
+	this.ServeSuccessJSON(map[string]interface{}{
5691
+		"msg": "ok",
5692
+	})
5693
+	return
5694
+}

+ 3 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go View File

379
 			newprescribe.DewaterAmount = dewater_amount
379
 			newprescribe.DewaterAmount = dewater_amount
380
 			newprescribe.TargetUltrafiltration = dewater_amount
380
 			newprescribe.TargetUltrafiltration = dewater_amount
381
 			newprescribe.PrescriptionWater = dewater_amount
381
 			newprescribe.PrescriptionWater = dewater_amount
382
+			newprescribe.Chaptalization = dialysisSolution.Chaptalization
382
 			newprescribe.Status = 1
383
 			newprescribe.Status = 1
383
 			if adminUserInfo.Org.Id != 10013 && adminUserInfo.Org.Id != 10014 {
384
 			if adminUserInfo.Org.Id != 10013 && adminUserInfo.Org.Id != 10014 {
384
 				newprescribe.Remark = dialysisSolution.Remark
385
 				newprescribe.Remark = dialysisSolution.Remark
465
 				newprescribe.PrescriptionWater = dewater_amount
466
 				newprescribe.PrescriptionWater = dewater_amount
466
 				newprescribe.Status = 1
467
 				newprescribe.Status = 1
467
 				newprescribe.Remark = lastDialysisPrescribe.Remark
468
 				newprescribe.Remark = lastDialysisPrescribe.Remark
469
+				newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
468
 				if adminUserInfo.Org.Id == 10340 {
470
 				if adminUserInfo.Org.Id == 10340 {
469
 					newprescribe.TargetUltrafiltration = 0
471
 					newprescribe.TargetUltrafiltration = 0
470
 				}
472
 				}
530
 				newprescribe.RecordDate = theAssessmentDateTime
532
 				newprescribe.RecordDate = theAssessmentDateTime
531
 				newprescribe.DewaterAmount = dewater_amount
533
 				newprescribe.DewaterAmount = dewater_amount
532
 				newprescribe.TargetUltrafiltration = dewater_amount
534
 				newprescribe.TargetUltrafiltration = dewater_amount
535
+				newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
533
 				newprescribe.Status = 1
536
 				newprescribe.Status = 1
534
 
537
 
535
 				if adminUserInfo.Org.Id == 10340 {
538
 				if adminUserInfo.Org.Id == 10340 {

+ 92 - 15
controllers/mobile_api_controllers/dialysis_api_controller.go View File

86
 	defer redis.Close()
86
 	defer redis.Close()
87
 
87
 
88
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
88
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
89
-	redis.Set(key, "", time.Second)
89
+
90
 	scheduals_json_str, _ := redis.Get(key).Result()
90
 	scheduals_json_str, _ := redis.Get(key).Result()
91
 
91
 
92
 	patients, _ := service.GetAllPatientListSix(orgID)
92
 	patients, _ := service.GetAllPatientListSix(orgID)
697
 	// 查询信息规挡的设置天数
697
 	// 查询信息规挡的设置天数
698
 
698
 
699
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
699
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
700
-	if infor.ID > 0 {
700
+	if infor.ID > 0 && infor.WeekDay > 0 {
701
 
701
 
702
 		var cha_time int64
702
 		var cha_time int64
703
 
703
 
908
 		// 查询信息规挡的设置天数
908
 		// 查询信息规挡的设置天数
909
 
909
 
910
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
910
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
911
-		if infor.ID > 0 {
911
+		if infor.ID > 0 && infor.WeekDay > 0 {
912
 
912
 
913
 			var cha_time int64
913
 			var cha_time int64
914
 
914
 
1124
 	// 查询信息规挡的设置天数
1124
 	// 查询信息规挡的设置天数
1125
 
1125
 
1126
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1126
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1127
-	if infor.ID > 0 {
1127
+	if infor.ID > 0 && infor.WeekDay > 0 {
1128
 
1128
 
1129
 		var cha_time int64
1129
 		var cha_time int64
1130
 
1130
 
1223
 		//		return
1223
 		//		return
1224
 		//	}
1224
 		//	}
1225
 		//}
1225
 		//}
1226
+		// 查询信息规挡的设置天数
1227
+
1228
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1229
+		if infor.ID > 0 && infor.WeekDay > 0 {
1230
+
1231
+			var cha_time int64
1232
+
1233
+			timeNowStr := time.Now().Format("2006-01-02")
1234
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1235
+
1236
+			//今日的日期减去设置的日期
1237
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1238
+
1239
+			if cha_time >= recordDate.Unix() {
1240
+				//查询审核是否允许
1241
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1242
+				//申请状态不允许的情况 拒绝修改
1243
+				if infor.ApplicationStatus != 1 {
1244
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1245
+					return
1246
+				}
1247
+
1248
+			}
1249
+		}
1226
 
1250
 
1227
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
1251
 		receiveTreatmentAsses.Creater = receiveTreatment.Creater
1228
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
1252
 		receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
1253
 	weightAfter, _ := c.GetFloat("weight_after", 0)
1277
 	weightAfter, _ := c.GetFloat("weight_after", 0)
1254
 	additionalWeight, _ := c.GetFloat("additional_weight", 0)
1278
 	additionalWeight, _ := c.GetFloat("additional_weight", 0)
1255
 	weightReduce, _ := c.GetFloat("weight_loss", 0)
1279
 	weightReduce, _ := c.GetFloat("weight_loss", 0)
1280
+	fmt.Println("weight_loss", weightReduce)
1256
 	temperature, _ := c.GetFloat("temperature", 0)
1281
 	temperature, _ := c.GetFloat("temperature", 0)
1257
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
1282
 	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
1258
 	breathing_rate := c.GetString("breathing_rate")
1283
 	breathing_rate := c.GetString("breathing_rate")
1260
 
1285
 
1261
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
1286
 	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
1262
 	actual_ultrafiltration, _ := c.GetFloat("actual_ultrafiltration", 0)
1287
 	actual_ultrafiltration, _ := c.GetFloat("actual_ultrafiltration", 0)
1288
+
1289
+	fmt.Println("actual_ultrafiltration233232322323", actual_ultrafiltration)
1263
 	actual_displacement, _ := c.GetFloat("actual_displacement", 0)
1290
 	actual_displacement, _ := c.GetFloat("actual_displacement", 0)
1291
+
1264
 	actualtreatHour, _ := c.GetInt64("actual_treatment_hour", 0)
1292
 	actualtreatHour, _ := c.GetInt64("actual_treatment_hour", 0)
1265
 	actualtreatmin, _ := c.GetInt64("actual_treatment_minute", 0)
1293
 	actualtreatmin, _ := c.GetInt64("actual_treatment_minute", 0)
1266
 	cruor := c.GetString("cruor")
1294
 	cruor := c.GetString("cruor")
1330
 	after_urea := c.GetString("after_urea")
1358
 	after_urea := c.GetString("after_urea")
1331
 	pip_coagulation := c.GetString("pip_coagulation")
1359
 	pip_coagulation := c.GetString("pip_coagulation")
1332
 	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1360
 	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1361
+	fmt.Println("accumulated_blood_volume", accumulated_blood_volume)
1333
 	if id <= 0 {
1362
 	if id <= 0 {
1334
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1363
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1335
 		return
1364
 		return
1337
 
1366
 
1338
 	adminUserInfo := c.GetMobileAdminUserInfo()
1367
 	adminUserInfo := c.GetMobileAdminUserInfo()
1339
 	patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
1368
 	patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
1369
+
1340
 	if patient.ID == 0 {
1370
 	if patient.ID == 0 {
1341
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1371
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
1342
 		return
1372
 		return
1346
 		recordDateStr = time.Now().Format("2006-01-02")
1376
 		recordDateStr = time.Now().Format("2006-01-02")
1347
 	}
1377
 	}
1348
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1378
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
1379
+	fmt.Println("parseDateErr", parseDateErr)
1349
 	if parseDateErr != nil {
1380
 	if parseDateErr != nil {
1350
 		c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
1381
 		c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
1351
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1382
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1442
 	// 查询信息规挡的设置天数
1473
 	// 查询信息规挡的设置天数
1443
 
1474
 
1444
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1475
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1445
-	if infor.ID > 0 {
1476
+	if infor.ID > 0 && infor.WeekDay > 0 {
1446
 
1477
 
1447
 		var cha_time int64
1478
 		var cha_time int64
1448
 
1479
 
1507
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1538
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1508
 			})
1539
 			})
1509
 		}
1540
 		}
1541
+		return
1510
 	} else { //修改
1542
 	} else { //修改
1511
 
1543
 
1544
+		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1545
+		if infor.ID > 0 && infor.WeekDay > 0 {
1546
+
1547
+			var cha_time int64
1548
+
1549
+			timeNowStr := time.Now().Format("2006-01-02")
1550
+			timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
1551
+
1552
+			//今日的日期减去设置的日期
1553
+			cha_time = timeNewDate.Unix() - infor.WeekDay*86400
1554
+			if cha_time >= recordDate.Unix() {
1555
+				//查询审核是否允许
1556
+				infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1557
+				//申请状态不允许的情况 拒绝修改
1558
+				if infor.ApplicationStatus != 1 {
1559
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1560
+					return
1561
+				}
1562
+
1563
+			}
1564
+		}
1512
 		if appRole.UserType == 2 || appRole.UserType == 1 {
1565
 		if appRole.UserType == 2 || appRole.UserType == 1 {
1513
 			assessmentAfterDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
1566
 			assessmentAfterDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
1514
 			assessmentAfterDislysis.AssessmentTime = time.Now().Unix()
1567
 			assessmentAfterDislysis.AssessmentTime = time.Now().Unix()
1523
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1576
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1524
 
1577
 
1525
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1578
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1579
+		fmt.Println("werwewweoweoweoweoewoewoew", err)
1526
 		redis := service.RedisClient()
1580
 		redis := service.RedisClient()
1527
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1581
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1528
 
1582
 
1534
 
1588
 
1535
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1589
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1536
 		redis.Set(keyOne, "", time.Second)
1590
 		redis.Set(keyOne, "", time.Second)
1537
-
1538
 		if err == nil {
1591
 		if err == nil {
1539
 			c.ServeSuccessJSON(map[string]interface{}{
1592
 			c.ServeSuccessJSON(map[string]interface{}{
1540
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1593
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1541
 			})
1594
 			})
1595
+			return
1542
 		}
1596
 		}
1597
+
1543
 	}
1598
 	}
1599
+
1600
+	return
1544
 }
1601
 }
1545
 
1602
 
1546
 func (c *DialysisAPIController) PostDialysisPrescription() {
1603
 func (c *DialysisAPIController) PostDialysisPrescription() {
1711
 	// 查询信息规挡的设置天数
1768
 	// 查询信息规挡的设置天数
1712
 
1769
 
1713
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1770
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1714
-	if infor.ID > 0 {
1771
+	if infor.ID > 0 && infor.WeekDay > 0 {
1715
 
1772
 
1716
 		var cha_time int64
1773
 		var cha_time int64
1717
 
1774
 
2294
 	// 查询信息规挡的设置天数
2351
 	// 查询信息规挡的设置天数
2295
 
2352
 
2296
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
2353
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
2297
-	if infor.ID > 0 {
2354
+	if infor.ID > 0 && infor.WeekDay > 0 {
2298
 
2355
 
2299
 		var cha_time int64
2356
 		var cha_time int64
2300
 
2357
 
3008
 	// 查询信息规挡的设置天数
3065
 	// 查询信息规挡的设置天数
3009
 
3066
 
3010
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
3067
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
3011
-	if infor.ID > 0 {
3068
+	if infor.ID > 0 && infor.WeekDay > 0 {
3012
 
3069
 
3013
 		var cha_time int64
3070
 		var cha_time int64
3014
 
3071
 
3203
 	}
3260
 	}
3204
 
3261
 
3205
 	//只针对广慈医院
3262
 	//只针对广慈医院
3206
-	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 || adminUserInfo.Org.Id == 9918 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 {
3263
+	if template.TemplateId == 26 || template.TemplateId == 25 || template.TemplateId == 28 || adminUserInfo.Org.Id == 9987 || adminUserInfo.Org.Id == 9526 || template.TemplateId == 32 || adminUserInfo.Org.Id == 9918 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10517 {
3207
 		// 查询病人是否有透前评估数据
3264
 		// 查询病人是否有透前评估数据
3208
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
3265
 		befor, errcode := service.GetAssessmentBefor(adminUserInfo.Org.Id, patientID, recordDate.Unix())
3209
 
3266
 
3480
 	// 查询信息规挡的设置天数
3537
 	// 查询信息规挡的设置天数
3481
 
3538
 
3482
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
3539
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
3483
-	if infor.ID > 0 {
3540
+	if infor.ID > 0 && infor.WeekDay > 0 {
3484
 
3541
 
3485
 		var cha_time int64
3542
 		var cha_time int64
3486
 
3543
 
3611
 
3668
 
3612
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
3669
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
3613
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
3670
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
3671
+	fmt.Println("appRole0000000000000", appRole.UserType)
3614
 	//
3672
 	//
3615
 	if appRole.UserType == 2 || appRole.UserType == 1 {
3673
 	if appRole.UserType == 2 || appRole.UserType == 1 {
3616
 		prescription_doctor = adminUserInfo.AdminUser.Id
3674
 		prescription_doctor = adminUserInfo.AdminUser.Id
4199
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
4257
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
4200
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
4258
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
4201
 	quality_nurse_id, _ := this.GetInt64("quality_nurse_id")
4259
 	quality_nurse_id, _ := this.GetInt64("quality_nurse_id")
4260
+	fmt.Println("quality_nurse_id", quality_nurse_id)
4202
 	patient_id, _ := this.GetInt64("patient_id")
4261
 	patient_id, _ := this.GetInt64("patient_id")
4203
 	record_date, _ := this.GetInt64("record_date")
4262
 	record_date, _ := this.GetInt64("record_date")
4204
 	puncture_needle := this.GetString("puncture_needle")
4263
 	puncture_needle := this.GetString("puncture_needle")
4398
 	// 查询信息规挡的设置天数
4457
 	// 查询信息规挡的设置天数
4399
 
4458
 
4400
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4459
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4401
-	if infor.ID > 0 {
4460
+	if infor.ID > 0 && infor.WeekDay > 0 {
4402
 
4461
 
4403
 		var cha_time int64
4462
 		var cha_time int64
4404
 
4463
 
5778
 	// 查询信息规挡的设置天数
5837
 	// 查询信息规挡的设置天数
5779
 
5838
 
5780
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
5839
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
5781
-	if infor.ID > 0 {
5840
+	if infor.ID > 0 && infor.WeekDay > 0 {
5782
 
5841
 
5783
 		var cha_time int64
5842
 		var cha_time int64
5784
 
5843
 
5799
 
5858
 
5800
 		}
5859
 		}
5801
 	}
5860
 	}
5861
+
5862
+	//创建步骤表
5863
+	finish := models.XtDialysisFinish{
5864
+		IsFinish:   1,
5865
+		UserOrgId:  adminInfo.Org.Id,
5866
+		Status:     1,
5867
+		Ctime:      time.Now().Unix(),
5868
+		Mtime:      0,
5869
+		Module:     11,
5870
+		RecordDate: record_time,
5871
+		Sourse:     1,
5872
+		PatientId:  patient_id,
5873
+	}
5874
+
5875
+	dialysisFinish, _ := service.GetDialysisFinish(adminInfo.Org.Id, record_time, 11, patient_id)
5876
+	if dialysisFinish.ID == 0 {
5877
+		service.CreateDialysisFinish(finish)
5878
+	}
5802
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
5879
 	consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
5803
 
5880
 
5804
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
5881
 	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
6221
 	// 查询信息规挡的设置天数
6298
 	// 查询信息规挡的设置天数
6222
 
6299
 
6223
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
6300
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
6224
-	if infor.ID > 0 {
6301
+	if infor.ID > 0 && infor.WeekDay > 0 {
6225
 
6302
 
6226
 		var cha_time int64
6303
 		var cha_time int64
6227
 
6304
 
7100
 	// 查询信息规挡的设置天数
7177
 	// 查询信息规挡的设置天数
7101
 
7178
 
7102
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
7179
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
7103
-	if infor.ID > 0 {
7180
+	if infor.ID > 0 && infor.WeekDay > 0 {
7104
 
7181
 
7105
 		var cha_time int64
7182
 		var cha_time int64
7106
 
7183
 

+ 3 - 3
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

122
 	// 查询信息规挡的设置天数
122
 	// 查询信息规挡的设置天数
123
 
123
 
124
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
124
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
125
-	if infor.ID > 0 {
125
+	if infor.ID > 0 && infor.WeekDay > 0 {
126
 
126
 
127
 		var cha_time int64
127
 		var cha_time int64
128
 
128
 
395
 	// 查询信息规挡的设置天数
395
 	// 查询信息规挡的设置天数
396
 
396
 
397
 	infor, _ := service.GetDialysisInformationSetting(monitor.MonitoringDate)
397
 	infor, _ := service.GetDialysisInformationSetting(monitor.MonitoringDate)
398
-	if infor.ID > 0 {
398
+	if infor.ID > 0 && infor.WeekDay > 0 {
399
 
399
 
400
 		var cha_time int64
400
 		var cha_time int64
401
 
401
 
468
 	// 查询信息规挡的设置天数
468
 	// 查询信息规挡的设置天数
469
 
469
 
470
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
470
 	infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
471
-	if infor.ID > 0 {
471
+	if infor.ID > 0 && infor.WeekDay > 0 {
472
 
472
 
473
 		var cha_time int64
473
 		var cha_time int64
474
 
474
 

+ 0 - 2
controllers/mobile_api_controllers/mobile_api_base_controller.go View File

7
 	"XT_New/service"
7
 	"XT_New/service"
8
 	"bytes"
8
 	"bytes"
9
 	"encoding/json"
9
 	"encoding/json"
10
-	"fmt"
11
 	"log"
10
 	"log"
12
 	"os"
11
 	"os"
13
 	"path"
12
 	"path"
143
 
142
 
144
 			//redis key值
143
 			//redis key值
145
 			key := "purviews_" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + strconv.FormatInt(adminUserInfo.AdminUser.Id, 10)
144
 			key := "purviews_" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + strconv.FormatInt(adminUserInfo.AdminUser.Id, 10)
146
-			fmt.Println("ket--------------------", key)
147
 
145
 
148
 			redis.Set(key, "", time.Second)
146
 			redis.Set(key, "", time.Second)
149
 			purviews_json_str, _ := redis.Get(key).Result()
147
 			purviews_json_str, _ := redis.Get(key).Result()

+ 12 - 9
controllers/mobile_api_controllers/patient_api_controller.go View File

314
 			// 查询信息规挡的设置天数
314
 			// 查询信息规挡的设置天数
315
 
315
 
316
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
316
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
317
-			if infor.ID > 0 {
317
+			if infor.ID > 0 && infor.WeekDay > 0 {
318
 
318
 
319
 				var cha_time int64
319
 				var cha_time int64
320
 
320
 
696
 			// 查询信息规挡的设置天数
696
 			// 查询信息规挡的设置天数
697
 
697
 
698
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
698
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
699
-			if infor.ID > 0 {
699
+			if infor.ID > 0 && infor.WeekDay > 0 {
700
 
700
 
701
 				var cha_time int64
701
 				var cha_time int64
702
 
702
 
705
 
705
 
706
 				//今日的日期减去设置的日期
706
 				//今日的日期减去设置的日期
707
 				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
707
 				cha_time = timeNewDate.Unix() - infor.WeekDay*86400
708
-				fmt.Println("cha_time----------------", cha_time)
709
-				fmt.Println("advices.232323232222", record_date)
708
+
710
 				if cha_time >= record_date {
709
 				if cha_time >= record_date {
711
 					//查询审核是否允许
710
 					//查询审核是否允许
712
 					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
711
 					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id)
1904
 			// 查询信息规挡的设置天数
1903
 			// 查询信息规挡的设置天数
1905
 
1904
 
1906
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1905
 			infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
1907
-			if infor.ID > 0 {
1906
+			if infor.ID > 0 && infor.WeekDay > 0 {
1908
 
1907
 
1909
 				var cha_time int64
1908
 				var cha_time int64
1910
 
1909
 
2173
 	// 计算透析处方的相关超滤量
2172
 	// 计算透析处方的相关超滤量
2174
 	schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.Org.Id, patient.ID, theAssessmentDateTime)
2173
 	schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.Org.Id, patient.ID, theAssessmentDateTime)
2175
 	lastDialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient.ID, adminUserInfo.Org.Id)
2174
 	lastDialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient.ID, adminUserInfo.Org.Id)
2175
+
2176
 	var lastDialysisPrescribe *models.DialysisPrescription
2176
 	var lastDialysisPrescribe *models.DialysisPrescription
2177
 	var dialysisSolution *models.DialysisSolution
2177
 	var dialysisSolution *models.DialysisSolution
2178
 	var dialysisPrescribe *models.DialysisPrescription
2178
 	var dialysisPrescribe *models.DialysisPrescription
2254
 		newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
2254
 		newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
2255
 		newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
2255
 		newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
2256
 		newprescribe.Remark = lastDialysisPrescription.Remark
2256
 		newprescribe.Remark = lastDialysisPrescription.Remark
2257
+		newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2257
 		_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2258
 		_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2258
 		newprescribe.ID = dialysisPrescription.ID
2259
 		newprescribe.ID = dialysisPrescription.ID
2259
 
2260
 
2374
 			newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
2375
 			newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
2375
 			newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
2376
 			newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
2376
 			newprescribe.Remark = lastDialysisPrescription.Remark
2377
 			newprescribe.Remark = lastDialysisPrescription.Remark
2378
+			newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2377
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2379
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2378
 			newprescribe.ID = dialysisPrescription.ID
2380
 			newprescribe.ID = dialysisPrescription.ID
2379
 			if dialysisPrescription.ID == 0 {
2381
 			if dialysisPrescription.ID == 0 {
2487
 			newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
2489
 			newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
2488
 			newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
2490
 			newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
2489
 			newprescribe.Remark = lastDialysisPrescription.Remark
2491
 			newprescribe.Remark = lastDialysisPrescription.Remark
2492
+			newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
2490
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2493
 			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
2491
 			newprescribe.ID = dialysisPrescription.ID
2494
 			newprescribe.ID = dialysisPrescription.ID
2492
 			if dialysisPrescription.ID == 0 {
2495
 			if dialysisPrescription.ID == 0 {
2653
 	// 查询信息规挡的设置天数
2656
 	// 查询信息规挡的设置天数
2654
 
2657
 
2655
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
2658
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
2656
-	if infor.ID > 0 {
2659
+	if infor.ID > 0 && infor.WeekDay > 0 {
2657
 
2660
 
2658
 		var cha_time int64
2661
 		var cha_time int64
2659
 
2662
 
3208
 
3211
 
3209
 	if dataBody["is_infect"] != nil && reflect.TypeOf(dataBody["is_infect"]).String() == "string" {
3212
 	if dataBody["is_infect"] != nil && reflect.TypeOf(dataBody["is_infect"]).String() == "string" {
3210
 		is_infect, _ := dataBody["is_infect"].(string)
3213
 		is_infect, _ := dataBody["is_infect"].(string)
3214
+		fmt.Println("is_infect================", is_infect)
3211
 		infect, _ := strconv.ParseInt(is_infect, 10, 64)
3215
 		infect, _ := strconv.ParseInt(is_infect, 10, 64)
3212
 		evaluation.IsInfect = infect
3216
 		evaluation.IsInfect = infect
3213
 	}
3217
 	}
3418
 		befor_symptoms := dataBody["befor_symptoms"].(string)
3422
 		befor_symptoms := dataBody["befor_symptoms"].(string)
3419
 		evaluation.BeforSymptoms = befor_symptoms
3423
 		evaluation.BeforSymptoms = befor_symptoms
3420
 
3424
 
3421
-		fmt.Println("befor_symptomsss23333333333333333333333333", befor_symptoms)
3422
 	}
3425
 	}
3423
 	return
3426
 	return
3424
 }
3427
 }
4358
 		// 查询信息规挡的设置天数
4361
 		// 查询信息规挡的设置天数
4359
 
4362
 
4360
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4363
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4361
-		if infor.ID > 0 {
4364
+		if infor.ID > 0 && infor.WeekDay > 0 {
4362
 
4365
 
4363
 			var cha_time int64
4366
 			var cha_time int64
4364
 
4367
 
4647
 		// 查询信息规挡的设置天数
4650
 		// 查询信息规挡的设置天数
4648
 
4651
 
4649
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4652
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
4650
-		if infor.ID > 0 {
4653
+		if infor.ID > 0 && infor.WeekDay > 0 {
4651
 
4654
 
4652
 			var cha_time int64
4655
 			var cha_time int64
4653
 
4656
 

+ 12 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

400
 		}
400
 		}
401
 	}
401
 	}
402
 
402
 
403
+	//针对百霖和贝尔
404
+	if orgid == 10138 || orgid == 10278 || orgid == 3877 {
405
+		//获取今日的排班数据
406
+		list, _ := service.GetMobileScheduleListByScheduleDate(orgid, startTime)
407
+		for _, item := range list {
408
+			solution, _ := service.GetLongSolutionByModeId(item.PatientId, item.ModeId, item.UserOrgId)
409
+			var str = solution.DialysisDialyszers + "/" + solution.DialysisIrrigation
410
+			service.UpdateScheduleByDialysis(item.PatientId, item.ModeId, item.ScheduleDate, item.UserOrgId, str, item.ScheduleType)
411
+		}
412
+	}
413
+
403
 	// stockType, _ := service.GetStockType(orgid)
414
 	// stockType, _ := service.GetStockType(orgid)
404
 	//zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
415
 	//zonelist, _ := service.GetPatientScheduleListByZone(startTime, classtype, orgid)
405
 	// if err != nil {
416
 	// if err != nil {
890
 	loc, _ := time.LoadLocation("Local")
901
 	loc, _ := time.LoadLocation("Local")
891
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
902
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
892
 	schedule, _ := service.GetSolutionScheduleBySchedule(orgId, zoneid, classtype, theTime.Unix())
903
 	schedule, _ := service.GetSolutionScheduleBySchedule(orgId, zoneid, classtype, theTime.Unix())
904
+
893
 	c.ServeSuccessJSON(map[string]interface{}{
905
 	c.ServeSuccessJSON(map[string]interface{}{
894
 		"schedule": schedule,
906
 		"schedule": schedule,
895
 	})
907
 	})

+ 31 - 10
controllers/patient_api_controller.go View File

108
 	reimbursement_way, _ := c.GetInt64("reimbursement_way", 0)
108
 	reimbursement_way, _ := c.GetInt64("reimbursement_way", 0)
109
 	isscheduling, _ := c.GetInt64("isscheduling", 0)
109
 	isscheduling, _ := c.GetInt64("isscheduling", 0)
110
 	isprescription, _ := c.GetInt64("isprescription", 0)
110
 	isprescription, _ := c.GetInt64("isprescription", 0)
111
-
111
+	patientSoureType, _ := c.GetInt64("patientSoureType")
112
 	if page <= 0 {
112
 	if page <= 0 {
113
 		page = 1
113
 		page = 1
114
 	}
114
 	}
147
 
147
 
148
 	var patients []*models.Patients
148
 	var patients []*models.Patients
149
 	var total int64
149
 	var total int64
150
-	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime)
150
+	patients, total, err = service.GetPatientList(adminUserInfo.CurrentOrgId, keywords, page, limit, schedulType, bindingState, lapseto, source, theStartTIme, theEndtTIme, contagion, reimbursement_way, isscheduling, isprescription, isStartTime, isEndTime, patientSoureType)
151
 
151
 
152
 	c.ServeSuccessJSON(map[string]interface{}{
152
 	c.ServeSuccessJSON(map[string]interface{}{
153
 		"patients": patients,
153
 		"patients": patients,
229
 	fmt.Println(code)
229
 	fmt.Println(code)
230
 	fmt.Println(patient)
230
 	fmt.Println(patient)
231
 
231
 
232
-	fmt.Println("contagions是什么", contagions)
233
 	if code > 0 {
232
 	if code > 0 {
234
 		c.ServeFailJSONWithSGJErrorCode(code)
233
 		c.ServeFailJSONWithSGJErrorCode(code)
235
 		return
234
 		return
367
 		TreatmentPlan:                patient.TreatmentPlan,
366
 		TreatmentPlan:                patient.TreatmentPlan,
368
 		Doctor:                       patient.Doctor,
367
 		Doctor:                       patient.Doctor,
369
 		RecordNumber:                 patient.RecordNumber,
368
 		RecordNumber:                 patient.RecordNumber,
369
+		PatientSource:                patient.PatientSource,
370
 	}
370
 	}
371
 
371
 
372
 	err = service.CreatePatientsNew(&patientsNew)
372
 	err = service.CreatePatientsNew(&patientsNew)
584
 		SchRemark:                 patient.SchRemark,
584
 		SchRemark:                 patient.SchRemark,
585
 		TreatmentPlan:             patient.TreatmentPlan,
585
 		TreatmentPlan:             patient.TreatmentPlan,
586
 		RecordNumber:              patient.RecordNumber,
586
 		RecordNumber:              patient.RecordNumber,
587
+		PatientSource:             patient.PatientSource,
587
 	}
588
 	}
588
 	//	//更新病人ID获取新表病人ID
589
 	//	//更新病人ID获取新表病人ID
589
 	err = service.UpdatepatientTwo(&patientsNew, id)
590
 	err = service.UpdatepatientTwo(&patientsNew, id)
1343
 		// 查询信息规挡的设置天数
1344
 		// 查询信息规挡的设置天数
1344
 
1345
 
1345
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1346
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1346
-		if infor.ID > 0 {
1347
+		if infor.ID > 0 && infor.WeekDay > 0 {
1347
 
1348
 
1348
 			var cha_time int64
1349
 			var cha_time int64
1349
 
1350
 
1717
 	// 查询信息规挡的设置天数
1718
 	// 查询信息规挡的设置天数
1718
 
1719
 
1719
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1720
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
1720
-	if infor.ID > 0 {
1721
+	if infor.ID > 0 && infor.WeekDay > 0 {
1721
 
1722
 
1722
 		var cha_time int64
1723
 		var cha_time int64
1723
 
1724
 
2053
 		// 查询信息规挡的设置天数
2054
 		// 查询信息规挡的设置天数
2054
 
2055
 
2055
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2056
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2056
-		if infor.ID > 0 {
2057
+		if infor.ID > 0 && infor.WeekDay > 0 {
2057
 
2058
 
2058
 			var cha_time int64
2059
 			var cha_time int64
2059
 
2060
 
2843
 		// 查询信息规挡的设置天数
2844
 		// 查询信息规挡的设置天数
2844
 
2845
 
2845
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2846
 		infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
2846
-		if infor.ID > 0 {
2847
+		if infor.ID > 0 && infor.WeekDay > 0 {
2847
 
2848
 
2848
 			var cha_time int64
2849
 			var cha_time int64
2849
 
2850
 
3058
 	// 查询信息规挡的设置天数
3059
 	// 查询信息规挡的设置天数
3059
 
3060
 
3060
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3061
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3061
-	if infor.ID > 0 {
3062
+	if infor.ID > 0 && infor.WeekDay > 0 {
3062
 
3063
 
3063
 		var cha_time int64
3064
 		var cha_time int64
3064
 
3065
 
3295
 	// 查询信息规挡的设置天数
3296
 	// 查询信息规挡的设置天数
3296
 
3297
 
3297
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3298
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3298
-	if infor.ID > 0 {
3299
+	if infor.ID > 0 && infor.WeekDay > 0 {
3299
 
3300
 
3300
 		var cha_time int64
3301
 		var cha_time int64
3301
 
3302
 
3366
 	// 查询信息规挡的设置天数
3367
 	// 查询信息规挡的设置天数
3367
 
3368
 
3368
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3369
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
3369
-	if infor.ID > 0 {
3370
+	if infor.ID > 0 && infor.WeekDay > 0 {
3370
 
3371
 
3371
 		var cha_time int64
3372
 		var cha_time int64
3372
 
3373
 
4910
 		record_number := patientBody["record_number"].(string)
4911
 		record_number := patientBody["record_number"].(string)
4911
 		patient.RecordNumber = record_number
4912
 		patient.RecordNumber = record_number
4912
 	}
4913
 	}
4914
+
4915
+	patient_source := int64(patientBody["patient_source"].(float64))
4916
+	if patient_source <= 0 {
4917
+		utils.ErrorLog("patient_source <= 0")
4918
+		code = enums.ErrorCodeParamWrong
4919
+		return
4920
+	}
4921
+	patient.PatientSource = patient_source
4922
+
4923
+	if patientBody["patient_start_time"] != nil && reflect.TypeOf(patientBody["patient_start_time"]).String() == "string" {
4924
+		patient_start_time := patientBody["patient_start_time"].(string)
4925
+		var startTime int64
4926
+		if len(patient_start_time) > 0 {
4927
+			theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", patient_start_time+" 00:00:00", loc)
4928
+
4929
+			startTime = theTime.Unix()
4930
+		}
4931
+		patient.PatientStartTime = startTime
4932
+	}
4933
+
4913
 	return
4934
 	return
4914
 }
4935
 }
4915
 
4936
 

+ 52 - 1
controllers/patient_dataconfig_api_controller.go View File

38
 
38
 
39
 	beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
39
 	beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
40
 
40
 
41
+	beego.Router("/api/patient/getcontextschedulelist", &PatientDataConfigAPIController{}, "Get:GetContextScheduleList")
42
+
41
 }
43
 }
42
 
44
 
43
 type PatientDataConfigAPIController struct {
45
 type PatientDataConfigAPIController struct {
1056
 		}
1058
 		}
1057
 		startTime = theTime.Unix()
1059
 		startTime = theTime.Unix()
1058
 	}
1060
 	}
1059
-	fmt.Println("startTime0000000000000000", startTime)
1060
 
1061
 
1061
 	//获取患者姓名
1062
 	//获取患者姓名
1062
 	patient, _ := service.GetPatientName(patientID)
1063
 	patient, _ := service.GetPatientName(patientID)
1090
 		"afterDislysis":   afterDislysis,
1091
 		"afterDislysis":   afterDislysis,
1091
 	})
1092
 	})
1092
 }
1093
 }
1094
+
1095
+func (this *PatientDataConfigAPIController) GetContextScheduleList() {
1096
+
1097
+	limit, _ := this.GetInt64("limit")
1098
+
1099
+	page, _ := this.GetInt64("page")
1100
+
1101
+	start_time := this.GetString("start_time")
1102
+
1103
+	end_time := this.GetString("end_time")
1104
+
1105
+	timeLayout := "2006-01-02"
1106
+	loc, _ := time.LoadLocation("Local")
1107
+	var startTime int64
1108
+	if len(start_time) > 0 {
1109
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1110
+		if err != nil {
1111
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1112
+			return
1113
+		}
1114
+		startTime = theTime.Unix()
1115
+	}
1116
+
1117
+	var endTime int64
1118
+	if len(end_time) > 0 {
1119
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1120
+		if err != nil {
1121
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1122
+			return
1123
+		}
1124
+		startTime = theTime.Unix()
1125
+	}
1126
+
1127
+	org_id := this.GetAdminUserInfo().CurrentOrgId
1128
+
1129
+	schedule, total, _ := service.GetContextScheduleListGroupPatientId(limit, page, startTime, endTime, org_id)
1130
+
1131
+	list, _, _ := service.GetContextScheduleListPatientId(startTime, endTime, org_id)
1132
+
1133
+	patients, _ := service.GetAllpatientThirty(org_id)
1134
+
1135
+	devicenumber, _ := service.GetAllBedNumber(org_id)
1136
+	this.ServeSuccessJSON(map[string]interface{}{
1137
+		"schedule":     schedule,
1138
+		"total":        total,
1139
+		"list":         list,
1140
+		"patients":     patients,
1141
+		"devicenumber": devicenumber,
1142
+	})
1143
+}

+ 10 - 5
controllers/print_data_api_controller.go View File

37
 	idStrs := strings.Split(schIDStr, ",")
37
 	idStrs := strings.Split(schIDStr, ",")
38
 	adminUserInfo := this.GetAdminUserInfo()
38
 	adminUserInfo := this.GetAdminUserInfo()
39
 
39
 
40
-	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 9905 || this.GetAdminUserInfo().CurrentOrgId == 10346 || this.GetAdminUserInfo().CurrentOrgId == 10441 {
40
+	if this.GetAdminUserInfo().CurrentOrgId == 10016 || this.GetAdminUserInfo().CurrentOrgId == 9882 || this.GetAdminUserInfo().CurrentOrgId == 10138 || this.GetAdminUserInfo().CurrentOrgId == 10278 || this.GetAdminUserInfo().CurrentOrgId == 9841 || this.GetAdminUserInfo().CurrentOrgId == 9845 || this.GetAdminUserInfo().CurrentOrgId == 10081 || this.GetAdminUserInfo().CurrentOrgId == 10215 || this.GetAdminUserInfo().CurrentOrgId == 10121 || this.GetAdminUserInfo().CurrentOrgId == 10234 || this.GetAdminUserInfo().CurrentOrgId == 10188 || this.GetAdminUserInfo().CurrentOrgId == 10217 || this.GetAdminUserInfo().CurrentOrgId == 10340 || this.GetAdminUserInfo().CurrentOrgId == 9905 || this.GetAdminUserInfo().CurrentOrgId == 10346 || this.GetAdminUserInfo().CurrentOrgId == 10441 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10101 {
41
+
41
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
42
 		schedules, getScheduleErr := service.GetSchedulesSeven(adminUserInfo.CurrentOrgId, idStrs)
42
 		for _, item := range schedules {
43
 		for _, item := range schedules {
43
 
44
 
88
 			item.Summer = summerVM
89
 			item.Summer = summerVM
89
 
90
 
90
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
91
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
91
-			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 {
92
+			if this.GetAdminUserInfo().CurrentOrgId != 10101 && this.GetAdminUserInfo().CurrentOrgId != 9671 && this.GetAdminUserInfo().CurrentOrgId != 10345 && this.GetAdminUserInfo().CurrentOrgId != 9970 {
92
 				item.Count = list.Count
93
 				item.Count = list.Count
93
 			}
94
 			}
94
-			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 {
95
-				if item.ScheduleDate <= 1640966400 {
95
+
96
+			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 {
97
+
98
+				if item.ScheduleDate <= 1672416000 {
99
+					fmt.Print("进来1")
96
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
100
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
97
 
101
 
98
 					item.Patient.TotalDialysis = listOne.Count
102
 					item.Patient.TotalDialysis = listOne.Count
100
 				}
104
 				}
101
 
105
 
102
 				if item.ScheduleDate >= 1672502400 {
106
 				if item.ScheduleDate >= 1672502400 {
107
+					fmt.Print("进来2")
103
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
108
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
104
 
109
 
105
 					item.Patient.TotalDialysis = listOne.Count
110
 					item.Patient.TotalDialysis = listOne.Count
136
 		})
141
 		})
137
 	}
142
 	}
138
 
143
 
139
-	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 && this.GetAdminUserInfo().CurrentOrgId != 10188 && this.GetAdminUserInfo().CurrentOrgId != 10217 && this.GetAdminUserInfo().CurrentOrgId != 10340 && this.GetAdminUserInfo().CurrentOrgId != 9905 && this.GetAdminUserInfo().CurrentOrgId != 10346 && this.GetAdminUserInfo().CurrentOrgId != 10441 {
144
+	if this.GetAdminUserInfo().CurrentOrgId != 10016 && this.GetAdminUserInfo().CurrentOrgId != 9882 && this.GetAdminUserInfo().CurrentOrgId != 10138 && this.GetAdminUserInfo().CurrentOrgId != 10278 && this.GetAdminUserInfo().CurrentOrgId != 9841 && this.GetAdminUserInfo().CurrentOrgId != 9845 && this.GetAdminUserInfo().CurrentOrgId != 10081 && this.GetAdminUserInfo().CurrentOrgId != 10215 && this.GetAdminUserInfo().CurrentOrgId != 10121 && this.GetAdminUserInfo().CurrentOrgId != 10234 && this.GetAdminUserInfo().CurrentOrgId != 10188 && this.GetAdminUserInfo().CurrentOrgId != 10217 && this.GetAdminUserInfo().CurrentOrgId != 10340 && this.GetAdminUserInfo().CurrentOrgId != 9905 && this.GetAdminUserInfo().CurrentOrgId != 10346 && this.GetAdminUserInfo().CurrentOrgId != 10441 && this.GetAdminUserInfo().CurrentOrgId != 9970 && this.GetAdminUserInfo().CurrentOrgId != 10101 {
140
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
145
 		schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
141
 		for _, item := range schedules {
146
 		for _, item := range schedules {
142
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)
147
 			list, _ := service.GetDialysisOrderCountSeven(item.PatientID, item.ScheduleDate)

+ 0 - 1
controllers/schedule_api_controller.go View File

216
 				sch_id := int64(items["sch_id"].(float64))
216
 				sch_id := int64(items["sch_id"].(float64))
217
 				if sch_id > 0 { //修改排班信息
217
 				if sch_id > 0 { //修改排班信息
218
 					schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
218
 					schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
219
-					fmt.Println("2222222")
220
 
219
 
221
 					if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
220
 					if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
222
 						utils.ErrorLog("mode_id")
221
 						utils.ErrorLog("mode_id")

+ 27 - 0
controllers/self_drug_api_congtroller.go View File

77
 	beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Get:DeleteDrugInventory")
77
 	beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Get:DeleteDrugInventory")
78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
78
 	beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
79
 	beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
80
+	beego.Router("/api/drug/getinventorydetailprintlist", &SelfDrugApiController{}, "Get:GetInventoryDetailPrintList")
80
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
81
 	beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
81
 	beego.Router("/api/drug/getdrugwarehouseinfototal", &StockManagerApiController{}, "Get:GetDrugWarehouseInfoTotal")
82
 	beego.Router("/api/drug/getdrugwarehouseinfototal", &StockManagerApiController{}, "Get:GetDrugWarehouseInfoTotal")
82
 
83
 
4008
 		"dealerList":       dealerList,
4009
 		"dealerList":       dealerList,
4009
 	})
4010
 	})
4010
 }
4011
 }
4012
+
4013
+func (this *SelfDrugApiController) GetInventoryDetailPrintList() {
4014
+	keyword := this.GetString("keyword")
4015
+	limit, _ := this.GetInt64("limit")
4016
+	page, _ := this.GetInt64("page")
4017
+	storehouse_id, _ := this.GetInt64("storehouse_id")
4018
+	ids := this.GetString("ids")
4019
+	idSplit := strings.Split(ids, ",")
4020
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4021
+	list, total, err := service.GetDrugInventoryDetailMapList(keyword, page, limit, orgId, storehouse_id, idSplit)
4022
+	inventoryList, _, _ := service.GetDrugInventoryDetailListTwo(keyword, page, limit, orgId, storehouse_id)
4023
+	houseList, _ := service.GetAllStoreHouseList(orgId)
4024
+	doctorList, _ := service.GetAllDoctorThree(orgId)
4025
+	if err != nil {
4026
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
4027
+		return
4028
+	}
4029
+
4030
+	this.ServeSuccessJSON(map[string]interface{}{
4031
+		"total":         total,
4032
+		"list":          list,
4033
+		"doctorList":    doctorList,
4034
+		"houseList":     houseList,
4035
+		"inventoryList": inventoryList,
4036
+	})
4037
+}

+ 3 - 1
controllers/stock_in_api_controller.go View File

7792
 	limit, _ := this.GetInt64("limit")
7792
 	limit, _ := this.GetInt64("limit")
7793
 	page, _ := this.GetInt64("page")
7793
 	page, _ := this.GetInt64("page")
7794
 	good_name := this.GetString("good_name")
7794
 	good_name := this.GetString("good_name")
7795
+	ids := this.GetString("ids")
7796
+	idSplit := strings.Split(ids, ",")
7795
 	fmt.Println(storehouse_id, good_name)
7797
 	fmt.Println(storehouse_id, good_name)
7796
 	orgId := this.GetAdminUserInfo().CurrentOrgId
7798
 	orgId := this.GetAdminUserInfo().CurrentOrgId
7797
 	houseList, _ := service.GetAllStoreHouseList(orgId)
7799
 	houseList, _ := service.GetAllStoreHouseList(orgId)
7798
-	list, total, _ := service.GetInventoryDetailList(good_name, limit, page, orgId, storehouse_id)
7800
+	list, total, _ := service.GetInventoryDetailPrintMapList(good_name, limit, page, orgId, storehouse_id, idSplit)
7799
 	this.ServeSuccessJSON(map[string]interface{}{
7801
 	this.ServeSuccessJSON(map[string]interface{}{
7800
 		"list":      list,
7802
 		"list":      list,
7801
 		"total":     total,
7803
 		"total":     total,

+ 1 - 1
main.go View File

14
 func main() {
14
 func main() {
15
 	//service.NewAutoCreateWeekSchedules()
15
 	//service.NewAutoCreateWeekSchedules()
16
 
16
 
17
-	service.BeginAutoCreateWeekDisinfectionJob()
17
+	//service.BeginAutoCreateWeekDisinfectionJob()
18
 	//service.BeginAutoCreatePlanJob()
18
 	//service.BeginAutoCreatePlanJob()
19
 	//	//service.AutoClearSchedules()
19
 	//	//service.AutoClearSchedules()
20
 	//service.BeginAutoCreateStaffScheduleJob()
20
 	//service.BeginAutoCreateStaffScheduleJob()

+ 23 - 0
models/device_models.go View File

1465
 
1465
 
1466
 	return "xt_dialysis_information"
1466
 	return "xt_dialysis_information"
1467
 }
1467
 }
1468
+
1469
+type XtDialysisRegistration struct {
1470
+	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
1471
+	RecordDate              int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1472
+	ModelNumber             string `gorm:"column:model_number" json:"model_number" form:"model_number"`
1473
+	UserCount               string `gorm:"column:user_count" json:"user_count" form:"user_count"`
1474
+	ProductDate             int64  `gorm:"column:product_date" json:"product_date" form:"product_date"`
1475
+	ExpiryDate              int64  `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1476
+	PackagingIdentification int64  `gorm:"column:packaging_identification" json:"packaging_identification" form:"packaging_identification"`
1477
+	DestroyPeople           int64  `gorm:"column:destroy_people" json:"destroy_people" form:"destroy_people"`
1478
+	DestroyNubmer           string `gorm:"column:destroy_nubmer" json:"destroy_nubmer" form:"destroy_nubmer"`
1479
+	DestroyWay              int64  `gorm:"column:destroy_way" json:"destroy_way" form:"destroy_way"`
1480
+	Leader                  int64  `gorm:"column:leader" json:"leader" form:"leader"`
1481
+	UserOrgId               int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1482
+	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
1483
+	Ctime                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1484
+	Mtime                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1485
+}
1486
+
1487
+func (XtDialysisRegistration) TableName() string {
1488
+
1489
+	return "xt_dialysis_registration"
1490
+}

+ 1 - 0
models/dialysis.go View File

898
 	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
898
 	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
899
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
899
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
900
 	Url            string `gorm:"column:url" json:"url" form:"url"`
900
 	Url            string `gorm:"column:url" json:"url" form:"url"`
901
+	ZoneId         int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
901
 }
902
 }
902
 
903
 
903
 func (XtDialysisOrder) TableName() string {
904
 func (XtDialysisOrder) TableName() string {

+ 2 - 0
models/his_models.go View File

43
 	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
43
 	SpecailProject              int64   `gorm:"column:specail_project" json:"specail_project" form:"specail_project"`
44
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
44
 	SocialSecurityDirectoryCode string  `gorm:"column:social_security_directory_code" json:"social_security_directory_code" form:"social_security_directory_code"`
45
 	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
45
 	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
46
+	IsPrint                     int64   `gorm:"column:is_print" json:"is_print" form:"is_print"`
46
 }
47
 }
47
 
48
 
48
 func (XtHisProject) TableName() string {
49
 func (XtHisProject) TableName() string {
600
 	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
601
 	RecordDate                  int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
601
 	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
602
 	SingleDose                  string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
602
 	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
603
 	ExecutionFrequency          string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
604
+	IsPrint                     int64   `gorm:"column:is_print" json:"is_print" form:"is_print"`
603
 }
605
 }
604
 
606
 
605
 func (HisProject) TableName() string {
607
 func (HisProject) TableName() string {

+ 26 - 4
models/patient_models.go View File

222
 	TreatmentPlan            string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
222
 	TreatmentPlan            string  `gorm:"column:treatment_plan" json:"treatment_plan" form:"treatment_plan"`
223
 	Doctor                   int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
223
 	Doctor                   int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
224
 	RecordNumber             string  `gorm:"column:record_number" json:"record_number" form:"record_number"`
224
 	RecordNumber             string  `gorm:"column:record_number" json:"record_number" form:"record_number"`
225
+	PatientSource            int64   `gorm:"column:patient_source" json:"patient_source" form:"patient_source"`
226
+	PatientStartTime         int64   `gorm:"column:patient_start_time" json:"patient_start_time" form:"patient_start_time"`
225
 }
227
 }
226
 
228
 
227
 func (Patients) TableName() string {
229
 func (Patients) TableName() string {
814
 	Doctor                       int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
816
 	Doctor                       int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
815
 	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
817
 	ScheduleRemark               string  `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
816
 	RecordNumber                 string  `gorm:"column:record_number" json:"record_number" form:"record_number"`
818
 	RecordNumber                 string  `gorm:"column:record_number" json:"record_number" form:"record_number"`
819
+	PatientSource                int64   `gorm:"column:patient_source" json:"patient_source" form:"patient_source"`
820
+	PatientStartTime             int64   `gorm:"column:patient_start_time" json:"patient_start_time" form:"patient_start_time"`
817
 }
821
 }
818
 
822
 
819
 func (XtPatientsNew) TableName() string {
823
 func (XtPatientsNew) TableName() string {
1663
 }
1667
 }
1664
 
1668
 
1665
 type DialysisPrescriptionThrity struct {
1669
 type DialysisPrescriptionThrity struct {
1666
-	ID        int64  `gorm:"column:id" json:"id"`
1667
-	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id"`
1668
-	PatientId int64  `gorm:"column:patient_id" json:"patient_id"`
1669
-	Remark    string `gorm:"column:remark" json:"remark" form:"remark"`
1670
+	ID             int64  `gorm:"column:id" json:"id"`
1671
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id"`
1672
+	PatientId      int64  `gorm:"column:patient_id" json:"patient_id"`
1673
+	Remark         string `gorm:"column:remark" json:"remark" form:"remark"`
1674
+	Chaptalization string `gorm:"column:chaptalization" json:"chaptalization" form:"chaptalization"`
1670
 }
1675
 }
1671
 
1676
 
1672
 func (DialysisPrescriptionThrity) TableName() string {
1677
 func (DialysisPrescriptionThrity) TableName() string {
1954
 func (XtPatientPhysiqueCheck) TableName() string {
1959
 func (XtPatientPhysiqueCheck) TableName() string {
1955
 	return "xt_patient_physique_check"
1960
 	return "xt_patient_physique_check"
1956
 }
1961
 }
1962
+
1963
+type ConScheduleList struct {
1964
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1965
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
1966
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
1967
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1968
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
1969
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1970
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1971
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
1972
+	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
1973
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
1974
+}
1975
+
1976
+func (ConScheduleList) TableName() string {
1977
+	return "xt_schedule"
1978
+}

+ 24 - 0
models/schedule_models.go View File

710
 func (ScheduleConfig) TableName() string {
710
 func (ScheduleConfig) TableName() string {
711
 	return "xt_schedule_config"
711
 	return "xt_schedule_config"
712
 }
712
 }
713
+
714
+type VmLongBloodSchedule struct {
715
+	ID              int64                      `gorm:"column:id" json:"id" form:"id"`
716
+	UserOrgId       int64                      `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
717
+	PartitionId     int64                      `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
718
+	BedId           int64                      `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
719
+	PatientId       int64                      `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
720
+	ScheduleDate    int64                      `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
721
+	ScheduleType    int64                      `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
722
+	ScheduleWeek    int64                      `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
723
+	ModeId          int64                      `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
724
+	Status          int64                      `gorm:"column:status" json:"status" form:"status"`
725
+	CreatedTime     int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
726
+	UpdatedTime     int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
727
+	IsExport        int64                      `gorm:"column:is_export" json:"is_export" form:"is_export"`
728
+	DeviceNumber    *NewMDeviceNumberVM        `gorm:"ForeignKey:BedId" json:"device_number"`
729
+	SchedualPatient *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
730
+	XtDoctorAdvice  []*XtDoctorAdvice          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"xt_doctor_advice"`
731
+	HisDoctorAdvice []*HisDoctorAdviceFourty   `gorm:"ForeignKey:PatientId,AdviceDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_doctor_advice"`
732
+}
733
+
734
+func (VmLongBloodSchedule) TableName() string {
735
+	return "xt_schedule"
736
+}

+ 28 - 0
service/dialysis_solution_service.go View File

556
 
556
 
557
 	return schedule, err
557
 	return schedule, err
558
 }
558
 }
559
+
560
+func GetLongDialysisAdviceToday(orgID int64, schedule_type int64, partition_id []string, scheduleDate int64) (schedule []*models.VmLongBloodSchedule, err error) {
561
+
562
+	db := XTReadDB().Model(&models.VmLongBloodSchedule{}).Where("status = 1")
563
+
564
+	if scheduleDate > 0 {
565
+		db = db.Where("schedule_date = ?", scheduleDate)
566
+	}
567
+	if schedule_type > 0 {
568
+		db = db.Where("schedule_type = ?", schedule_type)
569
+	}
570
+	if len(partition_id) > 0 {
571
+		db = db.Where("partition_id in(?)", partition_id)
572
+	}
573
+
574
+	if orgID > 0 {
575
+		db = db.Where("user_org_id  = ?", orgID)
576
+	}
577
+	err = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
578
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
579
+		Preload("XtDoctorAdvice", "status = 1 AND user_org_id = ?  and advice_type = 1", orgID).
580
+		Preload("HisDoctorAdvice", func(db *gorm.DB) *gorm.DB {
581
+			return db.Where("user_org_id = ? and status = 1 and advice_date = ?", orgID, scheduleDate).Preload("Drug", "org_id =? and status = 1", orgID)
582
+		}).Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).Find(&schedule).Error
583
+
584
+	return schedule, err
585
+
586
+}

+ 17 - 0
service/doctor_schedule_service.go View File

801
 	err = db.Select("partition_id,Count(id) as id,user_org_id").Group("partition_id").Scan(&schedule).Error
801
 	err = db.Select("partition_id,Count(id) as id,user_org_id").Group("partition_id").Scan(&schedule).Error
802
 	return schedule, err
802
 	return schedule, err
803
 }
803
 }
804
+
805
+func GetMobileScheduleListByScheduleDate(org_id int64, schedule_date int64) (schedule []*models.Search_Schedule, err error) {
806
+
807
+	db := XTReadDB().Model(&schedule).Where("status= 1")
808
+
809
+	if org_id > 0 {
810
+		db = db.Where("user_org_id = ?", org_id)
811
+	}
812
+
813
+	if schedule_date > 0 {
814
+		db = db.Where("schedule_date=?", schedule_date)
815
+	}
816
+
817
+	err = db.Find(&schedule).Error
818
+
819
+	return schedule, err
820
+}

+ 1 - 1
service/his_project_service.go View File

59
 
59
 
60
 func UpdatedProject(id int64, pro *models.XtHisProject) error {
60
 func UpdatedProject(id int64, pro *models.XtHisProject) error {
61
 
61
 
62
-	err := XTWriteDB().Model(&pro).Where("id=?", id).Updates(map[string]interface{}{"project_name": pro.ProjectName, "pinyin": pro.Pinyin, "wubi": pro.Pinyin, "price": pro.Price, "unit": pro.Unit, "cost_classify": pro.CostClassify, "executive_section": pro.ExecutiveSection, "medical_coverage": pro.MedicalCoverage, "statistical_classification": pro.StatisticalClassification, "disease_directory": pro.DiseaseDirectory, "is_record": pro.IsRecord, "medical_code": pro.MedicalCode, "tube_color": pro.TubeColor, "medical_status": pro.MedicalStatus, "remark": pro.Remark, "sign": pro.Sign, "default_number": pro.DefaultNumber, "is_default": pro.IsDefault, "is_charge": pro.IsCharge, "is_estimate": pro.IsEstimate, "is_workload": pro.IsWorkload, "sort": pro.Sort, "doctor_advice": pro.DoctorAdvice, "single_dose": pro.SingleDose, "execution_frequency": pro.ExecutionFrequency, "delivery_way": pro.DeliveryWay, "number_days": pro.NumberDays, "total": pro.Total, "updated_time": pro.UpdatedTime, "category": pro.Category, "specail_project": pro.SpecailProject, "social_security_directory_code": pro.SocialSecurityDirectoryCode, "record_date": pro.RecordDate}).Error
62
+	err := XTWriteDB().Model(&pro).Where("id=?", id).Updates(map[string]interface{}{"project_name": pro.ProjectName, "pinyin": pro.Pinyin, "wubi": pro.Pinyin, "price": pro.Price, "unit": pro.Unit, "cost_classify": pro.CostClassify, "executive_section": pro.ExecutiveSection, "medical_coverage": pro.MedicalCoverage, "statistical_classification": pro.StatisticalClassification, "disease_directory": pro.DiseaseDirectory, "is_record": pro.IsRecord, "medical_code": pro.MedicalCode, "tube_color": pro.TubeColor, "medical_status": pro.MedicalStatus, "remark": pro.Remark, "sign": pro.Sign, "default_number": pro.DefaultNumber, "is_default": pro.IsDefault, "is_charge": pro.IsCharge, "is_estimate": pro.IsEstimate, "is_workload": pro.IsWorkload, "sort": pro.Sort, "doctor_advice": pro.DoctorAdvice, "single_dose": pro.SingleDose, "execution_frequency": pro.ExecutionFrequency, "delivery_way": pro.DeliveryWay, "number_days": pro.NumberDays, "total": pro.Total, "updated_time": pro.UpdatedTime, "category": pro.Category, "specail_project": pro.SpecailProject, "social_security_directory_code": pro.SocialSecurityDirectoryCode, "record_date": pro.RecordDate, "is_print": pro.IsPrint}).Error
63
 	return err
63
 	return err
64
 }
64
 }
65
 
65
 

+ 1 - 1
service/his_service.go View File

941
 }
941
 }
942
 
942
 
943
 func FindLastPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
943
 func FindLastPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
944
-	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date < ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
944
+	err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date < ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).Last(&info).Error
945
 	return
945
 	return
946
 
946
 
947
 }
947
 }

+ 4 - 4
service/inspection_service.go View File

12
 		var count int
12
 		var count int
13
 		err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = 0", orgId).Count(&count).Error
13
 		err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = 0", orgId).Count(&count).Error
14
 		if count > 0 {
14
 		if count > 0 {
15
-			err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = 0", orgId).Order("project_id").Find(&reference).Error
15
+			err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = 0", orgId).Order("project_id,created_time").Find(&reference).Error
16
 		} else {
16
 		} else {
17
-			err = readDb.Model(&models.InspectionReference{}).Where("org_id=0 and status=1 and inspection_type = 0").Order("project_id").Find(&reference).Error
17
+			err = readDb.Model(&models.InspectionReference{}).Where("org_id=0 and status=1 and inspection_type = 0").Order("project_id,created_time").Find(&reference).Error
18
 		}
18
 		}
19
 
19
 
20
 	} else {
20
 	} else {
22
 		var count int
22
 		var count int
23
 		err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = ?", orgId, inspect_type).Count(&count).Error
23
 		err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = ?", orgId, inspect_type).Count(&count).Error
24
 		if count > 0 {
24
 		if count > 0 {
25
-			err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = ?", orgId, inspect_type).Order("project_id").Find(&reference).Error
25
+			err = readDb.Model(&models.InspectionReference{}).Where("org_id=? and status=1 and inspection_type = ?", orgId, inspect_type).Order("project_id,created_time").Find(&reference).Error
26
 		} else {
26
 		} else {
27
-			err = readDb.Model(&models.InspectionReference{}).Where("org_id=0 and status=1 and inspection_type = ?", inspect_type).Order("project_id").Find(&reference).Error
27
+			err = readDb.Model(&models.InspectionReference{}).Where("org_id=0 and status=1 and inspection_type = ?", inspect_type).Order("project_id,created_time").Find(&reference).Error
28
 		}
28
 		}
29
 
29
 
30
 	}
30
 	}

+ 1 - 1
service/manage_center_service.go View File

853
 				BatchNumber:             info.BatchNumber,
853
 				BatchNumber:             info.BatchNumber,
854
 				Count:                   prescribingNumber,
854
 				Count:                   prescribingNumber,
855
 				UserOrgId:               advice.UserOrgId,
855
 				UserOrgId:               advice.UserOrgId,
856
-				PatientId:               0,
856
+				PatientId:               advice.PatientId,
857
 				SystemTime:              info.SysRecordTime,
857
 				SystemTime:              info.SysRecordTime,
858
 				ConsumableType:          7,
858
 				ConsumableType:          7,
859
 				IsSys:                   0,
859
 				IsSys:                   0,

+ 53 - 0
service/manage_service.go View File

1741
 	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&list).Error
1741
 	err = XTReadDB().Where("user_org_id = ? and status = 1", user_org_id).Find(&list).Error
1742
 	return
1742
 	return
1743
 }
1743
 }
1744
+
1745
+func GetDialysisOrderPatient(org_id int64) (order []*models.XtDialysisOrder, err error) {
1746
+
1747
+	err = XTReadDB().Where("user_org_id = ? and dialysis_date>=? and dialysis_date<=? and status =1", org_id, 1672502400, 1675094400).Find(&order).Error
1748
+
1749
+	return order, err
1750
+}
1751
+
1752
+func CreateObjectRegistration(registration models.XtDialysisRegistration) error {
1753
+
1754
+	err := XTWriteDB().Create(&registration).Error
1755
+
1756
+	return err
1757
+}
1758
+
1759
+func GetRegistrationDisinfectList(limit int64, page int64, start_time int64, end_time int64, user_org_id int64) (list []*models.XtDialysisRegistration, total int64, err error) {
1760
+
1761
+	offset := (page - 1) * limit
1762
+
1763
+	db := XTReadDB().Model(&list).Where("status =1")
1764
+	if start_time > 0 {
1765
+		db = db.Where("record_date >= ?", start_time)
1766
+	}
1767
+	if end_time > 0 {
1768
+		db = db.Where("record_date <= ?", end_time)
1769
+	}
1770
+	if user_org_id > 0 {
1771
+		db = db.Where("user_org_id = ?", user_org_id)
1772
+	}
1773
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&list).Error
1774
+	return list, total, err
1775
+}
1776
+
1777
+func GetObjectRegistrationByIdList(id int64) (models.XtDialysisRegistration, error) {
1778
+
1779
+	registration := models.XtDialysisRegistration{}
1780
+	err := XTReadDB().Where("id = ? and status=1", id).Find(&registration).Error
1781
+	return registration, err
1782
+
1783
+}
1784
+
1785
+func UpdateObjectRegistration(registration models.XtDialysisRegistration) error {
1786
+
1787
+	err := XTWriteDB().Save(&registration).Error
1788
+
1789
+	return err
1790
+}
1791
+
1792
+func DeleteObjectTregistration(id int64) error {
1793
+
1794
+	err := XTWriteDB().Model(&models.XtDialysisRegistration{}).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
1795
+	return err
1796
+}

+ 305 - 9
service/mobile_dialysis_service.go View File

2637
 }
2637
 }
2638
 
2638
 
2639
 // 透析方案
2639
 // 透析方案
2640
-func GetDialysisSolution(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
2640
+func GetDialysisSolution(orgID int64, patientID int64, mode_id int64) (models.DialysisSolution, error) {
2641
 	var record models.DialysisSolution
2641
 	var record models.DialysisSolution
2642
 	err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2642
 	err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2643
-	if err != nil {
2644
-		if err == gorm.ErrRecordNotFound {
2645
-			return nil, nil
2646
-		} else {
2647
-			return nil, err
2648
-		}
2649
-	}
2650
-	return &record, nil
2643
+	return record, err
2651
 }
2644
 }
2652
 
2645
 
2653
 func GetDialysisSolutionOne(orgID int64, mode_id int64) (*models.DialysisSolution, error) {
2646
 func GetDialysisSolutionOne(orgID int64, mode_id int64) (*models.DialysisSolution, error) {
7244
 
7237
 
7245
 	return weight, err
7238
 	return weight, err
7246
 }
7239
 }
7240
+
7241
+func MobileGetLongScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType int, patientType int, adminUserId int64, deliverWay string, scheduleType int64, partitonType int64, patient_id int64, execution_state int64, cost_type int64, execution_frequency string) ([]*MScheduleDoctorAdviceVM, error) {
7242
+
7243
+	var vms []*MScheduleDoctorAdviceVM
7244
+	adviceWhere := ""
7245
+	adviceCondition := []interface{}{}
7246
+	if adviceType == 1 {
7247
+		if patientType == 0 {
7248
+			if patient_id > 0 {
7249
+				if execution_state > 0 {
7250
+					if cost_type > 0 {
7251
+						if len(execution_frequency) > 0 {
7252
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and patient_id = ? and execution_state = ? and is_settle = ? and execution_frequency = ?"
7253
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type, execution_frequency)
7254
+						} else {
7255
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_state = ? and is_settle = ?"
7256
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type)
7257
+						}
7258
+
7259
+					} else {
7260
+						if len(execution_frequency) > 0 {
7261
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_state = ? and execution_frequency = ?"
7262
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, execution_frequency)
7263
+						} else {
7264
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and patient_id = ? and execution_state = ?"
7265
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state)
7266
+						}
7267
+
7268
+					}
7269
+
7270
+				} else {
7271
+					if cost_type > 0 {
7272
+						if len(execution_frequency) > 0 {
7273
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and patient_id = ? and is_settle = ? and execution_frequency = ?"
7274
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type, execution_frequency)
7275
+						} else {
7276
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and patient_id = ? and is_settle = ? "
7277
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type)
7278
+						}
7279
+
7280
+					} else {
7281
+						if len(execution_frequency) > 0 {
7282
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? and execution_frequency = ?"
7283
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_frequency)
7284
+						} else {
7285
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 and patient_id = ? "
7286
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id)
7287
+						}
7288
+
7289
+					}
7290
+
7291
+				}
7292
+
7293
+			} else {
7294
+				if execution_state > 0 {
7295
+					if cost_type > 0 {
7296
+						if len(execution_frequency) > 0 {
7297
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and execution_state = ? and is_settle = ? and execution_frequency = ?"
7298
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type, execution_frequency)
7299
+						} else {
7300
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and execution_state = ? and is_settle = ?"
7301
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type)
7302
+						}
7303
+
7304
+					} else {
7305
+						if len(execution_frequency) > 0 {
7306
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and execution_state = ? and execution_frequency = ?"
7307
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, execution_frequency)
7308
+						} else {
7309
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and execution_state = ?"
7310
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state)
7311
+						}
7312
+
7313
+					}
7314
+
7315
+				} else {
7316
+					if cost_type > 0 {
7317
+						adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  and is_settle = ? "
7318
+						adviceCondition = append(adviceCondition, adviceWhere, orgID, cost_type)
7319
+					} else {
7320
+						adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1   "
7321
+						adviceCondition = append(adviceCondition, adviceWhere, orgID)
7322
+					}
7323
+
7324
+				}
7325
+
7326
+			}
7327
+
7328
+		} else if patientType == 1 {
7329
+			if patient_id > 0 {
7330
+				if execution_state > 0 {
7331
+					if cost_type > 0 {
7332
+						if len(execution_frequency) > 0 {
7333
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and patient_id = ? and execution_state = ? and  is_settle = ? and execution_frequency = ?"
7334
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state, cost_type, execution_frequency)
7335
+						} else {
7336
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and patient_id = ? and execution_state = ? and  is_settle = ?"
7337
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state, cost_type)
7338
+						}
7339
+
7340
+					} else {
7341
+						if len(execution_frequency) > 0 {
7342
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and execution_state = ? and execution_frequency = ?"
7343
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state, execution_frequency)
7344
+						} else {
7345
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and patient_id = ? and execution_state = ?"
7346
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_state)
7347
+						}
7348
+
7349
+					}
7350
+
7351
+				} else {
7352
+					if cost_type > 0 {
7353
+						if len(execution_frequency) > 0 {
7354
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and patient_id = ? and is_settle = ?and execution_frequency = ?"
7355
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, cost_type, execution_frequency)
7356
+						} else {
7357
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ? and is_settle = ?"
7358
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, cost_type)
7359
+						}
7360
+
7361
+					} else {
7362
+						if len(execution_frequency) > 0 {
7363
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and patient_id = ? and execution_frequency = ?"
7364
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id, execution_frequency)
7365
+						} else {
7366
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and patient_id = ?"
7367
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, patient_id)
7368
+						}
7369
+
7370
+					}
7371
+
7372
+				}
7373
+
7374
+			} else {
7375
+				if execution_state > 0 {
7376
+					if cost_type > 0 {
7377
+						if len(execution_frequency) > 0 {
7378
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? and execution_state=? and is_settle = ?and execution_frequency = ?"
7379
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state, cost_type, execution_frequency)
7380
+						} else {
7381
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and execution_state=? and is_settle = ?"
7382
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state, cost_type)
7383
+						}
7384
+
7385
+					} else {
7386
+						if len(execution_frequency) > 0 {
7387
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and execution_state=?and execution_frequency = ?"
7388
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state, execution_frequency)
7389
+						} else {
7390
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and execution_state=?"
7391
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_state)
7392
+						}
7393
+
7394
+					}
7395
+
7396
+				} else {
7397
+					if cost_type > 0 {
7398
+						if len(execution_frequency) > 0 {
7399
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and  is_settle = ? and execution_frequency = ?"
7400
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, cost_type, execution_frequency)
7401
+						} else {
7402
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and  is_settle = ? "
7403
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, cost_type)
7404
+						}
7405
+
7406
+					} else {
7407
+						if len(execution_frequency) > 0 {
7408
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND advice_doctor = ? and execution_frequency = ?"
7409
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId, execution_frequency)
7410
+						} else {
7411
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND advice_doctor = ? "
7412
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, adminUserId)
7413
+						}
7414
+
7415
+					}
7416
+
7417
+				}
7418
+
7419
+			}
7420
+
7421
+		} else if patientType == 2 {
7422
+			if patient_id > 0 {
7423
+				if execution_state > 0 {
7424
+					if cost_type > 0 {
7425
+						if len(execution_frequency) > 0 {
7426
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ? and execution_state = ? and is_settle = ?and execution_frequency = ?"
7427
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type, execution_frequency)
7428
+						} else {
7429
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ? and execution_state = ? and is_settle = ?"
7430
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, cost_type)
7431
+						}
7432
+
7433
+					} else {
7434
+						if len(execution_frequency) > 0 {
7435
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ? and execution_state = ? and execution_frequency = ?"
7436
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state, execution_frequency)
7437
+						} else {
7438
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ? and execution_state = ?"
7439
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_state)
7440
+						}
7441
+
7442
+					}
7443
+
7444
+				} else {
7445
+					if cost_type > 0 {
7446
+						if len(execution_frequency) > 0 {
7447
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ? and is_settle = ? and execution_frequency = ?"
7448
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type, execution_frequency)
7449
+						} else {
7450
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ? and is_settle = ?"
7451
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, cost_type)
7452
+						}
7453
+
7454
+					} else {
7455
+						if len(execution_frequency) > 0 {
7456
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and patient_id = ?  and execution_frequency = ?"
7457
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id, execution_frequency)
7458
+						} else {
7459
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and patient_id = ?"
7460
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, patient_id)
7461
+						}
7462
+
7463
+					}
7464
+
7465
+				}
7466
+			} else {
7467
+				if execution_state > 0 {
7468
+
7469
+					if cost_type > 0 {
7470
+						if len(execution_frequency) > 0 {
7471
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1AND execution_staff = 0 and execution_state = ? and is_settle = ? and execution_frequency = ?"
7472
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type, execution_frequency)
7473
+						} else {
7474
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1AND execution_staff = 0 and execution_state = ? and is_settle = ?"
7475
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, cost_type)
7476
+						}
7477
+
7478
+					} else {
7479
+						if len(execution_frequency) > 0 {
7480
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and execution_state = ? and execution_frequency = ?"
7481
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state, execution_frequency)
7482
+						} else {
7483
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and execution_state = ?"
7484
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_state)
7485
+						}
7486
+
7487
+					}
7488
+
7489
+				} else {
7490
+
7491
+					if cost_type > 0 {
7492
+						if len(execution_frequency) > 0 {
7493
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and is_settle = ? and execution_frequency = ?"
7494
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, cost_type, execution_frequency)
7495
+						} else {
7496
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0 and is_settle = ?"
7497
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, cost_type)
7498
+						}
7499
+
7500
+					} else {
7501
+						if len(execution_frequency) > 0 {
7502
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1 AND execution_staff = 0 and execution_frequency = ?"
7503
+							adviceCondition = append(adviceCondition, adviceWhere, orgID, execution_frequency)
7504
+						} else {
7505
+							adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 1  AND execution_staff = 0"
7506
+							adviceCondition = append(adviceCondition, adviceWhere, orgID)
7507
+						}
7508
+
7509
+					}
7510
+
7511
+				}
7512
+
7513
+			}
7514
+
7515
+		}
7516
+
7517
+	}
7518
+
7519
+	db := readDb.Table("xt_schedule")
7520
+	if scheduleType > 0 {
7521
+		db = db.Where("schedule_type = ?", scheduleType)
7522
+	}
7523
+	if partitonType > 0 {
7524
+		db = db.Where("partition_id = ?", partitonType)
7525
+	}
7526
+	db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
7527
+		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
7528
+			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
7529
+		}).
7530
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
7531
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
7532
+		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
7533
+		Preload("DialysisAssesmentBefor", "status =1 AND user_org_id = ? and assessment_date =?", orgID, scheduleDate).
7534
+		Preload("DoctorAdvices", adviceCondition...).
7535
+		Where("status = 1 AND user_org_id = ?", orgID)
7536
+	if scheduleDate != 0 {
7537
+		db = db.Where("schedule_date = ?", scheduleDate)
7538
+	}
7539
+
7540
+	err := db.Find(&vms).Error
7541
+	return vms, err
7542
+}

+ 47 - 4
service/patient_service.go View File

12
 )
12
 )
13
 
13
 
14
 // GetPatientList 返回患者的列表
14
 // GetPatientList 返回患者的列表
15
-func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool) (patients []*models.Patients, total int64, err error) {
15
+func GetPatientList(orgID int64, keywords string, page, limit, schedulType, bindingState, lapseto, source, startTime, endTime, contagion, reimbursementWay, isscheduling, isprescription int64, isStartTime, isEndTime bool, patientSoureType int64) (patients []*models.Patients, total int64, err error) {
16
 
16
 
17
 	db := readDb.Table("xt_patients as p").Where("p.status=1")
17
 	db := readDb.Table("xt_patients as p").Where("p.status=1")
18
 	if orgID > 0 {
18
 	if orgID > 0 {
65
 		db = db.Where("p.created_time<=?", endTime)
65
 		db = db.Where("p.created_time<=?", endTime)
66
 	}
66
 	}
67
 
67
 
68
+	if patientSoureType > 0 {
69
+		db = db.Where("p.patient_source =?", patientSoureType)
70
+	}
71
+
68
 	offset := (page - 1) * limit
72
 	offset := (page - 1) * limit
69
 	if lapseto == 2 || lapseto == 3 {
73
 	if lapseto == 2 || lapseto == 3 {
70
 		err = db.Order("p.death_time desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
74
 		err = db.Order("p.death_time desc").Select(" p.id, p.user_org_id, p.user_id, p.patient_type, p.dialysis_no, p.admission_number, p.source, p.lapseto, p.partition_id, p.bed_id, p.name, p.alias, p.gender, p.marital_status, p.id_card_no, p.birthday, p.reimbursement_way_id, p.health_care_type, p.health_care_no, p.health_care_due_date, p.height, p.blood_type, p.rh, p.health_care_due_alert_date, p.education_level, p.profession, p.phone, p.home_telephone, p.relative_phone, p.relative_relations, p.home_address, p.work_unit, p.unit_address, p.children, p.receiving_date, p.is_hospital_first_dialysis, p.first_dialysis_date, p.first_dialysis_hospital, p.induction_period, p.initial_dialysis, p.total_dialysis, p.attending_doctor_id, p.head_nurse_id, p.evaluate, p.diagnose, p.remark, p.registrars_id, p.registrars, p.qr_code, p.binding_state, p.status, p.created_time, p.updated_time,p.user_sys_before_count,p.out_reason,p.death_time,p.is_infectious").Group("p.id").Count(&total).Offset(offset).Limit(limit).Find(&patients).Error
512
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Count(&total)
516
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Count(&total)
513
 	return
517
 	return
514
 }
518
 }
515
-
516
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
519
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
517
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and lapseto=? and status=1", orgID, lapseto).Count(&total)
520
 	readDb.Model(&models.Patients{}).Where("user_org_id=? and lapseto=? and status=1", orgID, lapseto).Count(&total)
518
 	return
521
 	return
871
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
874
 func UpdatepatientTwo(patientsNew *models.XtPatientsNew, id int64) error {
872
 
875
 
873
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
876
 	err := XTWriteDB().Model(&patientsNew).Where("blood_id = ?", id).Update(map[string]interface{}{"user_org_id": patientsNew.UserOrgId, "user_id": patientsNew.UserId, "avatar": patientsNew.Avatar, "patient_type": patientsNew.Avatar, "dialysis_no": patientsNew.DialysisNo, "admission_number": patientsNew.AdmissionNumber, "source": patientsNew.Source, "lapseto": patientsNew.Lapseto, "partition_id": patientsNew.PartitionId, "bed_id": patientsNew.BedId, "name": patientsNew.Name, "alias": patientsNew.Alias, "gender": patientsNew.Gender, "marital_status": patientsNew.MaritalStatus, "id_card_no": patientsNew.IdCardNo, "birthday": patientsNew.Birthday, "reimbursement_way_id": patientsNew.ReimbursementWayId, "health_care_type": patientsNew.HealthCareType, "health_care_no": patientsNew.HealthCareType, "health_care_due_date": patientsNew.HealthCareType, "height": patientsNew.Height, "blood_type": patientsNew.BloodType, "rh": patientsNew.Rh, "health_care_due_alert_date": patientsNew.HealthCareDueAlertDate, "education_level": patientsNew.EducationLevel, "profession": patientsNew.Profession, "phone": patientsNew.Phone, "home_telephone": patientsNew.HomeTelephone, "relative_phone": patientsNew.RelativePhone, "relative_relations": patientsNew.RelativeRelations, "home_address": patientsNew.HomeAddress, "work_unit": patientsNew.WorkUnit, "unit_address": patientsNew.UnitAddress, "children": patientsNew.Children, "receiving_date": patientsNew.ReceivingDate, "is_hospital_first_dialysis": patientsNew.IsHospitalFirstDialysis, "first_dialysis_date": patientsNew.FirstDialysisDate, "first_dialysis_hospital": patientsNew.FirstDialysisHospital, "predialysis_condition": patientsNew.PredialysisCondition, "pre_hospital_dialysis_frequency": patientsNew.PreHospitalDialysisFrequency, "pre_hospital_dialysis_times": patientsNew.PreHospitalDialysisFrequency, "hospital_first_dialysis_date": patientsNew.HospitalFirstDialysisDate, "induction_period": patientsNew.InductionPeriod, "initial_dialysis": patientsNew.InitialDialysis, "total_dialysis": patientsNew.TotalDialysis, "attending_doctor_id": patientsNew.AttendingDoctorId, "head_nurse_id": patientsNew.HeadNurseId, "evaluate": patientsNew.Evaluate, "diagnose": patientsNew.Diagnose, "remark": patientsNew.Remark, "registrars_id": patientsNew.RegistrarsId, "registrars": patientsNew.Registrars, "qr_code": patientsNew.QrCode, "binding_state": patientsNew.BindingState, "patient_complains": patientsNew.PatientComplains, "present_history": patientsNew.PresentHistory, "past_history": patientsNew.PastHistory, "temperature": patientsNew.Temperature,
874
-		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark, "treatment_plan": patientsNew.TreatmentPlan, "record_number": patientsNew.RecordNumber}).Error
877
+		"pulse": patientsNew.Pulse, "respiratory": patientsNew.Respiratory, "sbp": patientsNew.Sbp, "dbp": patientsNew.Dbp, "nation": patientsNew.Nation, "native_place": patientsNew.NativePlace, "age": patientsNew.Age, "infectious_next_record_time": patientsNew.InfectiousNextRecordTime, "is_infectious": patientsNew.IsInfectious, "remind_cycle": patientsNew.RemindCycle, "response_result": patientsNew.ResponseResult, "is_open_remind": patientsNew.IsOpenRemind, "first_treatment_date": patientsNew.FirstTreatmentDate, "dialysis_age": patientsNew.DialysisAge, "expense_kind": patientsNew.ExpenseKind, "tell_phone": patientsNew.ExpenseKind, "contact_name": patientsNew.ContactName, "blood_patients": patientsNew.BloodPatients, "slow_patients": patientsNew.SlowPatients, "member_patients": patientsNew.MemberPatients, "ecommer_patients": patientsNew.EcommerPatients, "troble_shoot": patientsNew.TrobleShoot, "sch_remark": patientsNew.SchRemark, "treatment_plan": patientsNew.TreatmentPlan, "record_number": patientsNew.RecordNumber, "patient_start_time": patientsNew.PatientStartTime}).Error
875
 	return err
878
 	return err
876
 }
879
 }
877
 
880
 
2667
 	defer redis.Close()
2670
 	defer redis.Close()
2668
 	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2671
 	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2669
 	patient_info_str, _ := redis.Get(key).Result()
2672
 	patient_info_str, _ := redis.Get(key).Result()
2670
-
2673
+	redis.Set(key, "", time.Second)
2671
 	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2674
 	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2672
 		err = readDb.Model(&models.VMMonitorPatients{}).Where("user_org_id=? and status=1", orgID).Find(&patients).Error
2675
 		err = readDb.Model(&models.VMMonitorPatients{}).Where("user_org_id=? and status=1", orgID).Find(&patients).Error
2673
 		if err != nil {
2676
 		if err != nil {
2895
 	err := XTWriteDB().Model(models.XtSchedule{}).Where("user_org_id = ? and schedule_date > ?", org_id, shcheduledate).Updates(map[string]interface{}{"status": 0}).Error
2898
 	err := XTWriteDB().Model(models.XtSchedule{}).Where("user_org_id = ? and schedule_date > ?", org_id, shcheduledate).Updates(map[string]interface{}{"status": 0}).Error
2896
 	return err
2899
 	return err
2897
 }
2900
 }
2901
+
2902
+func GetContextScheduleListGroupPatientId(limit int64, page int64, startTime int64, endTime int64, org_id int64) (schedule []*models.ConScheduleList, total int64, err error) {
2903
+
2904
+	db := XTReadDB().Model(&schedule).Where("status=1")
2905
+
2906
+	offset := (page - 1) * limit
2907
+
2908
+	if startTime > 0 {
2909
+		db = db.Where("schedule_date >=?", startTime)
2910
+	}
2911
+	if endTime > 0 {
2912
+		db = db.Where("schedule_date<=?", endTime)
2913
+	}
2914
+
2915
+	if org_id > 0 {
2916
+		db = db.Where("user_org_id = ?", org_id)
2917
+	}
2918
+	err = db.Count(&total).Offset(offset).Limit(limit).Group("patient_id").Find(&schedule).Error
2919
+
2920
+	return schedule, total, err
2921
+}
2922
+
2923
+func GetContextScheduleListPatientId(startTime int64, endTime int64, org_id int64) (schedule []*models.ConScheduleList, total int64, err error) {
2924
+
2925
+	db := XTReadDB().Model(&schedule).Where("status=1")
2926
+
2927
+	if startTime > 0 {
2928
+		db = db.Where("schedule_date >=?", startTime)
2929
+	}
2930
+	if endTime > 0 {
2931
+		db = db.Where("schedule_date<=?", endTime)
2932
+	}
2933
+
2934
+	if org_id > 0 {
2935
+		db = db.Where("user_org_id = ?", org_id)
2936
+	}
2937
+	err = db.Find(&schedule).Error
2938
+
2939
+	return schedule, total, err
2940
+}

+ 24 - 1
service/self_drug_service.go View File

1119
 	return list, total, err
1119
 	return list, total, err
1120
 }
1120
 }
1121
 
1121
 
1122
+func GetDrugInventoryDetailMapList(keyword string, page int64, limit int64, orgid int64, storehouse_id int64, ids []string) (list []*models.VmDrugInventory, total int64, err error) {
1123
+	likeKey := "%" + keyword + "%"
1124
+	offset := (page - 1) * limit
1125
+	db := XTReadDB().Table("xt_drug_inventory as x").Where("x.status = 1")
1126
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
1127
+	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
1128
+	fmt.Println(table, tab)
1129
+	if len(keyword) > 0 {
1130
+		db = db.Where("x.warehousing_order = ? or r.user_name like ? or t.drug_name like ?", keyword, likeKey, likeKey)
1131
+	}
1132
+	if orgid > 0 {
1133
+		db = db.Where("x.user_org_id = ?", orgid)
1134
+	}
1135
+	if storehouse_id > 0 {
1136
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
1137
+	}
1138
+	if len(ids) > 0 {
1139
+		db = db.Where("x.id in(?)", ids)
1140
+	}
1141
+	err = db.Select("x.id,x.drug_name,x.specification_name,x.warehousing_unit,x.count,x.last_price,x.retail_price,x.manufacturer,x.dealer,x.remark,x.drug_id,x.warehousing_order,x.number,x.batch_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.drug_origin_place,x.expiry_date,x.product_date,x.min_count,x.storehouse_id,x.warehouse_info_id,t.dose,t.dose_unit,t.max_unit,x.min_unit,x.stock_max_number,x.stock_min_number,x.last_stock_max_number,x.last_stock_min_number,x.inventory_type,t.min_number,t.retail_price").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_base_drug as t on t.id =x.drug_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
1142
+	return list, total, err
1143
+}
1144
+
1122
 func GetDrugInventoryDetailListTwo(keyword string, page int64, limit int64, orgid int64, storehouse_id int64) (list []*models.XtDrugInventory, total int64, err error) {
1145
 func GetDrugInventoryDetailListTwo(keyword string, page int64, limit int64, orgid int64, storehouse_id int64) (list []*models.XtDrugInventory, total int64, err error) {
1123
 
1146
 
1124
 	db := XTReadDB().Model(&list).Where("status = 1")
1147
 	db := XTReadDB().Model(&list).Where("status = 1")
2715
 
2738
 
2716
 func GetDrugInventoryWarehouseInfoList(org_id int64, storehouse_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
2739
 func GetDrugInventoryWarehouseInfoList(org_id int64, storehouse_id int64) (info []*models.XtDrugWarehouseInfo, err error) {
2717
 
2740
 
2718
-	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id = ? and is_check = 1 and org_id = ?", storehouse_id, org_id).Preload("XtBaseDrug", "status= 1").Find(&info).Error
2741
+	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id = ? and is_check = 1 and org_id = ? and (stock_max_number >0 or stock_min_number >0)", storehouse_id, org_id).Preload("XtBaseDrug", "status= 1").Order("drug_id").Find(&info).Error
2719
 	return info, err
2742
 	return info, err
2720
 }
2743
 }

+ 36 - 1
service/stock_service.go View File

6113
 	return list, total, err
6113
 	return list, total, err
6114
 }
6114
 }
6115
 
6115
 
6116
+func GetInventoryDetailPrintMapList(keyword string, limit int64, page int64, orgid int64, storehouse_id int64, ids []string) (list []*models.VmStockInventory, total int64, err error) {
6117
+
6118
+	likeKey := "%" + keyword + "%"
6119
+	offset := (page - 1) * limit
6120
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.type = 10")
6121
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
6122
+	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
6123
+	fmt.Println(table, tab)
6124
+	if len(keyword) > 0 {
6125
+		db = db.Where("x.good_name like ?", likeKey)
6126
+	}
6127
+	if orgid > 0 {
6128
+		db = db.Where("x.user_org_id = ?", orgid)
6129
+	}
6130
+	if storehouse_id > 0 {
6131
+		db = db.Where("x.storehouse_id = ?", storehouse_id)
6132
+	}
6133
+	if len(ids) > 0 {
6134
+		db = db.Where("x.id in(?)", ids)
6135
+	}
6136
+	err = db.Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,x.expire_date,x.product_date,t.packing_unit,x.last_stock_count,x.type,x.inventory_type,x.stock_count,x.storehouse_id").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
6137
+	return list, total, err
6138
+}
6139
+
6116
 func GetInventoryPrintList(ids []string) (list []*models.XtStockInventory, err error) {
6140
 func GetInventoryPrintList(ids []string) (list []*models.XtStockInventory, err error) {
6117
 
6141
 
6118
 	err = XTReadDB().Where("id in(?) and status = 1", ids).Find(&list).Error
6142
 	err = XTReadDB().Where("id in(?) and status = 1", ids).Find(&list).Error
8212
 
8236
 
8213
 func GetInvetoryWarehouseInfoList(orgid int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
8237
 func GetInvetoryWarehouseInfoList(orgid int64, storehouse_id int64) (info []*models.WarehousingInfo, err error) {
8214
 
8238
 
8215
-	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id=? and is_check= 1 and org_id = ?", storehouse_id, orgid).Preload("GoodInfo", "status = 1").Find(&info).Error
8239
+	err = XTReadDB().Model(&info).Where("status = 1 and storehouse_id=? and is_check= 1 and org_id = ? and stock_count >0", storehouse_id, orgid).Preload("GoodInfo", "status = 1").Order("good_id").Find(&info).Error
8216
 	return info, err
8240
 	return info, err
8217
 }
8241
 }
8218
 
8242
 
8602
 	return err
8626
 	return err
8603
 
8627
 
8604
 }
8628
 }
8629
+
8630
+func FindFirstWarehousingInfoByStockThree(good_id int64, storehouse_id int64) (info models.WarehousingInfo, err error) {
8631
+	if storehouse_id == 0 {
8632
+		err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND status = 1 and stock_count > 0", good_id).Order("ctime").First(&info).Error
8633
+	}
8634
+	if storehouse_id > 0 {
8635
+		err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ?  AND status = 1 and stock_count > 0 and storehouse_id =? ", good_id, storehouse_id).Order("ctime").First(&info).Error
8636
+	}
8637
+
8638
+	return info, err
8639
+}

+ 1 - 1
service/user_service.go View File

189
 	offset := (page - 1) * limit
189
 	offset := (page - 1) * limit
190
 	table := XTReadDB().Table("sgj_users.sgj_user_admin_role AS a")
190
 	table := XTReadDB().Table("sgj_users.sgj_user_admin_role AS a")
191
 	fmt.Println("table", table)
191
 	fmt.Println("table", table)
192
-	err = XTReadDB().Table("xt_patient_dryweight as x").Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.status,x.user_org_id,x.adjusted_value,a.user_name").Where("x.user_org_id = ? AND x.patient_id = ? AND x.status = ? ", orgid, id, 1).Count(&total).Joins("LEFT  JOIN sgj_users.sgj_user_admin_role AS a ON a.admin_user_id = x.creator").Order("x.ctime desc").Offset(offset).Limit(limit).Group("id").Scan(&dry).Error
192
+	err = XTReadDB().Table("xt_patient_dryweight as x").Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.status,x.user_org_id,x.adjusted_value,a.user_name").Where("x.user_org_id = ? AND x.patient_id = ? AND x.status = ?", orgid, id, 1).Count(&total).Joins("LEFT  JOIN sgj_users.sgj_user_admin_role AS a ON a.admin_user_id = x.creator").Order("x.ctime desc").Offset(offset).Limit(limit).Group("id").Scan(&dry).Error
193
 	if err != nil {
193
 	if err != nil {
194
 		return
194
 		return
195
 	}
195
 	}