소스 검색

11月8日库存管理

XMLWAN 3 년 전
부모
커밋
a94f1e7e45

+ 1 - 1
conf/app.conf 파일 보기

@@ -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
 

+ 132 - 95
controllers/dialysis_api_controller.go 파일 보기

@@ -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)

+ 13 - 1
controllers/dialysis_record_api_controller.go 파일 보기

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

+ 16 - 0
controllers/doctors_api_controller.go 파일 보기

@@ -58,6 +58,7 @@ func DoctorApiRegistRouters() {
58 58
 	beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
59 59
 	beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Get: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() {
@@ -1294,8 +1295,10 @@ func (this *DoctorsApiController) GetHospitalSummaryList() {
1294 1295
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1295 1296
 	patient_id, _ := this.GetInt64("patient_id")
1296 1297
 	start_time := this.GetString("start_time")
1298
+	fmt.Println("start_tim232232323232323232323232332", start_time)
1297 1299
 	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1298 1300
 	startime := dischargeTimes.Unix()
1301
+	fmt.Println("startime1111111111111111111111", startime)
1299 1302
 	end_time := this.GetString("end_time")
1300 1303
 	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1301 1304
 	endtime := endTimes.Unix()
@@ -1409,3 +1412,16 @@ func (this *DoctorsApiController) DeleteHospitalSummary() {
1409 1412
 	this.ServeSuccessJSON(returnData)
1410 1413
 	return
1411 1414
 }
1415
+
1416
+func (this *DoctorsApiController) GetPatientInfo() {
1417
+
1418
+	patient_id, _ := this.GetInt64("patient_id")
1419
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1420
+	detail, err := service.GetPatientDetail(patient_id, orgId)
1421
+	if err == nil {
1422
+		this.ServeSuccessJSON(map[string]interface{}{
1423
+			"patient": detail,
1424
+		})
1425
+		return
1426
+	}
1427
+}

+ 4 - 6
controllers/mobile_api_controllers/dialysis_api_controller.go 파일 보기

@@ -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"

+ 221 - 10
controllers/mobile_api_controllers/patient_api_controller.go 파일 보기

@@ -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 파일 보기

@@ -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

+ 42 - 39
service/dialysis_service.go 파일 보기

@@ -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
 

+ 36 - 2
service/mobile_dialysis_service.go 파일 보기

@@ -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

+ 72 - 10
service/patient_service.go 파일 보기

@@ -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 {

+ 1 - 1
service/patientmanage_service.go 파일 보기

@@ -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)

+ 9 - 4
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go 파일 보기

@@ -112,22 +112,27 @@ func GetAllName(orgId int64, appid int64) (list []AdminUserListTwo, err error) {
112 112
 	return
113 113
 }
114 114
 
115
-func GetPatientCoursesRecords(orgID int64, id int64) (records models.PatientDiseaseCourse, err error) {
115
+func GetPatientCoursesRecords(orgID int64, id []string) (records []*models.PatientDiseaseCourse, err error) {
116 116
 	db := p_service.XTReadDB()
117
-	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id = ? and status = 1", orgID, id).Find(&records).Error
117
+	err = db.Model(&models.PatientDiseaseCourse{}).Where("org_id = ? and id in(?) and status = 1", orgID, id).Find(&records).Error
118 118
 	return
119 119
 }
120 120
 
121
-func FindPatientWithDeviceById(orgID int64, patient_id int64, time int64) (patient models.SchedualPatient2, err error) {
121
+func FindPatientWithDeviceById(orgID int64, patient_id int64) (patient models.SchedualPatient2, err error) {
122 122
 	db := p_service.XTReadDB()
123 123
 
124 124
 	err = db.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
125 125
 		return db.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
126 126
 			Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
127
-			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
127
+			Where("user_org_id = ?", orgID)
128 128
 	}).Where("user_org_id=? and id = ? and status=1", orgID, patient_id).First(&patient).Error
129 129
 	return
130 130
 }
131
+func GetPatientDetail(orgID int64, patient_id int64) (models.XtPatients, error) {
132
+	patients := models.XtPatients{}
133
+	err := p_service.XTReadDB().Where("user_org_id = ? and id = ? and status = 1", orgID, patient_id).Find(&patients).Error
134
+	return patients, err
135
+}
131 136
 
132 137
 func GetLastAfterWeight(orgID int64, patientID int64, maxDate int64) (*models.AssessmentAfterDislysis, error) {
133 138
 	var record models.AssessmentAfterDislysis