Explorar el Código

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

csx hace 3 años
padre
commit
ef739780f8

+ 1 - 1
conf/app.conf Ver fichero

@@ -124,7 +124,7 @@ writepatientname = sgj_cdm
124 124
 redishost = kuyicloud.redis.rds.aliyuncs.com
125 125
 redisport = 6379
126 126
 redispasswrod = 1Q2W3e4r!@#$
127
-redisdb = 8
127
+redisdb = 1
128 128
 
129 129
 
130 130
 

+ 140 - 97
controllers/dialysis_api_controller.go Ver fichero

@@ -1571,19 +1571,19 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1571 1571
 			dewater_amount = 0
1572 1572
 		}
1573 1573
 		// 计算透析处方的相关超滤量
1574
-		schedual, _ := service.MobileGetSchedualDetail(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1574
+		schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1575 1575
 		var lastDialysisPrescribe *models.DialysisPrescription
1576 1576
 		var dialysisSolution *models.DialysisSolution
1577 1577
 		var dialysisPrescribe *models.DialysisPrescription
1578 1578
 		var mode_id int64
1579 1579
 		if schedual != nil {
1580
-			dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
1580
+			dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
1581 1581
 			if dialysisPrescribe == nil {
1582 1582
 				dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
1583 1583
 			}
1584
-			lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
1584
+			lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
1585 1585
 			// 获取透析模版
1586
-			dialysisSolution, _ = service.MobileGetDialysisSolutionByModeId(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
1586
+			dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
1587 1587
 			mode_id = schedual.ModeId
1588 1588
 		} else {
1589 1589
 			//lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribe(adminUserInfo.Org.Id, id,schedual.ModeId)
@@ -1599,7 +1599,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1599 1599
 				mode_id = 0
1600 1600
 			}
1601 1601
 		}
1602
-
1602
+		fmt.Println("dialysisPrescribe------------------------------------", dialysisPrescribe)
1603
+		fmt.Println("dialysisSolution------------------------------------", dialysisSolution)
1603 1604
 		// 插入透析处方
1604 1605
 		if dialysisPrescribe == nil && dialysisSolution != nil {
1605 1606
 			var newprescribe models.DialysisPrescription
@@ -1705,6 +1706,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1705 1706
 				newprescribe.DewaterAmount = dewater_amount
1706 1707
 				newprescribe.TargetUltrafiltration = dewater_amount
1707 1708
 				newprescribe.Status = 1
1709
+
1708 1710
 				err := service.AddSigleRecord(&newprescribe)
1709 1711
 				if err != nil {
1710 1712
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
@@ -1808,6 +1810,10 @@ func (c *DialysisApiController) PostTreatmentSummary() {
1808 1810
 		err := service.AddSigleSummaryRecord(&treatmentSummary)
1809 1811
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
1810 1812
 		redis := service.RedisClient()
1813
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
1814
+		redis.Set(keyOne, "", time.Second)
1815
+		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1816
+		redis.Set(keyThree, "", time.Second)
1811 1817
 		defer redis.Close()
1812 1818
 		//清空key 值
1813 1819
 		redis.Set(key, "", time.Second)
@@ -1889,96 +1895,6 @@ func (c *DialysisApiController) GetDialysisWatch() {
1889 1895
 	adminUserInfo := c.GetAdminUserInfo()
1890 1896
 	if len(keywords) > 0 {
1891 1897
 		dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
1892
-
1893
-		//获取所有床位号
1894
-		numberList, _ := service.GetAllDeviceNumberByList(adminUserInfo.CurrentOrgId)
1895
-
1896
-		//获取所有分区
1897
-		//	zoneList, _ := service.GetAllZoneByList(adminUserInfo.CurrentOrgId)
1898
-		//获取透析处方
1899
-		prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
1900
-		//获取透前评估
1901
-		assessmentBefores, _ := service.GetAllAssessmentBeforesByListThree(adminUserInfo.CurrentOrgId, startTime)
1902
-		//获取上机
1903
-		dialysisOrders, _ := service.GetAllDialysisOrdersByListThree(adminUserInfo.CurrentOrgId, startTime)
1904
-		//获取透后
1905
-		AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListThree(adminUserInfo.CurrentOrgId, startTime)
1906
-
1907
-		//获取透后监测
1908
-		monitorlist, _ := service.GetAllMonitorListThree(adminUserInfo.CurrentOrgId, startTime)
1909
-
1910
-		//获取所有的患者
1911
-		patients, _ := service.GetAllPatientListByListThree(adminUserInfo.CurrentOrgId)
1912
-
1913
-		//获取所有透析模式
1914
-		treatments, _ := service.GetAllTreatModeByList(adminUserInfo.CurrentOrgId)
1915
-
1916
-		for key, scheduals := range dialysisSchedule {
1917
-			// 获取患者信息
1918
-			for _, patient := range patients {
1919
-				if scheduals.PatientId == patient.ID {
1920
-					dialysisSchedule[key].MonitorPatients = patient
1921
-					break
1922
-				}
1923
-			}
1924
-			// 床位信息
1925
-			for _, device := range numberList {
1926
-				if scheduals.BedId == device.ID {
1927
-					dialysisSchedule[key].DeviceNumber = device
1928
-					break
1929
-				}
1930
-			}
1931
-
1932
-			// 医嘱信息
1933
-			for _, prescription := range prescriptions {
1934
-				if scheduals.PatientId == prescription.PatientId {
1935
-					dialysisSchedule[key].Prescription = prescription
1936
-					break
1937
-				}
1938
-			}
1939
-
1940
-			// 透前评估
1941
-			for _, assessmentBefore := range assessmentBefores {
1942
-				if scheduals.PatientId == assessmentBefore.PatientId {
1943
-					dialysisSchedule[key].AssessmentBeforeDislysis = assessmentBefore
1944
-					break
1945
-				}
1946
-			}
1947
-
1948
-			// 透析上下机
1949
-			for _, dialysisOrder := range dialysisOrders {
1950
-				if scheduals.PatientId == dialysisOrder.PatientId {
1951
-					dialysisSchedule[key].DialysisOrder = dialysisOrder
1952
-					break
1953
-				}
1954
-			}
1955
-
1956
-			records := make([]*models.MonitoringRecord, 0)
1957
-			// 透析监测
1958
-			for _, it := range monitorlist {
1959
-				records := append(records, it)
1960
-				if scheduals.PatientId == it.PatientId {
1961
-					dialysisSchedule[key].MonitoringRecord = records
1962
-				}
1963
-			}
1964
-
1965
-			// 透后评估
1966
-			for _, afterDislysis := range AssessmentAfterDislysis {
1967
-				if scheduals.PatientId == afterDislysis.PatientId {
1968
-					dialysisSchedule[key].AssessmentAfterDislysis = afterDislysis
1969
-					break
1970
-				}
1971
-			}
1972
-
1973
-			//透析模式
1974
-			for _, treatment := range treatments {
1975
-				if scheduals.ModeId == treatment.ID {
1976
-					dialysisSchedule[key].TreatmentMode = treatment
1977
-					break
1978
-				}
1979
-			}
1980
-		}
1981
-		//获取所有床位号
1982 1898
 		if err == nil {
1983 1899
 			c.ServeSuccessJSON(map[string]interface{}{
1984 1900
 				"schedule": dialysisSchedule,
@@ -2001,6 +1917,127 @@ func (c *DialysisApiController) GetDialysisWatch() {
2001 1917
 	}
2002 1918
 }
2003 1919
 
1920
+//func (c *DialysisApiController) GetDialysisWatch() {
1921
+//	page, _ := c.GetInt64("page", 1)
1922
+//	limit, _ := c.GetInt64("limit", 10)
1923
+//	schedulType, _ := c.GetInt64("schedul_type", 0)
1924
+//	startTime, _ := c.GetInt64("schedul_time", 0)
1925
+//	partitionType, _ := c.GetInt64("partition_type", 0)
1926
+//	keywords := c.GetString("keywords")
1927
+//
1928
+//	adminUserInfo := c.GetAdminUserInfo()
1929
+//	if len(keywords) > 0 {
1930
+//		dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
1931
+//
1932
+//		//获取所有床位号
1933
+//		numberList, _ := service.GetAllDeviceNumberByListSix(adminUserInfo.CurrentOrgId)
1934
+//
1935
+//		//获取透析处方
1936
+//		prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
1937
+//		//获取透前评估
1938
+//		assessmentBefores, _ := service.GetAllAssessmentBeforesByListThree(adminUserInfo.CurrentOrgId, startTime)
1939
+//		//获取上机
1940
+//		dialysisOrders, _ := service.GetAllDialysisOrdersByListThree(adminUserInfo.CurrentOrgId, startTime)
1941
+//		//获取透后
1942
+//		AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListThree(adminUserInfo.CurrentOrgId, startTime)
1943
+//
1944
+//		//获取透后监测
1945
+//		monitorlist, _ := service.GetAllMonitorListThree(adminUserInfo.CurrentOrgId, startTime)
1946
+//
1947
+//		//获取所有的患者
1948
+//		patients, _ := service.GetAllPatientListByListSix(adminUserInfo.CurrentOrgId,keywords)
1949
+//
1950
+//		//获取所有透析模式
1951
+//		treatments, _ := service.GetAllTreatModeByList(adminUserInfo.CurrentOrgId)
1952
+//
1953
+//		for key, scheduals := range dialysisSchedule {
1954
+//			// 获取患者信息
1955
+//			for _, patient := range patients {
1956
+//				if scheduals.PatientId == patient.ID {
1957
+//					dialysisSchedule[key].MonitorPatients = patient
1958
+//					break
1959
+//				}
1960
+//			}
1961
+//			// 床位信息
1962
+//			for _, device := range numberList {
1963
+//				if scheduals.BedId == device.ID {
1964
+//					dialysisSchedule[key].DeviceNumber = device
1965
+//					break
1966
+//				}
1967
+//			}
1968
+//
1969
+//			// 医嘱信息
1970
+//			for _, prescription := range prescriptions {
1971
+//				if scheduals.PatientId == prescription.PatientId {
1972
+//					dialysisSchedule[key].Prescription = prescription
1973
+//					break
1974
+//				}
1975
+//			}
1976
+//
1977
+//			// 透前评估
1978
+//			for _, assessmentBefore := range assessmentBefores {
1979
+//				if scheduals.PatientId == assessmentBefore.PatientId {
1980
+//					dialysisSchedule[key].AssessmentBeforeDislysis = assessmentBefore
1981
+//					break
1982
+//				}
1983
+//			}
1984
+//
1985
+//			// 透析上下机
1986
+//			for _, dialysisOrder := range dialysisOrders {
1987
+//				if scheduals.PatientId == dialysisOrder.PatientId {
1988
+//					dialysisSchedule[key].DialysisOrder = dialysisOrder
1989
+//					break
1990
+//				}
1991
+//			}
1992
+//
1993
+//			records := make([]*models.MonitoringRecord, 0)
1994
+//			// 透析监测
1995
+//			for _, it := range monitorlist {
1996
+//				records := append(records, it)
1997
+//				if scheduals.PatientId == it.PatientId {
1998
+//					dialysisSchedule[key].MonitoringRecord = records
1999
+//				}
2000
+//			}
2001
+//
2002
+//			// 透后评估
2003
+//			for _, afterDislysis := range AssessmentAfterDislysis {
2004
+//				if scheduals.PatientId == afterDislysis.PatientId {
2005
+//					dialysisSchedule[key].AssessmentAfterDislysis = afterDislysis
2006
+//					break
2007
+//				}
2008
+//			}
2009
+//
2010
+//			//透析模式
2011
+//			for _, treatment := range treatments {
2012
+//				if scheduals.ModeId == treatment.ID {
2013
+//					dialysisSchedule[key].TreatmentMode = treatment
2014
+//					break
2015
+//				}
2016
+//			}
2017
+//		}
2018
+//		//获取所有床位号
2019
+//		if err == nil {
2020
+//			c.ServeSuccessJSON(map[string]interface{}{
2021
+//				"schedule": dialysisSchedule,
2022
+//				"total":    total,
2023
+//			})
2024
+//		} else {
2025
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2026
+//		}
2027
+//
2028
+//	} else {
2029
+//		dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit)
2030
+//		if err == nil {
2031
+//			c.ServeSuccessJSON(map[string]interface{}{
2032
+//				"schedule": dialysisSchedule,
2033
+//				"total":    total,
2034
+//			})
2035
+//		} else {
2036
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2037
+//		}
2038
+//	}
2039
+//}
2040
+
2004 2041
 func (c *DialysisApiController) GetSchedualPatientsInfo() {
2005 2042
 	patientId, _ := c.GetInt64("id", 0)
2006 2043
 	record_date, _ := c.GetInt64("record_date", 0)
@@ -2769,8 +2806,14 @@ func (c *DialysisApiController) GetDialysisOrder() {
2769 2806
 
2770 2807
 	check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2771 2808
 
2772
-	dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2773
-	patientInfo.TotalDialysis = dialysis_count
2809
+	if adminUserInfo.CurrentOrgId != 10101 {
2810
+		dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2811
+		patientInfo.TotalDialysis = dialysis_count
2812
+	}
2813
+	if adminUserInfo.CurrentOrgId == 10101 {
2814
+		dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
2815
+		patientInfo.TotalDialysis = dialysis_count
2816
+	}
2774 2817
 
2775 2818
 	//相关操作对应的操作人
2776 2819
 	//operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)

+ 15 - 2
controllers/dialysis_record_api_controller.go Ver fichero

@@ -88,7 +88,8 @@ func (this *DialysisRecordAPIController) GetSchedules() {
88 88
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
89 89
 		} else {
90 90
 			if len(scheduals) > 0 {
91
-				patients, _ := service.GetAllPcPatientListByList(orgID)
91
+
92
+				patients, _ := service.GetAllPcPatientListByListSeven(orgID)
92 93
 
93 94
 				dialysisOrders, _ := service.GetAllPcDialysisOrdersByList(orgID, date.Unix())
94 95
 
@@ -888,13 +889,17 @@ func (this *DialysisRecordAPIController) StartDialysis() {
888 889
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
889 890
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
890 891
 	redis := service.RedisClient()
891
-	defer redis.Close()
892 892
 	//清空key 值
893 893
 	redis.Set(key, "", time.Second)
894 894
 
895 895
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_orders_list_all"
896 896
 	redis.Set(keyOne, "", time.Second)
897 897
 
898
+	keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
899
+	//清空key 值
900
+	redis.Set(keyTwo, "", time.Second)
901
+	defer redis.Close()
902
+
898 903
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
899 904
 
900 905
 	if createErr != nil {
@@ -982,6 +987,14 @@ func (this *DialysisRecordAPIController) StartDialysis() {
982 987
 		// 如果当天有插入数据,则不再往透析纪录里插入数据
983 988
 		if newdialysisRecord.ID > 0 {
984 989
 			err := service.CreateMonitor(&record)
990
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
991
+
992
+			redis := service.RedisClient()
993
+			//清空key 值
994
+			redis.Set(key, "", time.Second)
995
+			keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_record_list_all"
996
+			redis.Set(keyOne, "", time.Second)
997
+			defer redis.Close()
985 998
 
986 999
 			if err != nil {
987 1000
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)

+ 115 - 138
controllers/doctors_api_controller.go Ver fichero

@@ -53,11 +53,12 @@ func DoctorApiRegistRouters() {
53 53
 	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
54 54
 	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
55 55
 	beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
56
-	beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Get:HospitalSummary")
56
+	beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Post:HospitalSummary")
57 57
 	beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
58 58
 	beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
59
-	beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Get:UpdateHospitalSummary")
59
+	beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
60 60
 	beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
61
+	beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
61 62
 }
62 63
 
63 64
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -1026,7 +1027,7 @@ func (this *DoctorsApiController) GetTemplateSummaryList() {
1026 1027
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1027 1028
 	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1028 1029
 	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
1029
-	fmt.Println("hhhhhhhhhhhhhh777777", endTime.Unix())
1030
+
1030 1031
 	list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
1031 1032
 	if err == nil {
1032 1033
 		this.ServeSuccessJSON(map[string]interface{}{
@@ -1081,90 +1082,50 @@ func (this *DoctorsApiController) UpdateTempalteSummary() {
1081 1082
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1082 1083
 		return
1083 1084
 	}
1084
-	id := int64(dataBody["id"].(float64))
1085
-	title := dataBody["title"].(string)
1086
-	dryWeight := dataBody["dry_weight"].(string)
1085
+
1086
+	id, _ := this.GetInt64("id")
1087
+	title := this.GetString("title")
1088
+
1089
+	dryWeight := this.GetString("dry_weight")
1087 1090
 	dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
1088
-	dialysis_count := int64(dataBody["dialysis_count"].(float64))
1089
-	hd_count := int64(dataBody["hd_count"].(float64))
1090
-	hdf_count := int64(dataBody["hdf_count"].(float64))
1091
-	hp_count := int64(dataBody["hp_count"].(float64))
1092
-	other_count := int64(dataBody["other_count"].(float64))
1093
-	dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
1094
-	perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
1095
-	anticoagulant := int64(dataBody["anticoagulant"].(float64))
1096
-	kaliumstr := dataBody["kalium"].(string)
1091
+	dialysis_count, _ := this.GetInt64("dialysis_count")
1092
+	hd_count, _ := this.GetInt64("hd_count")
1093
+	hdf_count, _ := this.GetInt64("hdf_count")
1094
+	hp_count, _ := this.GetInt64("hp_count")
1095
+	other_count, _ := this.GetInt64("other_count")
1096
+	dialzer_apparatus := this.GetString("dialzer_apparatus")
1097
+	perfusion_apparatus := this.GetString("perfusion_apparatus")
1098
+	anticoagulant, _ := this.GetInt64("anticoagulant")
1099
+	kaliumstr := this.GetString("kalium")
1097 1100
 	kalium, _ := strconv.ParseFloat(kaliumstr, 64)
1098
-	autunitestr := dataBody["autunite"].(string)
1101
+
1102
+	autunitestr := this.GetString("autunite")
1099 1103
 	autunite, _ := strconv.ParseFloat(autunitestr, 64)
1100
-	natriumstr := dataBody["natrium"].(string)
1104
+	natriumstr := this.GetString("natrium")
1101 1105
 	natrium, _ := strconv.ParseFloat(natriumstr, 64)
1102
-	hour := int64(dataBody["hour"].(float64))
1103
-	minute := int64(dataBody["minute"].(float64))
1104
-	beforWeight := dataBody["befor_weight"].(string)
1106
+	hour, _ := this.GetInt64("hour")
1107
+	minute, _ := this.GetInt64("minute")
1108
+	beforWeight := this.GetString("befor_weight")
1105 1109
 	befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
1106
-	afterWeight := dataBody["after_weight"].(string)
1110
+	afterWeight := this.GetString("after_weight")
1107 1111
 	after_weight, _ := strconv.ParseFloat(afterWeight, 64)
1108
-	befor_pressure := dataBody["befor_pressure"].(string)
1109
-	template_summary_content := dataBody["template_summary_content"].(string)
1110
-	template_plan_content := dataBody["template_plan_content"].(string)
1111
-	admin_user_id := int64(dataBody["admin_user_id"].(float64))
1112
-	record_time := dataBody["record_time"].(string)
1112
+	befor_pressure := this.GetString("befor_pressure")
1113
+	template_summary_content := this.GetString("template_summary_content")
1114
+	template_plan_content := this.GetString("template_plan_content")
1115
+	admin_user_id, _ := this.GetInt64("admin_user_id")
1116
+	record_time := this.GetString("record_time")
1113 1117
 	timeLayout := "2006-01-02"
1114 1118
 	loc, _ := time.LoadLocation("Local")
1115 1119
 	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
1116
-	after_pressure := dataBody["after_pressure"].(string)
1117
-	template_summary_id := int64(dataBody["template_summary_id"].(float64))
1118
-	template_plan_id := int64(dataBody["template_plan_id"].(float64))
1119
-	patient_id := int64(dataBody["patient_id"].(float64))
1120
+	after_pressure := this.GetString("after_pressure")
1121
+	template_summary_id, _ := this.GetInt64("template_summary_id")
1122
+	template_plan_id, _ := this.GetInt64("template_plan_id")
1123
+	template_inspection_id, _ := this.GetInt64("template_inspection_id")
1124
+	patient_id, _ := this.GetInt64("patient_id")
1125
+	fmt.Println("patient_id", patient_id)
1120 1126
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1121
-	inspect_date := dataBody["inspect_date"].(string)
1122
-	project_id := dataBody["project_id"].(string)
1123
-	template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
1124
-
1125
-	//id, _ := this.GetInt64("id")
1126
-	//title := this.GetString("title")
1127
-	//
1128
-	//dryWeight := this.GetString("dry_weight")
1129
-	//dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
1130
-	//dialysis_count, _ := this.GetInt64("dialysis_count")
1131
-	//hd_count, _ := this.GetInt64("hd_count")
1132
-	//hdf_count, _ := this.GetInt64("hdf_count")
1133
-	//hp_count, _ := this.GetInt64("hp_count")
1134
-	//other_count, _ := this.GetInt64("other_count")
1135
-	//dialzer_apparatus := this.GetString("dialzer_apparatus")
1136
-	//perfusion_apparatus := this.GetString("perfusion_apparatus")
1137
-	//anticoagulant, _ := this.GetInt64("anticoagulant")
1138
-	//kaliumstr := this.GetString("kalium")
1139
-	//kalium, _ := strconv.ParseFloat(kaliumstr, 64)
1140
-	//
1141
-	//autunitestr := this.GetString("autunite")
1142
-	//autunite, _ := strconv.ParseFloat(autunitestr, 64)
1143
-	//natriumstr := this.GetString("natrium")
1144
-	//natrium, _ := strconv.ParseFloat(natriumstr, 64)
1145
-	//hour, _ := this.GetInt64("hour")
1146
-	//minute, _ := this.GetInt64("minute")
1147
-	//beforWeight := this.GetString("befor_weight")
1148
-	//befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
1149
-	//afterWeight := this.GetString("after_weight")
1150
-	//after_weight, _ := strconv.ParseFloat(afterWeight, 64)
1151
-	//befor_pressure := this.GetString("befor_pressure")
1152
-	//template_summary_content := this.GetString("template_summary_content")
1153
-	//template_plan_content := this.GetString("template_plan_content")
1154
-	//admin_user_id, _ := this.GetInt64("admin_user_id")
1155
-	//record_time := this.GetString("record_time")
1156
-	//timeLayout := "2006-01-02"
1157
-	//loc, _ := time.LoadLocation("Local")
1158
-	//recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
1159
-	//after_pressure := this.GetString("after_pressure")
1160
-	//template_summary_id, _ := this.GetInt64("template_summary_id")
1161
-	//template_plan_id, _ := this.GetInt64("template_plan_id")
1162
-	//template_inspection_id, _ := this.GetInt64("template_inspection_id")
1163
-	//patient_id, _ := this.GetInt64("patient_id")
1164
-	//fmt.Println("patient_id", patient_id)
1165
-	//orgId := this.GetAdminUserInfo().CurrentOrgId
1166
-	//inspect_date := this.GetString("inspect_date")
1167
-	//project_id := this.GetString("project_id")
1127
+	inspect_date := this.GetString("inspect_date")
1128
+	project_id := this.GetString("project_id")
1168 1129
 	summary := models.XtTemplateSummary{
1169 1130
 		ID:                     id,
1170 1131
 		StartYear:              0,
@@ -1230,41 +1191,42 @@ func (this *DoctorsApiController) HospitalSummary() {
1230 1191
 
1231 1192
 	timeLayout := "2006-01-02"
1232 1193
 	loc, _ := time.LoadLocation("Local")
1233
-	admission_time := this.GetString("admission_time")
1194
+
1195
+	dataBody := make(map[string]interface{}, 0)
1196
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1197
+	fmt.Print("err", err)
1198
+	admission_time := dataBody["admission_time"].(string)
1234 1199
 	admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
1235 1200
 	admissiontime := admissionTimes.Unix()
1201
+	admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
1202
+	admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
1203
+	connecticut := dataBody["connecticut"].(string)
1204
+	dean := int64(dataBody["dean"].(float64))
1205
+	discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
1206
+	discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
1207
+	diagnosis_admission := dataBody["diagnosis_admission"].(string)
1208
+	diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
1209
+	discharge_advice_id := dataBody["discharge_advice_id"].(string)
1210
+	discharge_advice := dataBody["discharge_advice"].(string)
1211
+	discharge_time := dataBody["discharge_time"].(string)
1236 1212
 
1237
-	admitting_diagnosis := this.GetString("admitting_diagnosis")
1238
-	admitting_diagnosis_id := this.GetString("admitting_diagnosis_id")
1239
-
1240
-	connecticut := this.GetString("connecticut")
1241
-	dean, _ := this.GetInt64("dean")
1242
-	discharge_diagnosis := this.GetString("discharge_diagnosis")
1243
-
1244
-	discharge_diagnosis_id := this.GetString("discharge_diagnosis_id")
1245
-	diagnosis_admission := this.GetString("diagnosis_admission")
1246
-	diagnosis_admission_id := this.GetString("diagnosis_admission_id")
1247
-	discharge_advice_id := this.GetString("discharge_advice_id")
1248
-	discharge_advice := this.GetString("discharge_advice")
1249
-
1250
-	discharge_time := this.GetString("discharge_time")
1251 1213
 	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
1252 1214
 	dischargetime := dischargeTimes.Unix()
1253
-	doctor, _ := this.GetInt64("doctor")
1254
-	illness_discharge_id := this.GetString("illness_discharge_id")
1255
-	illness_discharge := this.GetString("illness_discharge")
1256
-	nuclear_magnetic_resonance := this.GetString("nuclear_magnetic_resonance")
1257
-	pathology := this.GetString("pathology")
1258
-	record_date := this.GetString("record_date")
1215
+	doctor := int64(dataBody["doctor"].(float64))
1216
+	illness_discharge_id := dataBody["illness_discharge_id"].(string)
1217
+	illness_discharge := dataBody["illness_discharge"].(string)
1218
+	nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
1219
+	pathology := dataBody["pathology"].(string)
1220
+	record_date := dataBody["record_date"].(string)
1259 1221
 	recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1260 1222
 	recordtime := recordDates.Unix()
1261
-	sick_personnel := this.GetString("sick_personnel")
1262
-	title := this.GetString("title")
1263
-	treatment_id := this.GetString("treatment_id")
1264
-	treatment := this.GetString("treatment")
1265
-	ultrasound := this.GetString("ultrasound")
1266
-	xray := this.GetString("xray")
1267
-	patient_id, _ := this.GetInt64("patient_id")
1223
+	sick_personnel := dataBody["sick_personnel"].(string)
1224
+	title := dataBody["title"].(string)
1225
+	treatment_id := dataBody["treatment_id"].(string)
1226
+	treatment := dataBody["treatment"].(string)
1227
+	ultrasound := dataBody["ultrasound"].(string)
1228
+	xray := dataBody["xray"].(string)
1229
+	patient_id := int64(dataBody["patient_id"].(float64))
1268 1230
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1269 1231
 	summary := models.XtHospitalSummary{
1270 1232
 		PatientId:                patient_id,
@@ -1312,8 +1274,10 @@ func (this *DoctorsApiController) GetHospitalSummaryList() {
1312 1274
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1313 1275
 	patient_id, _ := this.GetInt64("patient_id")
1314 1276
 	start_time := this.GetString("start_time")
1277
+	fmt.Println("start_tim232232323232323232323232332", start_time)
1315 1278
 	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1316 1279
 	startime := dischargeTimes.Unix()
1280
+	fmt.Println("startime1111111111111111111111", startime)
1317 1281
 	end_time := this.GetString("end_time")
1318 1282
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1319 1283
 	endtime := endTimes.Unix()
@@ -1342,43 +1306,42 @@ func (this *DoctorsApiController) UpdateHospitalSummary() {
1342 1306
 
1343 1307
 	timeLayout := "2006-01-02"
1344 1308
 	loc, _ := time.LoadLocation("Local")
1345
-	admission_time := this.GetString("admission_time")
1309
+	dataBody := make(map[string]interface{}, 0)
1310
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1311
+	fmt.Print("err", err)
1312
+	admission_time := dataBody["admission_time"].(string)
1346 1313
 	admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
1347 1314
 	admissiontime := admissionTimes.Unix()
1315
+	admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
1316
+	admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
1317
+	connecticut := dataBody["connecticut"].(string)
1318
+	dean := int64(dataBody["dean"].(float64))
1319
+	discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
1320
+	discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
1321
+	diagnosis_admission := dataBody["diagnosis_admission"].(string)
1322
+	diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
1323
+	discharge_advice_id := dataBody["discharge_advice_id"].(string)
1324
+	discharge_advice := dataBody["discharge_advice"].(string)
1325
+	discharge_time := dataBody["discharge_time"].(string)
1348 1326
 
1349
-	id, _ := this.GetInt64("id")
1350
-	admitting_diagnosis := this.GetString("admitting_diagnosis")
1351
-	admitting_diagnosis_id := this.GetString("admitting_diagnosis_id")
1352
-
1353
-	connecticut := this.GetString("connecticut")
1354
-	dean, _ := this.GetInt64("dean")
1355
-	discharge_diagnosis := this.GetString("discharge_diagnosis")
1356
-
1357
-	discharge_diagnosis_id := this.GetString("discharge_diagnosis_id")
1358
-	diagnosis_admission := this.GetString("diagnosis_admission")
1359
-	diagnosis_admission_id := this.GetString("diagnosis_admission_id")
1360
-	discharge_advice_id := this.GetString("discharge_advice_id")
1361
-	discharge_advice := this.GetString("discharge_advice")
1362
-
1363
-	discharge_time := this.GetString("discharge_time")
1364 1327
 	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
1365 1328
 	dischargetime := dischargeTimes.Unix()
1366
-	doctor, _ := this.GetInt64("doctor")
1367
-	illness_discharge_id := this.GetString("illness_discharge_id")
1368
-	illness_discharge := this.GetString("illness_discharge")
1369
-	nuclear_magnetic_resonance := this.GetString("nuclear_magnetic_resonance")
1370
-	pathology := this.GetString("pathology")
1371
-	record_date := this.GetString("record_date")
1329
+	doctor := int64(dataBody["doctor"].(float64))
1330
+	illness_discharge_id := dataBody["illness_discharge_id"].(string)
1331
+	illness_discharge := dataBody["illness_discharge"].(string)
1332
+	nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
1333
+	pathology := dataBody["pathology"].(string)
1334
+	record_date := dataBody["record_date"].(string)
1372 1335
 	recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1373 1336
 	recordtime := recordDates.Unix()
1374
-	sick_personnel := this.GetString("sick_personnel")
1375
-	title := this.GetString("title")
1376
-	treatment_id := this.GetString("treatment_id")
1377
-	treatment := this.GetString("treatment")
1378
-	ultrasound := this.GetString("ultrasound")
1379
-	xray := this.GetString("xray")
1380
-	patient_id, _ := this.GetInt64("patient_id")
1381
-
1337
+	sick_personnel := dataBody["sick_personnel"].(string)
1338
+	title := dataBody["title"].(string)
1339
+	treatment_id := dataBody["treatment_id"].(string)
1340
+	treatment := dataBody["treatment"].(string)
1341
+	ultrasound := dataBody["ultrasound"].(string)
1342
+	xray := dataBody["xray"].(string)
1343
+	patient_id := int64(dataBody["patient_id"].(float64))
1344
+	id := int64(dataBody["id"].(float64))
1382 1345
 	summary := models.XtHospitalSummary{
1383 1346
 		PatientId:                patient_id,
1384 1347
 		AdmissionTime:            admissiontime,
@@ -1408,7 +1371,7 @@ func (this *DoctorsApiController) UpdateHospitalSummary() {
1408 1371
 		DeanId:                   dean,
1409 1372
 		DischargeDiagnosisId:     discharge_diagnosis_id,
1410 1373
 	}
1411
-	err := service.UpdateHospital(id, summary)
1374
+	err = service.UpdateHospital(id, summary)
1412 1375
 	if err == nil {
1413 1376
 		this.ServeSuccessJSON(map[string]interface{}{
1414 1377
 			"detail": summary,
@@ -1419,11 +1382,25 @@ func (this *DoctorsApiController) UpdateHospitalSummary() {
1419 1382
 
1420 1383
 func (this *DoctorsApiController) DeleteHospitalSummary() {
1421 1384
 
1422
-	id, _ := this.GetInt64("id")
1423
-	err := service.DeleteHospitalSummary(id)
1385
+	schIDStr := this.GetString("ids")
1386
+	idStrs := strings.Split(schIDStr, ",")
1387
+	err := service.DeleteHospitalSummary(idStrs)
1424 1388
 	fmt.Println(err)
1425 1389
 	returnData := make(map[string]interface{}, 0)
1426 1390
 	returnData["msg"] = "ok"
1427 1391
 	this.ServeSuccessJSON(returnData)
1428 1392
 	return
1429 1393
 }
1394
+
1395
+func (this *DoctorsApiController) GetPatientInfo() {
1396
+
1397
+	patient_id, _ := this.GetInt64("patient_id")
1398
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1399
+	detail, err := service.GetPatientDetail(patient_id, orgId)
1400
+	if err == nil {
1401
+		this.ServeSuccessJSON(map[string]interface{}{
1402
+			"patient": detail,
1403
+		})
1404
+		return
1405
+	}
1406
+}

+ 4 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go Ver fichero

@@ -98,8 +98,8 @@ func (this *DialysisAPIController) Scheduals() {
98 98
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
99 99
 		} else {
100 100
 			if len(scheduals) > 0 {
101
-				patients, _ := service.GetAllPatientListByList(orgID)
102
-				devices, _ := service.GetAllDevicetByList(orgID)
101
+				patients, _ := service.GetAllPatientListSix(orgID)
102
+				devices, _ := service.GetAllDevicetByListSix(orgID)
103 103
 				advices, _ := service.GetAllAdvicestByList(orgID, date.Unix())
104 104
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
105 105
 				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
@@ -624,10 +624,6 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
624 624
 		return
625 625
 	}
626 626
 
627
-	//now := time.Now()
628
-	//year, month, day := now.Date()
629
-	//today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
630
-	//todayTimeStamp := today_time.Unix()
631 627
 	summary := models.TreatmentSummary{
632 628
 		UserOrgId:       adminUserInfo.Org.Id,
633 629
 		PatientId:       id,
@@ -655,6 +651,7 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
655 651
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
656 652
 		redis.Set(keyOne, "", time.Second)
657 653
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
654
+		fmt.Println("keyThree2332323232323", keyThree)
658 655
 		redis.Set(keyThree, "", time.Second)
659 656
 		defer redis.Close()
660 657
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -1570,6 +1567,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1570 1567
 		}
1571 1568
 
1572 1569
 		prescription.ID = dialysisPrescription.ID
1570
+
1573 1571
 		err := service.UpDateDialysisPrescription(&prescription)
1574 1572
 		//获取key,清空redis
1575 1573
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"

+ 7 - 2
controllers/mobile_api_controllers/doctor_advice_api_controller.go Ver fichero

@@ -5,6 +5,8 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
+	"strconv"
9
+	"time"
8 10
 )
9 11
 
10 12
 type DoctorAdviceAPIController struct {
@@ -15,6 +17,7 @@ type DoctorAdviceAPIController struct {
15 17
 // @param date:string (yyyy-mm-dd)
16 18
 // @param advice_type:int 1长期医嘱 3临时医嘱 其他:全部
17 19
 func (this *DoctorAdviceAPIController) ScheduleAdvices() {
20
+
18 21
 	schedualDate := this.GetString("date")
19 22
 	adviceType, _ := this.GetInt("advice_type")
20 23
 	patientType, _ := this.GetInt("patient_type")
@@ -36,9 +39,12 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
36 39
 
37 40
 	adminInfo := this.GetMobileAdminUserInfo()
38 41
 	orgID := adminInfo.Org.Id
42
+	redis := service.RedisClient()
43
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
44
+	redis.Set(key, "", time.Second)
39 45
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesTwo(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
40 46
 	//获取所有的患者
41
-	blood_patients, _ := service.GetAllPatientListByListTwo(orgID)
47
+	blood_patients, _ := service.GetAllPatientListByListSeven(orgID)
42 48
 	//获取透析处方
43 49
 	blood_prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
44 50
 	//获取上机
@@ -95,7 +101,6 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
95 101
 			}
96 102
 		}
97 103
 
98
-
99 104
 		//获取所有的患者
100 105
 		patients, _ := service.GetAllPatientListByListTwo(orgID)
101 106
 

+ 221 - 10
controllers/mobile_api_controllers/patient_api_controller.go Ver fichero

@@ -1490,7 +1490,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1490 1490
 		dewater_amount = 0
1491 1491
 	}
1492 1492
 	// 计算透析处方的相关超滤量
1493
-	schedual, _ := service.MobileGetSchedualDetail(adminUserInfo.Org.Id, patient.ID, theAssessmentDateTime)
1493
+	schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.Org.Id, patient.ID, theAssessmentDateTime)
1494 1494
 	var lastDialysisPrescribe *models.DialysisPrescription
1495 1495
 	var dialysisSolution *models.DialysisSolution
1496 1496
 	var dialysisPrescribe *models.DialysisPrescription
@@ -1499,11 +1499,11 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1499 1499
 	var mode_id int64
1500 1500
 
1501 1501
 	dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
1502
-	lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.Org.Id, id, schedual.ModeId)
1502
+	lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
1503 1503
 	if schedual != nil {
1504 1504
 		// 获取透析模版
1505
-		dialysisSolution, _ = service.MobileGetDialysisSolutionByModeId(adminUserInfo.Org.Id, id, schedual.ModeId)
1506
-		system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeId(adminUserInfo.Org.Id, schedual.ModeId)
1505
+		dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
1506
+		system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, schedual.ModeId)
1507 1507
 
1508 1508
 		mode_id = schedual.ModeId
1509 1509
 	} else {
@@ -1571,11 +1571,62 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1571 1571
 		newprescribe.Status = 1
1572 1572
 		newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
1573 1573
 		newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
1574
+		_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1575
+		newprescribe.ID = dialysisPrescription.ID
1574 1576
 
1575
-		err := service.AddSigleRecord(&newprescribe)
1576
-		if err != nil {
1577
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1577
+		if dialysisPrescription.ID == 0 {
1578
+			fmt.Println("处方11111111111")
1579
+			err := service.AddSigleRecord(&newprescribe)
1580
+			//获取key,清空redis
1581
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1582
+			redis := service.RedisClient()
1583
+
1584
+			//清空key 值
1585
+			redis.Set(key, "", time.Second)
1586
+
1587
+			keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1588
+			//清空key 值
1589
+			redis.Set(keyOne, "", time.Second)
1590
+
1591
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1592
+			//清空key 值
1593
+			redis.Set(keyTwo, "", time.Second)
1594
+
1595
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1596
+			redis.Set(keySix, "", time.Second)
1597
+
1598
+			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1599
+			redis.Set(keySeven, "", time.Second)
1600
+			if err != nil {
1601
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1602
+			}
1603
+		} else {
1604
+			err := service.UpDateDialysisPrescription(&newprescribe)
1605
+			//获取key,清空redis
1606
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1607
+			redis := service.RedisClient()
1608
+
1609
+			//清空key 值
1610
+			redis.Set(key, "", time.Second)
1611
+
1612
+			keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1613
+			//清空key 值
1614
+			redis.Set(keyOne, "", time.Second)
1615
+
1616
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1617
+			//清空key 值
1618
+			redis.Set(keyTwo, "", time.Second)
1619
+
1620
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1621
+			redis.Set(keySix, "", time.Second)
1622
+
1623
+			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1624
+			redis.Set(keySeven, "", time.Second)
1625
+			if err != nil {
1626
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1627
+			}
1578 1628
 		}
1629
+
1579 1630
 	}
1580 1631
 
1581 1632
 	if dialysisPrescribe == nil && dialysisSolution == nil {
@@ -1628,7 +1679,60 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1628 1679
 			newprescribe.Status = 1
1629 1680
 			newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
1630 1681
 			newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
1631
-			err := service.AddSigleRecord(&newprescribe)
1682
+			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1683
+			newprescribe.ID = dialysisPrescription.ID
1684
+			if dialysisPrescription.ID == 0 {
1685
+				err := service.AddSigleRecord(&newprescribe)
1686
+				//获取key,清空redis
1687
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1688
+				redis := service.RedisClient()
1689
+
1690
+				//清空key 值
1691
+				redis.Set(key, "", time.Second)
1692
+
1693
+				keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1694
+				//清空key 值
1695
+				redis.Set(keyOne, "", time.Second)
1696
+
1697
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1698
+				//清空key 值
1699
+				redis.Set(keyTwo, "", time.Second)
1700
+
1701
+				keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1702
+				redis.Set(keySix, "", time.Second)
1703
+
1704
+				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1705
+				redis.Set(keySeven, "", time.Second)
1706
+				fmt.Println("处方2222222222")
1707
+				if err != nil {
1708
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1709
+				}
1710
+			} else {
1711
+				err := service.UpDateDialysisPrescription(&newprescribe)
1712
+				//获取key,清空redis
1713
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1714
+				redis := service.RedisClient()
1715
+
1716
+				//清空key 值
1717
+				redis.Set(key, "", time.Second)
1718
+
1719
+				keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1720
+				//清空key 值
1721
+				redis.Set(keyOne, "", time.Second)
1722
+
1723
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1724
+				//清空key 值
1725
+				redis.Set(keyTwo, "", time.Second)
1726
+
1727
+				keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1728
+				redis.Set(keySix, "", time.Second)
1729
+
1730
+				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1731
+				redis.Set(keySeven, "", time.Second)
1732
+				if err != nil {
1733
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1734
+				}
1735
+			}
1632 1736
 			if err != nil {
1633 1737
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1634 1738
 			}
@@ -1682,7 +1786,61 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1682 1786
 			newprescribe.Status = 1
1683 1787
 			newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
1684 1788
 			newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
1685
-			err := service.AddSigleRecord(&newprescribe)
1789
+			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1790
+			newprescribe.ID = dialysisPrescription.ID
1791
+			if dialysisPrescription.ID == 0 {
1792
+				err := service.AddSigleRecord(&newprescribe)
1793
+
1794
+				fmt.Println("处方2222222222")
1795
+				//获取key,清空redis
1796
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1797
+				redis := service.RedisClient()
1798
+
1799
+				//清空key 值
1800
+				redis.Set(key, "", time.Second)
1801
+
1802
+				keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1803
+				//清空key 值
1804
+				redis.Set(keyOne, "", time.Second)
1805
+
1806
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1807
+				//清空key 值
1808
+				redis.Set(keyTwo, "", time.Second)
1809
+
1810
+				keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1811
+				redis.Set(keySix, "", time.Second)
1812
+
1813
+				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1814
+				redis.Set(keySeven, "", time.Second)
1815
+				if err != nil {
1816
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1817
+				}
1818
+			} else {
1819
+				err := service.UpDateDialysisPrescription(&newprescribe)
1820
+				//获取key,清空redis
1821
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1822
+				redis := service.RedisClient()
1823
+
1824
+				//清空key 值
1825
+				redis.Set(key, "", time.Second)
1826
+
1827
+				keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1828
+				//清空key 值
1829
+				redis.Set(keyOne, "", time.Second)
1830
+
1831
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1832
+				//清空key 值
1833
+				redis.Set(keyTwo, "", time.Second)
1834
+
1835
+				keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1836
+				redis.Set(keySix, "", time.Second)
1837
+
1838
+				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1839
+				redis.Set(keySeven, "", time.Second)
1840
+				if err != nil {
1841
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1842
+				}
1843
+			}
1686 1844
 			if err != nil {
1687 1845
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1688 1846
 			}
@@ -1699,7 +1857,60 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1699 1857
 			newprescribe.TargetUltrafiltration = dewater_amount
1700 1858
 			newprescribe.Status = 1
1701 1859
 
1702
-			err := service.AddSigleRecord(&newprescribe)
1860
+			_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
1861
+			newprescribe.ID = dialysisPrescription.ID
1862
+			if dialysisPrescription.ID == 0 {
1863
+				err := service.AddSigleRecord(&newprescribe)
1864
+				fmt.Println("处方44444444444")
1865
+				//获取key,清空redis
1866
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1867
+				redis := service.RedisClient()
1868
+
1869
+				//清空key 值
1870
+				redis.Set(key, "", time.Second)
1871
+
1872
+				keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1873
+				//清空key 值
1874
+				redis.Set(keyOne, "", time.Second)
1875
+
1876
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1877
+				//清空key 值
1878
+				redis.Set(keyTwo, "", time.Second)
1879
+
1880
+				keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1881
+				redis.Set(keySix, "", time.Second)
1882
+
1883
+				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1884
+				redis.Set(keySeven, "", time.Second)
1885
+				if err != nil {
1886
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1887
+				}
1888
+			} else {
1889
+				err := service.UpDateDialysisPrescription(&newprescribe)
1890
+				//获取key,清空redis
1891
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1892
+				redis := service.RedisClient()
1893
+
1894
+				//清空key 值
1895
+				redis.Set(key, "", time.Second)
1896
+
1897
+				keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1898
+				//清空key 值
1899
+				redis.Set(keyOne, "", time.Second)
1900
+
1901
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1902
+				//清空key 值
1903
+				redis.Set(keyTwo, "", time.Second)
1904
+
1905
+				keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
1906
+				redis.Set(keySix, "", time.Second)
1907
+
1908
+				keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
1909
+				redis.Set(keySeven, "", time.Second)
1910
+				if err != nil {
1911
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1912
+				}
1913
+			}
1703 1914
 			if err != nil {
1704 1915
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1705 1916
 			}

+ 18 - 19
controllers/print_data_api_controller.go Ver fichero

@@ -113,26 +113,25 @@ func (this *PrintDataAPIController) StockRecordPrintData() {
113 113
 }
114 114
 
115 115
 func (this *PrintDataAPIController) CourseRecordPrintData() {
116
-	id, _ := this.GetInt64("id", 0)
116
+	ids_str := this.GetString("ids")
117
+	ids_arr := strings.Split(ids_str, ",")
117 118
 	adminUserInfo := this.GetAdminUserInfo()
118
-
119
-	if id == 0 {
120
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121
-		return
122
-	}
123
-	timeLayout := "2006-01-02 15:04:05"
124
-	record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, id)
125
-	dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
126
-	tempTime := strings.Split(dataTimeStr, " ")
127
-
128
-	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
129
-	if parseDateErr != nil {
130
-		this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
131
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
132
-		//return
133
-	}
134
-
135
-	patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, record.PatientID, recordDate.Unix())
119
+	patient_id, _ := this.GetInt64("patient_id")
120
+
121
+	//timeLayout := "2006-01-02 15:04:05"
122
+	record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, ids_arr)
123
+	//dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
124
+	//tempTime := strings.Split(dataTimeStr, " ")
125
+	//
126
+	//recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
127
+	//if parseDateErr != nil {
128
+	//	this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
129
+	//	//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
130
+	//	//return
131
+	//}
132
+
133
+	//patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, patient_id)
134
+	patient, _ := service.GetPatientDetail(adminUserInfo.CurrentOrgId, patient_id)
136 135
 	if err != nil {
137 136
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
138 137
 		return

+ 1 - 1
controllers/qiniiu_api_controller.go Ver fichero

@@ -22,7 +22,7 @@ func (c *QiNiuApiController) GetQNUpToken() {
22 22
 	defer redisClient.Close()
23 23
 
24 24
 	token, err := redisClient.Get("qn_token").Result()
25
-	fmt.Print("token------------------------------------", token)
25
+
26 26
 	if err != nil {
27 27
 		defer fmt.Println(err)
28 28
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)

+ 81 - 0
controllers/schedule_api_controller.go Ver fichero

@@ -67,6 +67,7 @@ func ScheduleApiRegistRouters() {
67 67
 	beego.Router("/api/order/changefuncprint", &ScheduleApiController{}, "Get:ChangeFuncPrint")
68 68
 	beego.Router("/api/order/getdataprint", &ScheduleApiController{}, "Get:GetDataPrint")
69 69
 	beego.Router("/api/schedule/getnextweekpanels", &ScheduleApiController{}, "Get:GetNextWeekPanels")
70
+	beego.Router("/api/schedule/synchroschedule", &ScheduleApiController{}, "Get:SynchroSchedule")
70 71
 }
71 72
 
72 73
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -367,7 +368,9 @@ func (c *ScheduleApiController) CreateSchedule() {
367 368
 	}
368 369
 
369 370
 	redis := service.RedisClient()
371
+
370 372
 	err = service.CreateSchedule(&schedule)
373
+
371 374
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
372 375
 
373 376
 	redis.Set(key, "", time.Second)
@@ -1400,6 +1403,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1400 1403
 			//err := service.UpdateScheduleStatus(clear_schedule_date, this.GetAdminUserInfo().CurrentOrgId)
1401 1404
 			if err == nil {
1402 1405
 				for _, item := range schedules {
1406
+					//删除当天的日期排班
1407
+					service.DeleteScheduleExist(item.ScheduleDate, item.UserOrgId)
1403 1408
 					//查找当天日期是否存在
1404 1409
 					_, errcode := service.GetTodayScheduleIsExist(item.PatientId, item.ScheduleDate, item.UserOrgId, item.ModeId, item.ScheduleType)
1405 1410
 					if errcode == gorm.ErrRecordNotFound {
@@ -2731,3 +2736,79 @@ func (c *ScheduleApiController) GetNextWeekPanels() {
2731 2736
 		"schedule": schedule,
2732 2737
 	})
2733 2738
 }
2739
+
2740
+func (c *ScheduleApiController) SynchroSchedule() {
2741
+
2742
+	template_id, _ := c.GetInt64("template_id")
2743
+	copy_startime, _ := c.GetInt64("copy_startime")
2744
+	copy_endtime, _ := c.GetInt64("copy_endtime")
2745
+
2746
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2747
+	//根据模板ID获取模板数据
2748
+	list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
2749
+	//清空该时间段的所有排班数据
2750
+	service.DeletePatientSchedule(copy_startime, copy_endtime, orgId)
2751
+
2752
+	var tuesday int64
2753
+	var wednesday int64
2754
+	var thursday int64
2755
+	var friday int64
2756
+	var saturday int64
2757
+
2758
+	tuesday = copy_startime + 86400
2759
+	wednesday = copy_startime + 172800
2760
+	thursday = copy_startime + 259200
2761
+	friday = copy_startime + 345600
2762
+	saturday = copy_startime + 432000
2763
+
2764
+	for _, item := range list {
2765
+		if item.Weekday == 1 {
2766
+			item.ScheduleDate = copy_startime
2767
+		}
2768
+		if item.Weekday == 2 {
2769
+			item.ScheduleDate = tuesday
2770
+		}
2771
+		if item.Weekday == 3 {
2772
+			item.ScheduleDate = wednesday
2773
+		}
2774
+		if item.Weekday == 4 {
2775
+			item.ScheduleDate = thursday
2776
+		}
2777
+		if item.Weekday == 5 {
2778
+			item.ScheduleDate = friday
2779
+		}
2780
+		if item.Weekday == 6 {
2781
+			item.ScheduleDate = saturday
2782
+		}
2783
+		if item.Weekday == 7 {
2784
+			item.ScheduleDate = copy_endtime
2785
+		}
2786
+
2787
+		//根据床位号获取区号
2788
+		number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
2789
+		item.ZoneId = number.ZoneID
2790
+	}
2791
+
2792
+	for _, item := range list {
2793
+		schedule := models.XtSchedule{
2794
+			UserOrgId:    orgId,
2795
+			PartitionId:  item.ZoneId,
2796
+			BedId:        item.DeviceNumberID,
2797
+			PatientId:    item.PatientID,
2798
+			ScheduleDate: item.ScheduleDate,
2799
+			ScheduleType: item.TimeType,
2800
+			ScheduleWeek: item.Weekday,
2801
+			ModeId:       item.TreatMode,
2802
+			Status:       1,
2803
+			CreatedTime:  time.Now().Unix(),
2804
+			UpdatedTime:  0,
2805
+		}
2806
+
2807
+		service.CreatePatientSchedule(&schedule)
2808
+	}
2809
+
2810
+	returnData := make(map[string]interface{}, 0)
2811
+	returnData["list"] = list
2812
+	c.ServeSuccessJSON(returnData)
2813
+	return
2814
+}

+ 3 - 0
controllers/schedule_template_api_controller.go Ver fichero

@@ -6,6 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8 8
 	"encoding/json"
9
+	"fmt"
9 10
 	"time"
10 11
 
11 12
 	"github.com/astaxie/beego"
@@ -76,6 +77,8 @@ func (this *PatientScheduleTemplateAPIController) InitData() {
76 77
 	}
77 78
 
78 79
 	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId)
80
+
81
+	fmt.Println("deviceNumbers233323232332232323223233223323232323", deviceNumbers)
79 82
 	if getDeviceNumbersErr != nil {
80 83
 		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
81 84
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 1 - 1
main.go Ver fichero

@@ -11,7 +11,7 @@ func init() {
11 11
 }
12 12
 
13 13
 func main() {
14
-	//service.BeginAutoCreateWeekSchedulesJob()
14
+	service.BeginAutoCreateWeekSchedulesJob()
15 15
 	//service.BeginAutoCreateWeekDisinfectionJob()
16 16
 	//service.BeginAutoCreatePlanJob()
17 17
 	//service.AutoClearSchedules()

+ 21 - 0
models/patient_schedule_template_models.go Ver fichero

@@ -44,3 +44,24 @@ type PatientScheduleTemplateItem struct {
44 44
 func (PatientScheduleTemplateItem) TableName() string {
45 45
 	return "xt_patient_schedule_template_item"
46 46
 }
47
+
48
+type VmPatientScheduleTemplateItem struct {
49
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
50
+	OrgID          int64 `gorm:"column:org_id" json:"-" form:"org_id"`
51
+	TemplateID     int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
52
+	DeviceNumberID int64 `gorm:"column:device_number_id" json:"device_number_id" form:"device_number_id"`
53
+	PatientID      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
54
+	TreatMode      int64 `gorm:"column:treat_mode" json:"treat_mode" form:"treat_mode"` // 治疗模式
55
+	Weekday        int64 `gorm:"column:weekday" json:"weekday" form:"weekday"`          // 周一-周日 1-7
56
+	TimeType       int64 `gorm:"column:time_type" json:"time_type" form:"time_type"`    // 上下晚 123
57
+	Status         int64 `gorm:"column:status" json:"-" form:"status"`
58
+	CreateTime     int64 `gorm:"column:ctime" json:"-" form:"ctime"`
59
+	ModifyTime     int64 `gorm:"column:mtime" json:"-" form:"mtime"`
60
+	IsExport       int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
61
+	ScheduleDate   int64
62
+	ZoneId         int64
63
+}
64
+
65
+func (VmPatientScheduleTemplateItem) TableName() string {
66
+	return "xt_patient_schedule_template_item"
67
+}

+ 1 - 2
service/auto_clear_schedules_service.go Ver fichero

@@ -33,8 +33,7 @@ func AutoClearSchedules() {
33 33
 	scheduleDate := utils.ZeroHourTimeOfDay(time.Now())
34 34
 	for _, item := range schedules {
35 35
 		//将今天(不包括今天)以前的的排班数据进行软删除
36
-		writeDb.
37
-			Table("xt_schedule as s").
36
+		writeDb.Table("xt_schedule as s").
38 37
 			Where("s.schedule_date < ? AND s.status = 1 AND "+
39 38
 				"s.user_org_id = ? AND "+
40 39
 				"NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where  d.`status` = 1 AND"+

+ 7 - 3
service/auto_create_staff_schedule_service.go Ver fichero

@@ -69,7 +69,6 @@ func AutoCreateStaffScheduleJob() {
69 69
 	// 获取所有机构信息
70 70
 	orgs, _ := GetAllOrgs()
71 71
 	for _, item := range orgs {
72
-		fmt.Println(item)
73 72
 		//查询该机构是否开启连续排班功能
74 73
 		schdule, _ := GetAutoContinueSchdule(item.ID)
75 74
 		//如果状态值未开启不生成连续排班
@@ -131,9 +130,14 @@ func GeThisWeekScheduleData(orgid int64, startime int64, endtime int64) (staffsc
131 130
 }
132 131
 
133 132
 func AddSchedules(schedule *models.StaffSchedule) error {
134
-
133
+	tx := writeDb.Begin()
135 134
 	err := XTWriteDB().Model(&schedule).Create(&schedule).Error
136
-	return err
135
+	if err != nil {
136
+		tx.Rollback()
137
+		return err
138
+	}
139
+	tx.Commit()
140
+	return nil
137 141
 }
138 142
 
139 143
 func GetNextWeekData(orgid int64, docid int64, scheduledate int64) (*models.StaffSchedule, error) {

+ 1 - 0
service/auto_create_week_schedules_service.go Ver fichero

@@ -147,6 +147,7 @@ func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.
147 147
 
148 148
 	// 批量插入排班
149 149
 	if len(templateItems) > 0 {
150
+
150 151
 		valueStrs := make([]string, 0, len(templateItems))
151 152
 		values := make([]interface{}, 0, len(templateItems)*11)
152 153
 		for _, item := range templateItems {

+ 49 - 39
service/dialysis_service.go Ver fichero

@@ -726,51 +726,54 @@ func GetDialysisWatch(orgID int64, schedulDate int64, schedulType int64, partiti
726 726
 	return schedule, err, total
727 727
 }
728 728
 
729
-func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64) (schedules []*models.DialysisSchedule, err error, total int64) {
730
-	//var patients []*models.Patients
731
-	//getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
732
-	//if getPatientErr != nil {
733
-	//	return nil, getPatientErr, 0
734
-	//}
735
-	//patientIDs := make([]int64, len(patients))
736
-	//for index, patient := range patients {
737
-	//	patientIDs[index] = patient.ID
738
-	//}
739
-	//
740
-	//db := readDb.
741
-	//	Model(&models.DialysisSchedule{}).
742
-	//	Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
743
-	//	Preload("TreatmentMode", "status = 1").
744
-	//	Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
745
-	//	Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
746
-	//	Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
747
-	//	Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
748
-	//	Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
749
-	//	Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
750
-	//db = db.Where("xt_schedule.status = 1 AND patient_id in (?)", patientIDs)
751
-	//if schedulType > 0 {
752
-	//	db = db.Where("schedule_type = ?", schedulType)
753
-	//}
754
-	//if partitionType > 0 {
755
-	//	db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ? and d_n.status = 1", partitionType)
756
-	//
757
-	//}
758
-	//var schedules []*models.DialysisSchedule
759
-	//total := int64(0)
760
-	//err := db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
761
-	//return schedules, err, total
729
+//func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64) (schedules []*models.DialysisSchedule, err error, total int64) {
730
+//	db := readDb.Model(&models.DialysisSchedule{}).Where("status = 1")
731
+//
732
+//	if schedulType > 0 {
733
+//		db = db.Where("scheudle_type = ?", schedulType)
734
+//	}
735
+//
736
+//	if partitionType > 0 {
737
+//		db = db.Where("partition_id = ?", partitionType)
738
+//	}
739
+//
740
+//	err = db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
741
+//	return schedules, err, total
742
+//}
762 743
 
763
-	db := readDb.Model(&models.DialysisSchedule{}).Where("status = 1")
744
+func GetDialysisWatchByKeyword(orgID int64, keyword string, schedulType int64, partitionType int64, page int64, limit int64) ([]*models.DialysisSchedule, error, int64) {
745
+	var patients []*models.Patients
746
+	getPatientErr := readDb.Model(&models.Patients{}).Where("status = 1 AND user_org_id = ? AND (name like ? OR dialysis_no like ?)", orgID, "%"+keyword+"%", "%"+keyword+"%").Find(&patients).Error
747
+	if getPatientErr != nil {
748
+		return nil, getPatientErr, 0
749
+	}
750
+	patientIDs := make([]int64, len(patients))
751
+	for index, patient := range patients {
752
+		patientIDs[index] = patient.ID
753
+	}
764 754
 
755
+	db := readDb.
756
+		Model(&models.DialysisSchedule{}).
757
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
758
+		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
759
+		Preload("TreatmentMode", "status = 1").
760
+		Preload("Prescription", "status = 1 AND user_org_id = ?", orgID).
761
+		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ?", orgID).
762
+		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ?", orgID).
763
+		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?", orgID).
764
+		Preload("DialysisOrder", "status = 1 AND user_org_id = ?", orgID).
765
+		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID)
766
+	db = db.Where("xt_schedule.status = 1 AND patient_id in (?)", patientIDs)
765 767
 	if schedulType > 0 {
766
-		db = db.Where("scheudle_type = ?", schedulType)
768
+		db = db.Where("schedule_type = ?", schedulType)
767 769
 	}
768
-
769 770
 	if partitionType > 0 {
770
-		db = db.Where("partition_id = ?", partitionType)
771
+		db = db.Joins("inner join xt_device_number as d_n on d_n.id = xt_schedule.bed_id and d_n.zone_id = ? and d_n.status = 1", partitionType)
772
+		// db = db.Where("partition_id = ?", partitionType)
771 773
 	}
772
-
773
-	err = db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
774
+	var schedules []*models.DialysisSchedule
775
+	total := int64(0)
776
+	err := db.Count(&total).Offset(limit * (page - 1)).Limit(limit).Order("schedule_date desc").Find(&schedules).Error
774 777
 	return schedules, err, total
775 778
 }
776 779
 
@@ -1406,6 +1409,13 @@ func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (ad
1406 1409
 	return
1407 1410
 }
1408 1411
 
1412
+func GetAllPcPatientListByListSeven(orgID int64) (patients []*MSchedualPatientVMList, err error) {
1413
+
1414
+	err = readDb.Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
1415
+
1416
+	return patients, err
1417
+}
1418
+
1409 1419
 func GetAllPcPatientListByList(orgID int64) (patients []*MSchedualPatientVMList, err error) {
1410 1420
 	redis := RedisClient()
1411 1421
 	defer redis.Close()

+ 41 - 2
service/mobile_dialysis_service.go Ver fichero

@@ -407,6 +407,25 @@ func MobileGetSchedualDetailOne(orgID int64, patientID int64, schedualDate int64
407 407
 	return &vm, err
408 408
 }
409 409
 
410
+// 用户排班信息
411
+func MobileGetSchedualDetailSix(orgID int64, patientID int64, schedualDate int64) (*MDialysisScheduleVM, error) {
412
+	var vm MDialysisScheduleVM
413
+	err := readDb.
414
+		Table("xt_schedule").
415
+		// Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
416
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
417
+		Where("status = 1 AND user_org_id = ? AND schedule_date = ? AND patient_id = ?", orgID, schedualDate, patientID).
418
+		First(&vm).Error
419
+	if err != nil {
420
+		if err == gorm.ErrRecordNotFound {
421
+			return nil, nil
422
+		} else {
423
+			return nil, err
424
+		}
425
+	}
426
+	return &vm, err
427
+}
428
+
410 429
 // 用户排班信息
411 430
 func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (*MDialysisScheduleVM, error) {
412 431
 	redis := RedisClient()
@@ -2102,9 +2121,9 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
2102 2121
 
2103 2122
 	// cur_date := time.Now().Format("2006-01-02")
2104 2123
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
2105
-	fmt.Println("key23323323223323")
2124
+
2106 2125
 	dialysis_prescribe_str, _ := redis.Get(key).Result()
2107
-	fmt.Println("c产杜3323232323232323232", len(dialysis_prescribe_str))
2126
+
2108 2127
 	if len(dialysis_prescribe_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2109 2128
 		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? AND mode_id = ?", patientID, orgID, recordDate, mode_id).First(&record).Error
2110 2129
 		if err != nil {
@@ -2139,6 +2158,21 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
2139 2158
 	}
2140 2159
 }
2141 2160
 
2161
+func MobileGetDialysisPrescribeByModeIdSix(orgID int64, patientID int64, recordDate int64, mode_id int64) (*models.DialysisPrescription, error) {
2162
+	var record models.DialysisPrescription
2163
+
2164
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? AND mode_id = ?", patientID, orgID, recordDate, mode_id).First(&record).Error
2165
+	if err != nil {
2166
+		if err == gorm.ErrRecordNotFound {
2167
+			return nil, nil
2168
+		} else {
2169
+			return nil, err
2170
+		}
2171
+	}
2172
+	return &record, nil
2173
+
2174
+}
2175
+
2142 2176
 func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
2143 2177
 	var record models.DialysisPrescription
2144 2178
 	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
@@ -2500,6 +2534,11 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
2500 2534
 	return
2501 2535
 }
2502 2536
 
2537
+func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2538
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1640966400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2539
+	return
2540
+}
2541
+
2503 2542
 func GetFirstDateOfMonth(d time.Time) time.Time {
2504 2543
 	d = d.AddDate(0, 0, -d.Day()+1)
2505 2544
 	return GetZeroTime(d)

+ 78 - 10
service/patient_service.go Ver fichero

@@ -80,6 +80,13 @@ func GetAllPatientList(orgID int64) (patients []*models.Patients, total int64, e
80 80
 	return
81 81
 }
82 82
 
83
+func GetAllPatientListSix(orgID int64) (patients []*models.MSchedualPatientList, err error) {
84
+
85
+	err = XTReadDB().Model(&patients).Where("user_org_id = ? and status = 1", orgID).Find(&patients).Error
86
+
87
+	return patients, err
88
+}
89
+
83 90
 //GetAllPatientList 返回全部患者的列表
84 91
 func GetAllPatientListByList(orgID int64) (patients []*models.MSchedualPatientList, err error) {
85 92
 	redis := RedisClient()
@@ -120,6 +127,12 @@ func GetAllPatientListByList(orgID int64) (patients []*models.MSchedualPatientLi
120 127
 	}
121 128
 }
122 129
 
130
+func GetAllDevicetByListSix(orgID int64) (devices []*models.MDeviceNumberForList, err error) {
131
+
132
+	err = readDb.Model(&models.MDeviceNumberForList{}).Preload("Zone", "status = 1 AND org_id = ?", orgID).Where("org_id=? and status=1 ", orgID).Find(&devices).Error
133
+	return devices, err
134
+}
135
+
123 136
 func GetAllDevicetByList(orgID int64) (devices []*models.MDeviceNumberForList, err error) {
124 137
 	redis := RedisClient()
125 138
 	defer redis.Close()
@@ -1959,6 +1972,13 @@ func GetDoctorAdviceListFour(orgID int64, patientID int64, advice_type int64, st
1959 1972
 
1960 1973
 }
1961 1974
 
1975
+func GetAllDeviceNumberByListSix(orgID int64) (number []*models.DeviceNumber, err error) {
1976
+
1977
+	err = readDb.Model(&models.DeviceNumber{}).Where("org_id=? and status=1", orgID).Find(&number).Error
1978
+
1979
+	return number, err
1980
+}
1981
+
1962 1982
 func GetAllDeviceNumberByList(orgID int64) (number []*models.DeviceNumber, err error) {
1963 1983
 	redis := RedisClient()
1964 1984
 	defer redis.Close()
@@ -1992,11 +2012,16 @@ func GetAllPrescriptionByListTwo(orgID int64, scheduleDate int64) (prescriptions
1992 2012
 
1993 2013
 	redis := RedisClient()
1994 2014
 	defer redis.Close()
1995
-	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
2015
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
1996 2016
 	prescriptions_list_all, _ := redis.Get(key).Result()
1997 2017
 
1998 2018
 	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1999
-		err = readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2019
+		if scheduleDate > 0 {
2020
+			err = readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2021
+		} else {
2022
+			err = readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ?", orgID).Find(&prescriptions).Error
2023
+		}
2024
+
2000 2025
 		if err != nil {
2001 2026
 			if err == gorm.ErrRecordNotFound {
2002 2027
 				return nil, nil
@@ -2022,11 +2047,16 @@ func GetAllPrescriptionByListTwo(orgID int64, scheduleDate int64) (prescriptions
2022 2047
 func GetAllAssessmentBeforesByListThree(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluation, err error) {
2023 2048
 	redis := RedisClient()
2024 2049
 	defer redis.Close()
2025
-	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_befores_list_all"
2050
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_befores_list_all"
2026 2051
 	assessment_befores_list_all, _ := redis.Get(key).Result()
2027 2052
 
2028 2053
 	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2029
-		err = readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
2054
+		if scheduleDate > 0 {
2055
+			err = readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
2056
+		} else {
2057
+			err = readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = ?", orgID).Find(&assessmentBefores).Error
2058
+		}
2059
+
2030 2060
 		if err != nil {
2031 2061
 			if err == gorm.ErrRecordNotFound {
2032 2062
 				return nil, nil
@@ -2052,11 +2082,16 @@ func GetAllAssessmentBeforesByListThree(orgID int64, scheduleDate int64) (assess
2052 2082
 func GetAllDialysisOrdersByListThree(orgID int64, scheduleDate int64) (dialysisOrders []*models.MonitorDialysisOrder, err error) {
2053 2083
 	redis := RedisClient()
2054 2084
 	defer redis.Close()
2055
-	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
2085
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
2056 2086
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
2057 2087
 
2058 2088
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2059
-		err = readDb.Model(&models.MonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2089
+		if scheduleDate > 0 {
2090
+			err = readDb.Model(&models.MonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2091
+		} else {
2092
+			err = readDb.Model(&models.MonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ?", orgID).Find(&dialysisOrders).Error
2093
+		}
2094
+
2060 2095
 		if err != nil {
2061 2096
 			if err == gorm.ErrRecordNotFound {
2062 2097
 				return nil, nil
@@ -2082,11 +2117,16 @@ func GetAllDialysisOrdersByListThree(orgID int64, scheduleDate int64) (dialysisO
2082 2117
 func GetAllAssessmentAfterDislysisByListThree(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.AssessmentAfterDislysis, err error) {
2083 2118
 	redis := RedisClient()
2084 2119
 	defer redis.Close()
2085
-	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
2120
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_after_dislysis_list_all"
2086 2121
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
2087 2122
 
2088 2123
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2089
-		err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
2124
+		if scheduleDate > 0 {
2125
+			err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
2126
+		} else {
2127
+			err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ?", orgID).Find(&assessmentAfterDislysis).Error
2128
+		}
2129
+
2090 2130
 		if err != nil {
2091 2131
 			if err == gorm.ErrRecordNotFound {
2092 2132
 				return nil, nil
@@ -2113,11 +2153,16 @@ func GetAllMonitorListThree(orgID int64, scheduleDate int64) (monitor []*models.
2113 2153
 
2114 2154
 	redis := RedisClient()
2115 2155
 	defer redis.Close()
2116
-	key := strconv.FormatInt(orgID, 10) + ":" + ":monitor_record_list_all"
2156
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_record_list_all"
2117 2157
 	monitor_record_list_all, _ := redis.Get(key).Result()
2118 2158
 
2119 2159
 	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2120
-		err = readDb.Model(&models.MonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2160
+		if scheduleDate > 0 {
2161
+			err = readDb.Model(&models.MonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2162
+		} else {
2163
+			err = readDb.Model(&models.MonitoringRecord{}).Where("status = 1  AND user_org_id = ?", orgID).Find(&monitor).Error
2164
+		}
2165
+
2121 2166
 		if err != nil {
2122 2167
 			if err == gorm.ErrRecordNotFound {
2123 2168
 				return nil, nil
@@ -2170,6 +2215,22 @@ func GetAllPatientListByListThree(orgID int64) (patients []*models.MonitorPatien
2170 2215
 	}
2171 2216
 }
2172 2217
 
2218
+func GetAllPatientListByListSix(orgID int64, keywords string) (patients []*models.MonitorPatients, err error) {
2219
+
2220
+	db := readDb.Model(&models.MonitorPatients{}).Where("status = 1 and lapseto = 1")
2221
+	likeKey := "%" + keywords + "%"
2222
+	if orgID > 0 {
2223
+		db = db.Where("user_org_id = ?", orgID)
2224
+	}
2225
+	if len(keywords) > 0 {
2226
+
2227
+		db = db.Where("name like ?", likeKey)
2228
+	}
2229
+	err = db.Find(&patients).Error
2230
+
2231
+	return patients, err
2232
+}
2233
+
2173 2234
 func GetAllDialysisOrdersByListTwo(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVM, err error) {
2174 2235
 	redis := RedisClient()
2175 2236
 	defer redis.Close()
@@ -2427,6 +2488,7 @@ func GetAllTreatModeByList(orgID int64) (treatement []*models.TreatmentMode, err
2427 2488
 	treatment_info_str, _ := redis.Get(key).Result()
2428 2489
 
2429 2490
 	if len(treatment_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2491
+
2430 2492
 		err = readDb.Model(&models.TreatmentMode{}).Where("status=1").Find(&treatement).Error
2431 2493
 		if err != nil {
2432 2494
 			if err == gorm.ErrRecordNotFound {
@@ -2450,6 +2512,12 @@ func GetAllTreatModeByList(orgID int64) (treatement []*models.TreatmentMode, err
2450 2512
 	}
2451 2513
 }
2452 2514
 
2515
+func GetAllPatientListByListSeven(orgID int64) (patients []*MSchedualPatientVM, err error) {
2516
+
2517
+	err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2518
+	return patients, nil
2519
+}
2520
+
2453 2521
 func GetAllPatientListByListTwo(orgID int64) (patients []*MSchedualPatientVM, err error) {
2454 2522
 	redis := RedisClient()
2455 2523
 	defer redis.Close()

+ 4 - 4
service/patientmanage_service.go Ver fichero

@@ -1853,7 +1853,7 @@ func GetHospitalSummaryList(orgid int64, patient_id int64, startime int64, endti
1853 1853
 		db = db.Where("record_date >=?", startime)
1854 1854
 	}
1855 1855
 	if endtime > 0 {
1856
-		db = db.Where("record_date >=?", endtime)
1856
+		db = db.Where("record_date <=?", endtime)
1857 1857
 	}
1858 1858
 	if patient_id > 0 {
1859 1859
 		db = db.Where("patient_id = ?", patient_id)
@@ -1871,11 +1871,11 @@ func GetHospitalSummaryDetail(id int64) (models.XtHospitalSummary, error) {
1871 1871
 
1872 1872
 func UpdateHospital(id int64, summary models.XtHospitalSummary) error {
1873 1873
 
1874
-	err := XTWriteDB().Model(&summary).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"title": summary.Title, "admission_time": summary.AdmissionTime, "discharge_time": summary.DischargeTime, "sick_personnel": summary.SickPersonnel, "xray": summary.Xray, "connecticut": summary.Connecticut, "nuclear_magnetic_resonance": summary.NuclearMagneticResonance, "ultrasound": summary.Ultrasound, "pathology": summary.Pathology, "admitting_diagnosis_id": summary.AdmittingDiagnosisId, "admitting_diagnosis": summary.AdmittingDiagnosis, "discharge_diagnosis_id": summary.DischargeAdviceId, "discharge_diagnosis": summary.DischargeDiagnosis, "diagnosis_admission_id": summary.DiagnosisAdmissionId, "diagnosis_admission": summary.DiagnosisAdmission, "treatment_id": summary.TreatmentId, "treatment": summary.Treatment, "illness_discharge_id": summary.IllnessDischargeId, "illness_discharge": summary.IllnessDischarge, "discharge_advice_id": summary.DischargeAdviceId, "discharge_advice": summary.DischargeAdvice, "mtime": summary.Mtime, "record_time": summary.RecordTime, "dean_id": summary.DeanId, "doctor": summary.Doctor, "record_date": summary.RecordDate}).Error
1874
+	err := XTWriteDB().Model(&summary).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"title": summary.Title, "admission_time": summary.AdmissionTime, "discharge_time": summary.DischargeTime, "sick_personnel": summary.SickPersonnel, "xray": summary.Xray, "connecticut": summary.Connecticut, "nuclear_magnetic_resonance": summary.NuclearMagneticResonance, "ultrasound": summary.Ultrasound, "pathology": summary.Pathology, "admitting_diagnosis_id": summary.AdmittingDiagnosisId, "admitting_diagnosis": summary.AdmittingDiagnosis, "discharge_diagnosis_id": summary.DischargeDiagnosisId, "discharge_diagnosis": summary.DischargeDiagnosis, "diagnosis_admission_id": summary.DiagnosisAdmissionId, "diagnosis_admission": summary.DiagnosisAdmission, "treatment_id": summary.TreatmentId, "treatment": summary.Treatment, "illness_discharge_id": summary.IllnessDischargeId, "illness_discharge": summary.IllnessDischarge, "discharge_advice_id": summary.DischargeAdviceId, "discharge_advice": summary.DischargeAdvice, "mtime": summary.Mtime, "record_time": summary.RecordTime, "dean_id": summary.DeanId, "doctor": summary.Doctor, "record_date": summary.RecordDate}).Error
1875 1875
 	return err
1876 1876
 }
1877 1877
 
1878
-func DeleteHospitalSummary(id int64) error {
1879
-	err := XTWriteDB().Model(models.XtHospitalSummary{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
1878
+func DeleteHospitalSummary(id []string) error {
1879
+	err := XTWriteDB().Model(models.XtHospitalSummary{}).Where("id in (?) and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
1880 1880
 	return err
1881 1881
 }

+ 24 - 7
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go Ver fichero

@@ -57,9 +57,16 @@ func GetSchedules(orgID int64, schIDs []string) ([]*ScheduleVM, error) {
57 57
 		return nil, err
58 58
 	}
59 59
 	for _, item := range schedules {
60
-		dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
61
-		fmt.Println(dialysis_count)
62
-		item.Patient.TotalDialysis = dialysis_count
60
+
61
+		if orgID != 10101 {
62
+			dialysis_count, _ := GetDialysisOrderCount(orgID, item.PatientID, item.ScheduleDate)
63
+			item.Patient.TotalDialysis = dialysis_count
64
+		}
65
+		if orgID == 10101 {
66
+			dialysis_count, _ := GetDialysisOrderCountOne(orgID, item.PatientID, item.ScheduleDate)
67
+			item.Patient.TotalDialysis = dialysis_count
68
+		}
69
+
63 70
 		fmt.Println(item.Patient.TotalDialysis)
64 71
 
65 72
 	}
@@ -112,22 +119,27 @@ func GetAllName(orgId int64, appid int64) (list []AdminUserListTwo, err error) {
112 119
 	return
113 120
 }
114 121
 
115
-func GetPatientCoursesRecords(orgID int64, id int64) (records models.PatientDiseaseCourse, err error) {
122
+func GetPatientCoursesRecords(orgID int64, id []string) (records []*models.PatientDiseaseCourse, err error) {
116 123
 	db := p_service.XTReadDB()
117
-	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id = ? and status = 1", orgID, id).Find(&records).Error
124
+	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id in(?) and status = 1", orgID, id).Find(&records).Error
118 125
 	return
119 126
 }
120 127
 
121
-func FindPatientWithDeviceById(orgID int64, patient_id int64, time int64) (patient models.SchedualPatient2, err error) {
128
+func FindPatientWithDeviceById(orgID int64, patient_id int64) (patient models.SchedualPatient2, err error) {
122 129
 	db := p_service.XTReadDB()
123 130
 
124 131
 	err = db.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
125 132
 		return db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
126 133
 			Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
127
-			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
134
+			Where("user_org_id = ?", orgID)
128 135
 	}).Where("user_org_id=? and id = ? and status=1", orgID, patient_id).First(&patient).Error
129 136
 	return
130 137
 }
138
+func GetPatientDetail(orgID int64, patient_id int64) (models.XtPatients, error) {
139
+	patients := models.XtPatients{}
140
+	err := p_service.XTReadDB().Where("user_org_id = ? and id = ? and status = 1", orgID, patient_id).Find(&patients).Error
141
+	return patients, err
142
+}
131 143
 
132 144
 func GetLastAfterWeight(orgID int64, patientID int64, maxDate int64) (*models.AssessmentAfterDislysis, error) {
133 145
 	var record models.AssessmentAfterDislysis
@@ -195,6 +207,11 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
195 207
 	return
196 208
 }
197 209
 
210
+func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
211
+	err = p_service.XTReadDB().Model(&models.DialysisOrder{}).Where("dialysis_date >=1640966400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
212
+	return
213
+}
214
+
198 215
 func GetOutStockTotalCountTwo(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
199 216
 
200 217
 	err = p_service.XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.record_time,x.count FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and x.record_time >= ? and x.record_time<=? and `status` = 1)  as b GROUP BY good_id", orgid, startime, endtime).Scan(&autoMatic).Error

+ 43 - 2
service/schedule_service.go Ver fichero

@@ -161,7 +161,16 @@ func GetPointSchedule(orgID, scheduleDate, scheduleWeek, scheduleType, bedId int
161 161
 }
162 162
 
163 163
 func CreateSchedule(m *models.Schedule) error {
164
-	return writeDb.Model(&models.Schedule{}).Create(&m).Error
164
+	utx := XTWriteDB().Begin()
165
+	err := utx.Create(&m).Error
166
+	utx.Commit()
167
+	return err
168
+}
169
+
170
+func DeleteScheduleExist(scheduleData int64, user_org_id int64) (models.XtSchedule, error) {
171
+	schedule := models.XtSchedule{}
172
+	err := XTWriteDB().Where("schedule_date= ? and user_org_id = ? and status = 1", scheduleData, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
173
+	return schedule, err
165 174
 }
166 175
 
167 176
 func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64, mode_id int64, schedule_type int64) (*models.XtSchedule, error) {
@@ -193,7 +202,10 @@ func GetSchedule(orgID, id int64) (*models.Schedule, error) {
193 202
 }
194 203
 
195 204
 func UpdateSchedule(m *models.Schedule) error {
196
-	return writeDb.Model(&models.Schedule{}).Save(&m).Error
205
+	utx := XTWriteDB().Begin()
206
+	err := utx.Save(&m).Error
207
+	utx.Commit()
208
+	return err
197 209
 }
198 210
 
199 211
 func GetPatientScheduleFormToday(orgId, id, start int64) (schedules []*models.PatientSchedule, err error) {
@@ -996,3 +1008,32 @@ func GetNextWeekPanels(startime int64, endtime int64, orgid int64) (schedule []*
996 1008
 	}).Find(&schedule).Error
997 1009
 	return schedule, err
998 1010
 }
1011
+
1012
+func GetTemplateListByTemplateId(id int64, orgid int64) (list []*models.VmPatientScheduleTemplateItem, err error) {
1013
+
1014
+	err = XTReadDB().Where("template_id =? and org_id = ? and status = 1", id, orgid).Find(&list).Error
1015
+	return list, err
1016
+}
1017
+
1018
+func DeletePatientSchedule(startime int64, endtime int64, org_id int64) (models.XtSchedule, error) {
1019
+
1020
+	schedule := models.XtSchedule{}
1021
+	err := XTWriteDB().Model(&schedule).Where("schedule_date>=? and schedule_date<=? and user_org_id = ? and status = 1", startime, endtime, org_id).Updates(map[string]interface{}{"status": 0}).Error
1022
+	return schedule, err
1023
+}
1024
+
1025
+func GetBedNumberById(id int64, org_id int64) (models.DeviceNumber, error) {
1026
+
1027
+	number := models.DeviceNumber{}
1028
+
1029
+	err := XTReadDB().Where("id = ? and status = 1 and org_id =?", id, org_id).Find(&number).Error
1030
+	return number, err
1031
+}
1032
+
1033
+func CreatePatientSchedule(schedule *models.XtSchedule) error {
1034
+
1035
+	utx := XTWriteDB().Begin()
1036
+	err := utx.Create(&schedule).Error
1037
+	utx.Commit()
1038
+	return err
1039
+}

+ 12 - 2
service/stock_service.go Ver fichero

@@ -1380,7 +1380,12 @@ func FindAllWarehouseOutListOne(orgId int64, page int64, limit int64, startTime
1380 1380
 	}
1381 1381
 	db = db.Count(&total)
1382 1382
 	offset := (page - 1) * limit
1383
-	err = db.Offset(offset).Limit(limit).Order("xt_warehouse_out.ctime desc").Find(&list).Error
1383
+	if orgId == 10191 {
1384
+		err = db.Offset(offset).Limit(limit).Order("xt_warehouse_out.warehouse_out_time desc").Find(&list).Error
1385
+	} else {
1386
+		err = db.Offset(offset).Limit(limit).Order("xt_warehouse_out.ctime desc").Find(&list).Error
1387
+	}
1388
+
1384 1389
 	return list, total, err
1385 1390
 
1386 1391
 }
@@ -1429,7 +1434,12 @@ func FindAllDrugWarehouseOutListOne(orgId int64, page int64, limit int64, startT
1429 1434
 	}
1430 1435
 	db = db.Count(&total)
1431 1436
 	offset := (page - 1) * limit
1432
-	err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
1437
+	if orgId == 10191 {
1438
+		err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.warehouse_out_time desc").Find(&list).Error
1439
+	} else {
1440
+		err = db.Offset(offset).Limit(limit).Order("xt_drug_warehouse_out.ctime desc").Find(&list).Error
1441
+	}
1442
+
1433 1443
 	return list, total, err
1434 1444
 
1435 1445
 }