Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
570808cb44

+ 1 - 8
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9529
2
+httpport = 9531
3 3
 runmode = dev
4 4
 
5 5
 #
@@ -219,13 +219,6 @@ writesgjpatientmysqlpass = 1Q2W3e4r!@#$
219 219
 writesgjpatientmysqlname = sgj_patient
220 220
 
221 221
 
222
-
223
-
224
-
225
-
226
-
227
-#redishost = 120.77.235.13
228
-#redishost = 112.74.16.180
229 222
 redishost = kuyi6666.redis.rds.aliyuncs.com
230 223
 redisport = 6379
231 224
 redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP

+ 9 - 9
controllers/base_api_controller.go View File

@@ -4,7 +4,7 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
-	_"fmt"
7
+	_ "fmt"
8 8
 	"strconv"
9 9
 	"strings"
10 10
 )
@@ -72,17 +72,17 @@ func (this *BaseAuthAPIController) Prepare() {
72 72
 	if this.GetAdminUserInfo() == nil {
73 73
 		var userAdmin models.AdminUser
74 74
 		userAdmin.Id = 1448
75
-		userAdmin.Mobile = "13318599895"
75
+		userAdmin.Mobile = "13416402574"
76 76
 
77 77
 		userAdmin.Id = 597
78
-		userAdmin.Mobile = "19874122664"
78
+		userAdmin.Mobile = "13416402574"
79 79
 		userAdmin.IsSuperAdmin = false
80 80
 		userAdmin.Status = 1
81 81
 		userAdmin.CreateTime = 1530786071
82 82
 		userAdmin.ModifyTime = 1530786071
83 83
 		var subscibe models.ServeSubscibe
84 84
 		subscibe.ID = 1
85
-		subscibe.OrgId = 9675
85
+		subscibe.OrgId = 10016
86 86
 		subscibe.PeriodStart = 1538035409
87 87
 		subscibe.PeriodEnd = 1569571409
88 88
 		subscibe.State = 1
@@ -92,7 +92,7 @@ func (this *BaseAuthAPIController) Prepare() {
92 92
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93 93
 		subscibes[4] = &subscibe
94 94
 		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 9675
95
+		adminUserInfo.CurrentOrgId = 10016
96 96
 		adminUserInfo.CurrentAppId = 4
97 97
 		adminUserInfo.AdminUser = &userAdmin
98 98
 		adminUserInfo.Subscibes = subscibes
@@ -318,17 +318,17 @@ func (this *BaseServeAPIController) Prepare() {
318 318
 	if this.GetAdminUserInfo() == nil {
319 319
 		var userAdmin models.AdminUser
320 320
 		userAdmin.Id = 1448
321
-		userAdmin.Mobile = "13318599895"
321
+		userAdmin.Mobile = "13416402574"
322 322
 
323 323
 		userAdmin.Id = 597
324
-		userAdmin.Mobile = "19874122664"
324
+		userAdmin.Mobile = "13416402574"
325 325
 		userAdmin.IsSuperAdmin = false
326 326
 		userAdmin.Status = 1
327 327
 		userAdmin.CreateTime = 1530786071
328 328
 		userAdmin.ModifyTime = 1530786071
329 329
 		var subscibe models.ServeSubscibe
330 330
 		subscibe.ID = 1
331
-		subscibe.OrgId = 9675
331
+		subscibe.OrgId = 10016
332 332
 		subscibe.PeriodStart = 1538035409
333 333
 		subscibe.PeriodEnd = 1569571409
334 334
 		subscibe.State = 1
@@ -338,7 +338,7 @@ func (this *BaseServeAPIController) Prepare() {
338 338
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339 339
 		subscibes[4] = &subscibe
340 340
 		var adminUserInfo service.AdminUserInfo
341
-		adminUserInfo.CurrentOrgId = 9675
341
+		adminUserInfo.CurrentOrgId = 10016
342 342
 		adminUserInfo.CurrentAppId = 4
343 343
 		adminUserInfo.AdminUser = &userAdmin
344 344
 		adminUserInfo.Subscibes = subscibes

+ 93 - 12
controllers/dialysis_api_controller.go View File

@@ -152,7 +152,7 @@ func (c *DialysisApiController) UpdateQueueCall() {
152 152
 }
153 153
 
154 154
 func (c *DialysisApiController) PostPrescription() {
155
-	patient, _ := c.GetInt64("patient", 0)
155
+	patient, _ := c.GetInt64("patient_id", 0)
156 156
 	recordDateStr := c.GetString("record_date")
157 157
 
158 158
 	if patient <= 0 {
@@ -385,10 +385,13 @@ func (c *DialysisApiController) PostPrescription() {
385 385
 		err := service.AddSigleRecord(&prescription)
386 386
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
387 387
 		redis := service.RedisClient()
388
-		defer redis.Close()
389 388
 		//清空key 值
390 389
 		redis.Set(key, "", time.Second)
391
-
390
+		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
391
+		redis.Set(keyTwo, "", time.Second)
392
+		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
393
+		redis.Set(keyThree, "", time.Second)
394
+		defer redis.Close()
392 395
 		if err == nil {
393 396
 			updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
394 397
 			if updateErr != nil {
@@ -442,11 +445,17 @@ func (c *DialysisApiController) PostPrescription() {
442 445
 		prescription.ID = dialysisPrescription.ID
443 446
 
444 447
 		updateErr := service.UpDateDialysisPrescription(&prescription)
448
+
445 449
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
446 450
 		redis := service.RedisClient()
447 451
 		defer redis.Close()
448 452
 		//清空key 值
449 453
 		redis.Set(key, "", time.Second)
454
+
455
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
456
+		redis.Set(keyOne, "", time.Second)
457
+		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
458
+		redis.Set(keyThree, "", time.Second)
450 459
 		if updateErr == nil {
451 460
 			updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
452 461
 			if updateErr != nil {
@@ -570,6 +579,9 @@ func (c *DialysisApiController) PostSoulution() {
570 579
 	epo := c.GetString("epo")
571 580
 	epo_count, _ := c.GetFloat("epo_count", 0)
572 581
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
582
+	impulse := c.GetString("impulse")
583
+	preImpules, parseDateErr := strconv.ParseFloat(impulse, 64)
584
+	fmt.Println("", preImpules)
573 585
 	var prescription_doctor int64
574 586
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
575 587
 
@@ -681,6 +693,7 @@ func (c *DialysisApiController) PostSoulution() {
681 693
 		Epo:                        epo,
682 694
 		EpoCount:                   epo_count,
683 695
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
696
+		PreImpulse:                 preImpules,
684 697
 	}
685 698
 
686 699
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -846,6 +859,10 @@ func (c *DialysisApiController) PostSoulution() {
846 859
 		Epo:                        epo,
847 860
 		EpoCount:                   epo_count,
848 861
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
862
+		OxygenUptake:               oxygen_uptake,
863
+		OxygenFlow:                 oxygen_flow,
864
+		OxygenTime:                 oxygen_time,
865
+		PreImpulse:                 preImpules,
849 866
 	}
850 867
 	err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
851 868
 	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
@@ -857,6 +874,12 @@ func (c *DialysisApiController) PostSoulution() {
857 874
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
858 875
 	//清空key 值
859 876
 	redis.Set(keyOne, "", time.Second)
877
+
878
+	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
879
+	redis.Set(keyTwo, "", time.Second)
880
+
881
+	keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
882
+	redis.Set(keyThree, "", time.Second)
860 883
 	defer redis.Close()
861 884
 	if err == nil {
862 885
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -957,11 +980,17 @@ func (c *DialysisApiController) PostDouleCheck() {
957 980
 		doubleCheck.Modifier = modifier
958 981
 
959 982
 		err := service.AddSigleDoubleCheck(&doubleCheck)
960
-		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
961 983
 		redis := service.RedisClient()
962
-		defer redis.Close()
984
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
985
+		fmt.Println("key2333223233223232323", key)
963 986
 		//清空key 值
964 987
 		redis.Set(key, "", time.Second)
988
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
989
+		fmt.Println("keyTwo23332323223233223323232", keyTwo)
990
+		redis.Set(keyTwo, "", time.Second)
991
+		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
992
+		redis.Set(keyThree, "", time.Second)
993
+		defer redis.Close()
965 994
 		if err == nil {
966 995
 			c.ServeSuccessJSON(map[string]interface{}{
967 996
 				"doubleCheck": doubleCheck,
@@ -978,7 +1007,18 @@ func (c *DialysisApiController) PostDouleCheck() {
978 1007
 		doubleCheck.CreatedTime = check.CreatedTime
979 1008
 		doubleCheck.UpdatedTime = time.Now().Unix()
980 1009
 		doubleCheck.ID = check.ID
1010
+		redis := service.RedisClient()
981 1011
 		err := service.UpdateDoubleCheck(&doubleCheck)
1012
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
1013
+		fmt.Println("key2333223233223232323", key)
1014
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1015
+		redis.Set(keyTwo, "", time.Second)
1016
+		fmt.Println("keyTwo23332323223233223323232", keyTwo)
1017
+		//清空key 值
1018
+		redis.Set(key, "", time.Second)
1019
+		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
1020
+		redis.Set(keyThree, "", time.Second)
1021
+		defer redis.Close()
982 1022
 		if err == nil {
983 1023
 			c.ServeSuccessJSON(map[string]interface{}{
984 1024
 				"doubleCheck": doubleCheck,
@@ -1067,6 +1107,11 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1067 1107
 	if receiveTreatment.ID == 0 { //新增
1068 1108
 		receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
1069 1109
 		err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
1110
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1111
+		redis := service.RedisClient()
1112
+		//清空key 值
1113
+		redis.Set(key, "", time.Second)
1114
+		defer redis.Close()
1070 1115
 		if err == nil {
1071 1116
 			c.ServeSuccessJSON(map[string]interface{}{
1072 1117
 				"receiveTreatmentAsses": receiveTreatmentAsses,
@@ -1095,6 +1140,10 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1095 1140
 		receiveTreatmentAsses.Modifier = adminUserInfo.AdminUser.Id
1096 1141
 		receiveTreatmentAsses.ID = receiveTreatment.ID
1097 1142
 		err := service.UpadateReceiveTreatmentAsses(&receiveTreatmentAsses)
1143
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
1144
+		redis := service.RedisClient()
1145
+		defer redis.Close()
1146
+		redis.Set(keyOne, "", time.Second*60*60*18)
1098 1147
 		if err == nil {
1099 1148
 			c.ServeSuccessJSON(map[string]interface{}{
1100 1149
 				"receiveTreatmentAsses": receiveTreatmentAsses,
@@ -1235,6 +1284,15 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1235 1284
 
1236 1285
 		assessment.UpdatedTime = time.Now().Unix()
1237 1286
 		err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
1287
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1288
+		redis := service.RedisClient()
1289
+		//清空key 值
1290
+		redis.Set(key, "", time.Second)
1291
+		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_after_dislysis_list_all"
1292
+		redis.Set(keyThree, "", time.Second)
1293
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1294
+		redis.Set(keyTwo, "", time.Second)
1295
+		defer redis.Close()
1238 1296
 	} else {
1239 1297
 		if appRole.UserType == 2 || appRole.UserType == 1 {
1240 1298
 			assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
@@ -1251,9 +1309,13 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1251 1309
 		err = service.AddSigleAssessmentAfterDislysisRecord(&assessment)
1252 1310
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1253 1311
 		redis := service.RedisClient()
1254
-		defer redis.Close()
1255 1312
 		//清空key 值
1256 1313
 		redis.Set(key, "", time.Second)
1314
+		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_after_dislysis_list_all"
1315
+		redis.Set(keyThree, "", time.Second)
1316
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1317
+		redis.Set(keyTwo, "", time.Second)
1318
+		defer redis.Close()
1257 1319
 	}
1258 1320
 
1259 1321
 	if err != nil {
@@ -1440,9 +1502,16 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1440 1502
 		err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
1441 1503
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1442 1504
 		redis := service.RedisClient()
1443
-		defer redis.Close()
1505
+
1444 1506
 		//清空key 值
1445 1507
 		redis.Set(key, "", time.Second)
1508
+
1509
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_befores_list_all"
1510
+		redis.Set(keyOne, "", time.Second)
1511
+
1512
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1513
+		redis.Set(keyTwo, "", time.Second)
1514
+		defer redis.Close()
1446 1515
 		if err == nil {
1447 1516
 			c.ServeSuccessJSON(map[string]interface{}{
1448 1517
 				"assessmentBeforeDislysis": &assessmentBeforeDislysis,
@@ -1658,7 +1727,16 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1658 1727
 		}
1659 1728
 
1660 1729
 		err := service.UpadatePredialysisEvaluation(&assessmentBeforeDislysis)
1730
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1731
+		redis := service.RedisClient()
1732
+		//清空key 值
1733
+		redis.Set(key, "", time.Second)
1661 1734
 
1735
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_befores_list_all"
1736
+		redis.Set(keyOne, "", time.Second)
1737
+		defer redis.Close()
1738
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1739
+		redis.Set(keyTwo, "", time.Second)
1662 1740
 		if err == nil {
1663 1741
 			c.ServeSuccessJSON(map[string]interface{}{
1664 1742
 				"assessmentBeforeDislysis": &assessmentBeforeDislysis,
@@ -2940,7 +3018,7 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
2940 3018
 	}
2941 3019
 	adviceDate, _ := dataBody["advice_date"].(string)
2942 3020
 	theTime, err := time.ParseInLocation(timeLayout2, adviceDate, loc2)
2943
-	fmt.Println("the-----------------", theTime)
3021
+
2944 3022
 	AdviceDate := theTime.Unix()
2945 3023
 	RecordDate := theTime.Unix()
2946 3024
 
@@ -3174,7 +3252,10 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
3174 3252
 	}
3175 3253
 
3176 3254
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
3177
-
3255
+	redis := service.RedisClient()
3256
+	defer redis.Close()
3257
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
3258
+	redis.Set(key, "", time.Second)
3178 3259
 	if err != nil {
3179 3260
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3180 3261
 		return
@@ -3195,9 +3276,9 @@ func (c *DialysisApiController) GetSolution() {
3195 3276
 
3196 3277
 	adminUserInfo := c.GetAdminUserInfo()
3197 3278
 
3198
-	solution, err := service.MobileGetDialysisSolutionByModeId(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3199
-	prescription, err := service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3200
-	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, mode_id)
3279
+	solution, err := service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3280
+	prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
3281
+	system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, mode_id)
3201 3282
 
3202 3283
 	if err != nil {
3203 3284
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 248 - 108
controllers/dialysis_record_api_controller.go View File

@@ -74,15 +74,126 @@ func (this *DialysisRecordAPIController) GetSchedules() {
74 74
 	adminInfo := this.GetAdminUserInfo()
75 75
 	orgID := adminInfo.CurrentOrgId
76 76
 
77
-	schedules, err := service.GetDialysisScheduals(orgID, date.Unix())
78
-	if err != nil {
79
-		this.ErrorLog("获取排班信息失败:%v", err)
80
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
81
-	} else {
77
+	redis := service.RedisClient()
78
+	defer redis.Close()
79
+	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
80
+
81
+	scheduals_json_str, _ := redis.Get(key).Result()
82
+
83
+	if len(scheduals_json_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
84
+		scheduals, err := service.GetDialysisSchedualsOne(orgID, date.Unix())
85
+
86
+		if err != nil {
87
+			this.ErrorLog("获取排班信息失败:%v", err)
88
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
89
+		} else {
90
+			if len(scheduals) > 0 {
91
+				patients, _ := service.GetAllPcPatientListByList(orgID)
92
+
93
+				dialysisOrders, _ := service.GetAllPcDialysisOrdersByList(orgID, date.Unix())
94
+
95
+				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
96
+
97
+				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
98
+
99
+				treatmentSummarys, _ := service.GetAllPcTreatmentSummarysByList(orgID, date.Unix())
100
+
101
+				AssessmentAfterDislysis, _ := service.GetAllPcAssessmentAfterDislysisByList(orgID, date.Unix())
102
+
103
+				advices, _ := service.GetAllPcAdvicestByList(orgID, date.Unix())
104
+
105
+				for key, item := range scheduals {
106
+					// 获取患者信息
107
+					for _, patient := range patients {
108
+						if item.PatientId == patient.ID {
109
+							scheduals[key].SchedualPatient = patient
110
+							break
111
+						}
112
+					}
113
+
114
+					for _, advice := range advices {
115
+						if item.PatientId == advice.PatientId {
116
+							scheduals[key].Advices = append(scheduals[key].Advices, advice)
117
+						}
118
+					}
119
+
120
+					// 医嘱信息
121
+					for _, prescription := range prescriptions {
122
+						if item.PatientId == prescription.PatientId {
123
+							scheduals[key].Prescription = prescription
124
+							break
125
+						}
126
+					}
127
+
128
+					// 透前评估
129
+					for _, assessmentBefore := range assessmentBefores {
130
+						if item.PatientId == assessmentBefore.PatientId {
131
+							scheduals[key].AssessmentBeforeDislysis = assessmentBefore
132
+							break
133
+						}
134
+					}
135
+
136
+					// 透析上下机
137
+					for _, dialysisOrder := range dialysisOrders {
138
+						if item.PatientId == dialysisOrder.PatientId {
139
+							scheduals[key].DialysisOrder = dialysisOrder
140
+							break
141
+						}
142
+					}
143
+
144
+					// 治疗小节
145
+					for _, afterDislysis := range AssessmentAfterDislysis {
146
+						if item.PatientId == afterDislysis.PatientId {
147
+							scheduals[key].AssessmentAfterDislysis = afterDislysis
148
+							break
149
+						}
150
+					}
151
+
152
+					// 透后评估
153
+					for _, treatmentSummary := range treatmentSummarys {
154
+						if item.PatientId == treatmentSummary.PatientId {
155
+							scheduals[key].TreatmentSummary = treatmentSummary
156
+							break
157
+						}
158
+					}
159
+				}
160
+
161
+				//缓存数据
162
+				scheduals_json, err := json.Marshal(&scheduals)
163
+				if err == nil {
164
+					redis.Set(key, scheduals_json, time.Second*60)
165
+				}
166
+			}
167
+
168
+			this.ServeSuccessJSON(map[string]interface{}{
169
+				"schedules": scheduals,
170
+			})
171
+
172
+		}
173
+
174
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
175
+		var dat []map[string]interface{}
176
+
177
+		if err := json.Unmarshal([]byte(scheduals_json_str), &dat); err == nil {
178
+
179
+		} else {
180
+
181
+		}
182
+
82 183
 		this.ServeSuccessJSON(map[string]interface{}{
83
-			"schedules": schedules,
184
+			"schedules": dat,
84 185
 		})
186
+
85 187
 	}
188
+
189
+	//if err != nil {
190
+	//	this.ErrorLog("获取排班信息失败:%v", err)
191
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
192
+	//} else {
193
+	//	this.ServeSuccessJSON(map[string]interface{}{
194
+	//		"schedules": schedules,
195
+	//	})
196
+	//}
86 197
 }
87 198
 
88 199
 // /api/dislysis/schedule [get]
@@ -106,78 +217,108 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
106 217
 	}
107 218
 
108 219
 	adminInfo := this.GetAdminUserInfo()
109
-	patient, getPatientErr := service.MobileGetPatientDetail(adminInfo.CurrentOrgId, patientID)
110
-	if getPatientErr != nil {
111
-		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
112
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
113
-		return
114
-	} else if patient == nil {
115
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
116
-		return
117
-	}
220
+	ch := make(chan struct{})
221
+	count := 15 // count 表示活动的协程个数
222
+	var patient *service.MPatient
223
+	var schedual *service.MDialysisScheduleVM
224
+	var receiverTreatmentAccess *models.ReceiveTreatmentAsses
225
+	var predialysisEvaluation *models.PredialysisEvaluation
226
+	var doctorAdvices []*models.DoctorAdvice
227
+	var dialysisOrder *models.DialysisOrder
228
+	var doubleCheck *models.DoubleCheck
229
+	var monitorRecords []*models.MonitoringRecord
230
+	var assessmentAfterDislysis *models.AssessmentAfterDislysis
231
+	var treatmentSummary *models.TreatmentSummary
232
+	var record models.GobalConfig
233
+	var is_open_config models.XtHisConfig
234
+	var stockType []*models.GoodsTypeOne
235
+	var prepare []*models.XtDialysisBeforePrepare
236
+	var lastAssessment models.XtPatientVascularAccess
237
+	go func() {
238
+		patient, _ = service.MobileGetPatientDetail(adminInfo.CurrentOrgId, patientID)
239
+		ch <- struct{}{}
240
+	}()
118 241
 
119
-	schedual, getSchedualErr := service.MobileGetSchedualDetail(adminInfo.CurrentOrgId, patientID, date.Unix())
120
-	if getSchedualErr != nil {
121
-		this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
122
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
123
-		return
124
-	}
242
+	go func() {
243
+		schedual, _ = service.MobileGetSchedualDetail(adminInfo.CurrentOrgId, patientID, date.Unix())
244
+		ch <- struct{}{}
245
+	}()
125 246
 
126
-	receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
127
-	if getRTARErr != nil {
128
-		this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
129
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
130
-		return
131
-	}
247
+	go func() {
248
+		receiverTreatmentAccess, _ = service.MobileGetReceiverTreatmentAccessRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
249
+		ch <- struct{}{}
250
+	}()
132 251
 
133
-	predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminInfo.CurrentOrgId, patientID, date.Unix())
134
-	fmt.Println("predialysisEvaluatiotion", predialysisEvaluation)
135
-	if getPEErr != nil {
136
-		this.ErrorLog("获取透前评估失败:%v", getPEErr)
137
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
138
-		return
139
-	}
252
+	go func() {
253
+		predialysisEvaluation, _ = service.MobileGetPredialysisEvaluation(adminInfo.CurrentOrgId, patientID, date.Unix())
254
+		ch <- struct{}{}
255
+	}()
140 256
 
141
-	doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvices(adminInfo.CurrentOrgId, patientID, date.Unix())
142
-	if getDoctorAdvicesErr != nil {
143
-		this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
144
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
145
-		return
146
-	}
257
+	go func() {
258
+		doctorAdvices, _ = service.MobileGetDoctorAdvices(adminInfo.CurrentOrgId, patientID, date.Unix())
259
+		ch <- struct{}{}
260
+	}()
147 261
 
148
-	dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
149
-	if getDialysisOrderErr != nil {
150
-		this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
151
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
152
-		return
153
-	}
262
+	go func() {
263
+		dialysisOrder, _ = service.MobileGetSchedualDialysisRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
264
+		ch <- struct{}{}
265
+	}()
154 266
 
155
-	doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheck(adminInfo.CurrentOrgId, patientID, date.Unix())
156
-	if getDoubleCheckErr != nil {
157
-		this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
158
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
159
-		return
160
-	}
267
+	go func() {
268
+		doubleCheck, _ = service.MobileGetDoubleCheck(adminInfo.CurrentOrgId, patientID, date.Unix())
269
+		ch <- struct{}{}
270
+	}()
161 271
 
162
-	monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecords(adminInfo.CurrentOrgId, patientID, date.Unix())
163
-	if getMonitorRecordsErr != nil {
164
-		this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
165
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
166
-		return
167
-	}
272
+	go func() {
273
+		monitorRecords, _ = service.MobileGetMonitorRecords(adminInfo.CurrentOrgId, patientID, date.Unix())
274
+		ch <- struct{}{}
275
+	}()
168 276
 
169
-	assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminInfo.CurrentOrgId, patientID, date.Unix())
170
-	if getAADErr != nil {
171
-		this.ErrorLog("获取透后评估失败:%v", getAADErr)
172
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
173
-		return
174
-	}
277
+	go func() {
278
+		assessmentAfterDislysis, _ = service.MobileGetAssessmentAfterDislysis(adminInfo.CurrentOrgId, patientID, date.Unix())
279
+		ch <- struct{}{}
280
+	}()
175 281
 
176
-	treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummary(adminInfo.CurrentOrgId, patientID, date.Unix())
177
-	if getTreatmentSummaryErr != nil {
178
-		this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
179
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
180
-		return
282
+	go func() {
283
+		treatmentSummary, _ = service.MobileGetTreatmentSummary(adminInfo.CurrentOrgId, patientID, date.Unix())
284
+		ch <- struct{}{}
285
+	}()
286
+
287
+	go func() {
288
+		_, record = service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
289
+		ch <- struct{}{}
290
+	}()
291
+
292
+	go func() {
293
+		_, is_open_config = service.FindXTHisRecordByOrgId(adminInfo.CurrentOrgId)
294
+		ch <- struct{}{}
295
+	}()
296
+
297
+	go func() {
298
+		//获取耗材类型
299
+		stockType, _ = service.GetStockType(adminInfo.CurrentOrgId)
300
+		ch <- struct{}{}
301
+	}()
302
+
303
+	go func() {
304
+		prepare, _ = service.GetDialyStockOut(adminInfo.CurrentOrgId, date.Unix(), patientID)
305
+
306
+		ch <- struct{}{}
307
+	}()
308
+
309
+	go func() {
310
+		//获取患者的最后一次血管通路数据
311
+		lastAssessment, _ = service.GetLastPassWayAssessment(adminInfo.CurrentOrgId, patientID)
312
+		ch <- struct{}{}
313
+	}()
314
+
315
+	for range ch {
316
+		// 每次从ch中接收数据,表明一个活动的协程结束
317
+		count--
318
+		// 当所有活动的协程都结束时,关闭管道
319
+		if count == 0 {
320
+			close(ch)
321
+		}
181 322
 	}
182 323
 
183 324
 	admins, getAdminsErr := service.GetAllAdminUsers(adminInfo.CurrentOrgId, adminInfo.CurrentAppId)
@@ -223,39 +364,19 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
223 364
 	}
224 365
 
225 366
 	dialysisPrescribe, _ := service.GetDialysisPrescribe(adminInfo.CurrentOrgId, patientID, date.Unix())
226
-	//if getDialysisPrescribeErr != nil {
227
-	//	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
228
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
229
-	//	return
230
-	//}
231
-	dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
232
-	//dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolutionOne(adminInfo.CurrentOrgId, schedual.ModeId)
233 367
 
234
-	if getDialysisSolutionErr != nil {
235
-		this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
236
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
237
-		return
238
-	}
368
+	dialysisSolution, _ := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
239 369
 
240
-	lastDialysisPrescribe, _ := service.GetLastDialysisPrescribeByModeId(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
241
-	//if getDialysisPrescribeErr != nil {
242
-	//	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
370
+	//
371
+	//if getDialysisSolutionErr != nil {
372
+	//	this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
243 373
 	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
244 374
 	//	return
245 375
 	//}
246 376
 
247
-	systemDialysisPrescribe, _ := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
248
-	//if getSystemDialysisPrescribeErr != nil {
249
-	//	this.ErrorLog("获取系统透析处方失败:%v", getSystemDialysisPrescribeErr)
250
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
251
-	//	return
252
-	//}
377
+	lastDialysisPrescribe, _ := service.GetLastDialysisPrescribeByModeId(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
253 378
 
254
-	if getLPEErr != nil {
255
-		this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
256
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
257
-		return
258
-	}
379
+	systemDialysisPrescribe, _ := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
259 380
 
260 381
 	lastDryWeightDislysis, getDryErr := service.GetLastDryWeight(adminInfo.CurrentOrgId, patientID)
261 382
 	if getDryErr != nil {
@@ -266,23 +387,12 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
266 387
 
267 388
 	headNurses, _ := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
268 389
 
269
-	_, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
270
-
271
-	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.CurrentOrgId)
272
-
273
-	//获取耗材类型
274
-	stockType, _ := service.GetStockType(adminInfo.CurrentOrgId)
275
-
276
-	prepare, _ := service.GetDialyStockOut(adminInfo.CurrentOrgId, date.Unix(), patientID)
277
-
278 390
 	var his_advices []*models.HisDoctorAdviceInfo
391
+	fmt.Println("hhh2333223322323223", is_open_config.IsOpen)
279 392
 	if is_open_config.IsOpen == 1 {
280 393
 		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
281 394
 	}
282 395
 
283
-	//获取患者的最后一次血管通路数据
284
-	lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.CurrentOrgId, patientID)
285
-
286 396
 	returnData := map[string]interface{}{
287 397
 		"patient":                     patient,
288 398
 		"schedual":                    schedual,
@@ -486,6 +596,7 @@ func (this *DialysisRecordAPIController) EditMonitor() {
486 596
 		defer redis.Close()
487 597
 		//清空key 值
488 598
 		redis.Set(key, "", time.Second)
599
+
489 600
 		if createErr != nil {
490 601
 			this.ErrorLog("创建监测记录失败:%v", createErr)
491 602
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -558,6 +669,11 @@ func (this *DialysisRecordAPIController) EditMonitor() {
558 669
 		monitor.BloodThickness = monitorParam.BloodThickness
559 670
 		monitor.BloodMonitor = monitorParam.BloodMonitor
560 671
 		updateErr := service.UpdateMonitor(monitor)
672
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
673
+		redis := service.RedisClient()
674
+		defer redis.Close()
675
+		//清空key 值
676
+		redis.Set(key, "", time.Second)
561 677
 		if updateErr != nil {
562 678
 			this.ErrorLog("修改透析监测记录失败:%v", updateErr)
563 679
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -772,6 +888,10 @@ func (this *DialysisRecordAPIController) StartDialysis() {
772 888
 	defer redis.Close()
773 889
 	//清空key 值
774 890
 	redis.Set(key, "", time.Second)
891
+
892
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
893
+	redis.Set(keyOne, "", time.Second)
894
+
775 895
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
776 896
 
777 897
 	if createErr != nil {
@@ -829,7 +949,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
829 949
 						fmt.Println("ultrafiltration_rate", ultrafiltration_rate)
830 950
 					}
831 951
 				}
832
-				fmt.Println("hhh233223323223232332233233223323223323232322332322323", adminUserInfo.CurrentOrgId)
952
+
833 953
 				//针对肇庆三鹤血液透析中心
834 954
 				if adminUserInfo.CurrentOrgId == 10215 || template.TemplateId == 43 {
835 955
 
@@ -1099,6 +1219,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1099 1219
 	}
1100 1220
 
1101 1221
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1222
+
1102 1223
 	if err != nil {
1103 1224
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1104 1225
 		return
@@ -1115,6 +1236,15 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1115 1236
 	}()
1116 1237
 
1117 1238
 	updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1239
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1240
+	redis := service.RedisClient()
1241
+	defer redis.Close()
1242
+	//清空key 值
1243
+	redis.Set(key, "", time.Second)
1244
+
1245
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
1246
+	redis.Set(keyOne, "", time.Second)
1247
+
1118 1248
 	if updateErr != nil {
1119 1249
 		this.ErrorLog("下机失败:%v", updateErr)
1120 1250
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1127,6 +1257,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1127 1257
 		dialysisRecord.EndTime = endDate.Unix()
1128 1258
 		// 结束时候透析次数加1
1129 1259
 		service.UpdateSolutionByPatientId(patientID)
1260
+
1130 1261
 		this.ServeSuccessJSON(map[string]interface{}{
1131 1262
 			"dialysis_order":          dialysisRecord,
1132 1263
 			"assessmentAfterDislysis": tempassessmentAfterDislysis,
@@ -1365,6 +1496,15 @@ func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
1365 1496
 	}
1366 1497
 
1367 1498
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
1499
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
1500
+	redis := service.RedisClient()
1501
+	defer redis.Close()
1502
+	//清空key 值
1503
+	redis.Set(key, "", time.Second)
1504
+
1505
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
1506
+	redis.Set(keyOne, "", time.Second)
1507
+
1368 1508
 	if updateErr != nil {
1369 1509
 		c.ErrorLog("修改下机失败:%v", updateErr)
1370 1510
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)

+ 293 - 253
controllers/his_api_controller.go View File

@@ -559,189 +559,53 @@ func (c *HisApiController) GetHisPatientInfo() {
559 559
 	return
560 560
 
561 561
 }
562
+
562 563
 func (c *HisApiController) GetHisPrescriptionConfig() {
563 564
 	adminInfo := c.GetAdminUserInfo()
564 565
 	//获取医嘱模版
565
-	//advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
566
+	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
566 567
 	//获取所有基础药
568
+	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
567 569
 
568
-	drugways_keys := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + "_drugways"
569
-	efs_keys := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + "_efs"
570
-	//doctors_keys := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + "_doctors"
571
-	department_keys := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + "_department"
572
-	sick_keys := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + "_sick"
573
-	diagnose_keys := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + "_diagnose"
574
-
575
-	redis := service.RedisClient()
576
-	defer redis.Close()
577
-	drugways_str, _ := redis.Get(drugways_keys).Result()
578
-	efs_str, _ := redis.Get(efs_keys).Result()
579
-	//doctors_str, _ := redis.Get(doctors_keys).Result()
580
-	department_str, _ := redis.Get(department_keys).Result()
581
-	sick_str, _ := redis.Get(sick_keys).Result()
582
-	diagnose_str, _ := redis.Get(diagnose_keys).Result()
583
-
584
-	var drugways []*models.DrugwayDic
585
-	var efs []*models.ExecutionFrequencyDic
586
-	var roles []*models.UserAdminRole
587
-	var departments []*models.XtHisDepartment
588
-	var sicks []*models.OutpatientServiceSick
589
-	var diagnose []*models.HisXtDiagnoseConfig
590
-
591
-	if len(drugways_str) == 0 {
592
-		drugways, _, _ = service.GetDrugWayDics(adminInfo.CurrentOrgId)
593
-		drugways_str, err := json.Marshal(drugways)
594
-		if err == nil {
595
-			redis.Set(drugways_keys, string(drugways_str), time.Second*60*60*18)
596
-
597
-		} else {
598
-			redis.Set(drugways_keys, "", time.Second*60*60*18)
599
-
600
-		}
601
-
602
-	} else {
603
-		err := json.Unmarshal([]byte(drugways_str), &drugways)
604
-		if err != nil {
605
-			drugways, _, _ = service.GetDrugWayDics(adminInfo.CurrentOrgId)
606
-			drugways_str, err := json.Marshal(drugways)
607
-			if err == nil {
608
-				redis.Set(drugways_keys, string(drugways_str), time.Second*60*60*18)
609
-
610
-			} else {
611
-				redis.Set(drugways_keys, "", time.Second*60*60*18)
612
-
613
-			}
614
-
615
-		}
616
-
617
-	}
618
-	if len(efs_str) == 0 {
619
-		efs, _, _ = service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
620
-		efs_str, err := json.Marshal(efs)
621
-		if err == nil {
622
-
623
-			redis.Set(efs_keys, string(efs_str), time.Second*60*60*18)
624
-
625
-		} else {
626
-
627
-			redis.Set(efs_keys, "", time.Second*60*60*18)
628
-
629
-		}
630
-	} else {
631
-		err := json.Unmarshal([]byte(efs_str), &efs)
632
-		if err != nil {
633
-			efs, _, _ = service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
634
-			efs_str, err := json.Marshal(efs)
635
-			if err == nil {
636
-
637
-				redis.Set(efs_keys, string(efs_str), time.Second*60*60*18)
638
-
639
-			} else {
640
-
641
-				redis.Set(efs_keys, "", time.Second*60*60*18)
642
-
570
+	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
571
+	if config.ID > 0 && config.IsOpen == 1 {
572
+		for _, item := range drugs {
573
+			var index = 0
574
+			for _, subItem := range item.OtherDrugWarehouseInfo {
575
+				if index == 0 {
576
+					if subItem.StockMaxNumber*item.MinNumber+subItem.StockMinNumber > 0 {
577
+						index = index + 1
578
+						item.MinPrice = subItem.Price
579
+					}
580
+				}
643 581
 			}
644 582
 		}
645 583
 	}
646 584
 
647
-	//if len(doctors_str) == 0 {
648
-	//	roles, _ = service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
649
-	//	doctors_str, err := json.Marshal(roles)
650
-	//	if err == nil {
651
-	//		redis.Set(doctors_keys, string(doctors_str), time.Second*60*60*18)
652
-	//	} else {
653
-	//		redis.Set(doctors_keys, "", time.Second*60*60*18)
654
-	//	}
655
-	//
656
-	//} else {
657
-	//	err := json.Unmarshal([]byte(doctors_str), &efs)
658
-	//	if err != nil {
659
-	//		roles, _ = service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
660
-	//		doctors_str, err := json.Marshal(roles)
661
-	//		if err == nil {
662
-	//			redis.Set(doctors_keys, string(doctors_str), time.Second*60*60*18)
663
-	//		} else {
664
-	//			redis.Set(doctors_keys, "", time.Second*60*60*18)
665
-	//		}
666
-	//
667
-	//	}
668
-	//}
669
-
670
-	if len(department_str) == 0 {
671
-		departments, _ = service.GetAllDepartMent(adminInfo.CurrentOrgId)
672
-		department_str, err := json.Marshal(departments)
673
-		if err == nil {
674
-			redis.Set(department_keys, string(department_str), time.Second*60*60*18)
675
-		} else {
676
-			redis.Set(department_keys, "", time.Second*60*60*18)
677
-		}
678
-	} else {
679
-		err := json.Unmarshal([]byte(department_str), &departments)
680
-		if err != nil {
681
-			departments, _ = service.GetAllDepartMent(adminInfo.CurrentOrgId)
682
-			department_str, _ := json.Marshal(departments)
683
-			redis.Set(department_keys, string(department_str), time.Second*60*60*18)
684
-		}
685
-	}
686
-
687
-	if len(sick_str) == 0 {
688
-		sicks, _ = service.FindAllSick(adminInfo.CurrentOrgId)
689
-		sick_str, err := json.Marshal(sicks)
690
-		if err == nil {
691
-			redis.Set(sick_keys, string(sick_str), time.Second*60*60*18)
692
-		} else {
693
-			redis.Set(sick_keys, "", time.Second*60*60*18)
694
-		}
585
+	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
586
+	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
587
+	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
588
+	//获取所有科室信息
589
+	department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
695 590
 
696
-	} else {
697
-		err := json.Unmarshal([]byte(sick_str), &sicks)
698
-		if err != nil {
699
-			sicks, _ = service.FindAllSick(adminInfo.CurrentOrgId)
700
-			sick_str, _ := json.Marshal(sicks)
701
-			redis.Set(sick_keys, string(sick_str), time.Second*60*60*18)
591
+	//获取诊断信息
702 592
 
703
-		}
593
+	sick, _ := service.FindAllSick(adminInfo.CurrentOrgId)
704 594
 
705
-	}
706
-
707
-	if len(diagnose_str) == 0 {
708
-		diagnose, _ = service.FindAllDiagnose(adminInfo.CurrentOrgId)
709
-		diagnose_str, err := json.Marshal(diagnose)
710
-		if err == nil {
711
-			redis.Set(diagnose_keys, string(diagnose_str), time.Second*60*60*18)
712
-		} else {
713
-			redis.Set(diagnose_keys, "", time.Second*60*60*18)
714
-		}
715
-	} else {
716
-		err := json.Unmarshal([]byte(diagnose_str), &sicks)
717
-		if err != nil {
718
-			diagnose, _ = service.FindAllDiagnose(adminInfo.CurrentOrgId)
719
-			diagnose_str, err := json.Marshal(diagnose)
720
-			if err == nil {
721
-				redis.Set(diagnose_keys, string(diagnose_str), time.Second*60*60*18)
722
-			} else {
723
-				redis.Set(diagnose_keys, "", time.Second*60*60*18)
724
-			}
725
-		}
726
-	}
727
-
728
-	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
729
-	roles, _ = service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
730
-	//获取所有科室信息
731
-	//获取诊断信息
595
+	diagnose, _ := service.FindAllDiagnose(adminInfo.CurrentOrgId)
732 596
 
733 597
 	additions, _ := service.FindAllAddition(adminInfo.CurrentOrgId)
734 598
 
735 599
 	c.ServeSuccessJSON(map[string]interface{}{
736
-		"drugs": drugs,
737
-		//"advices_template": advices,
738
-		"drugways":   drugways,
739
-		"efs":        efs,
740
-		"doctors":    roles,
741
-		"department": departments,
742
-		"sick":       sicks,
743
-		"additions":  additions,
744
-		"diagnose":   diagnose,
600
+		"drugs":            drugs,
601
+		"advices_template": advices,
602
+		"drugways":         drugways,
603
+		"efs":              efs,
604
+		"doctors":          doctors,
605
+		"department":       department,
606
+		"sick":             sick,
607
+		"additions":        additions,
608
+		"diagnose":         diagnose,
745 609
 	})
746 610
 }
747 611
 func (c *HisApiController) CreateHisPrescription() {
@@ -784,8 +648,10 @@ func (c *HisApiController) CreateHisPrescription() {
784 648
 
785 649
 	}
786 650
 
787
-	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
651
+	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
788 652
 
653
+	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
654
+	fmt.Println("drugStockConfig94394343344334344343434334", drugStockConfig)
789 655
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
790 656
 
791 657
 	if drugStockConfig.IsOpen == 1 {
@@ -823,8 +689,17 @@ func (c *HisApiController) CreateHisPrescription() {
823 689
 									return
824 690
 								}
825 691
 
692
+								//查询药品的搜有库存
693
+								list, _ := service.GetDrugWarehouseInfoPrescription(drug_id, adminInfo.CurrentOrgId)
694
+								var total_count int64
695
+								for _, it := range list {
696
+									total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
697
+								}
698
+								totals := strconv.FormatInt(total_count, 10)
699
+								all_count, _ := strconv.ParseFloat(totals, 64)
700
+								fmt.Println("all_count2323323233232", all_count)
826 701
 								if prescribingNumberUnit == drug.MinUnit {
827
-									if prescribing_number > drug.Total {
702
+									if prescribing_number > all_count {
828 703
 										c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
829 704
 										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
830 705
 										return
@@ -832,13 +707,14 @@ func (c *HisApiController) CreateHisPrescription() {
832 707
 								} else {
833 708
 									if prescribingNumberUnit == drug.MaxUnit {
834 709
 										num := prescribing_number * float64(drug.MinNumber)
835
-										if num > drug.Total {
710
+										if num > all_count {
836 711
 											c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
837 712
 											//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
838 713
 											return
839 714
 										}
840 715
 									}
841 716
 								}
717
+
842 718
 							}
843 719
 						}
844 720
 					}
@@ -877,9 +753,17 @@ func (c *HisApiController) CreateHisPrescription() {
877 753
 										c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
878 754
 										return
879 755
 									}
880
-									if totals > good.Total {
756
+									//查询耗材库存
757
+									list, _ := service.GetGoodWarehouseInfo(project_id)
758
+									var stock_count int64
759
+									for _, it := range list {
760
+										stock_count += it.StockCount
761
+									}
762
+									stock_counts := strconv.FormatInt(stock_count, 10)
763
+									stock_total_count, _ := strconv.ParseFloat(stock_counts, 64)
764
+									if totals > stock_total_count {
881 765
 										c.ServeDynamicFailJsonSend(good.GoodName + "库存不足")
882
-										//c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
766
+
883 767
 										return
884 768
 									}
885 769
 
@@ -891,7 +775,6 @@ func (c *HisApiController) CreateHisPrescription() {
891 775
 				}
892 776
 			}
893 777
 		}
894
-
895 778
 	}
896 779
 
897 780
 	info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
@@ -977,10 +860,10 @@ func (c *HisApiController) CreateHisPrescription() {
977 860
 				}
978 861
 				types := int64(items["type"].(float64))
979 862
 
980
-				if items["order_status"] == nil || reflect.TypeOf(items["order_status"]).String() != "float64" {
981
-					utils.ErrorLog("order_status")
982
-				}
983
-				order_status := int64(items["order_status"].(float64))
863
+				//if items["order_status"] == nil || reflect.TypeOf(items["order_status"]).String() != "float64" {
864
+				//	utils.ErrorLog("order_status")
865
+				//}
866
+				//order_status := int64(items["order_status"].(float64))
984 867
 
985 868
 				if items["med_type"] == nil || reflect.TypeOf(items["med_type"]).String() != "float64" {
986 869
 					utils.ErrorLog("med_type")
@@ -993,9 +876,9 @@ func (c *HisApiController) CreateHisPrescription() {
993 876
 					med_type = "14"
994 877
 				}
995 878
 
996
-				if order_status == 0 {
997
-					order_status = 1
998
-				}
879
+				//if order_status == 0 {
880
+				//	order_status = 1
881
+				//}
999 882
 
1000 883
 				if items["pre_time"] == nil || reflect.TypeOf(items["pre_time"]).String() != "string" {
1001 884
 					utils.ErrorLog("pre_time")
@@ -1027,7 +910,7 @@ func (c *HisApiController) CreateHisPrescription() {
1027 910
 						Status:             1,
1028 911
 						Doctor:             role.UserName,
1029 912
 						HisPatientId:       his_patient_id,
1030
-						OrderStatus:        order_status,
913
+						OrderStatus:        1,
1031 914
 						BatchNumber:        "",
1032 915
 						PrescriptionNumber: hpInfo.PrescriptionNumber,
1033 916
 						PreTime:            pTime,
@@ -1043,7 +926,7 @@ func (c *HisApiController) CreateHisPrescription() {
1043 926
 					tempPrescription.Modifier = adminInfo.AdminUser.Id
1044 927
 					tempPrescription.Mtime = time.Now().Unix()
1045 928
 					tempPrescription.Doctor = role.UserName
1046
-					tempPrescription.OrderStatus = order_status
929
+					//tempPrescription.OrderStatus = order_status
1047 930
 					tempPrescription.PreTime = pTime
1048 931
 					tempPrescription.MedType = med_type
1049 932
 					service.SaveHisPrescription(tempPrescription)
@@ -1077,6 +960,7 @@ func (c *HisApiController) CreateHisPrescription() {
1077 960
 							s.PatientId = patient_id
1078 961
 							s.HisPatientId = his_patient_id
1079 962
 							s.StartTime = pTime
963
+
1080 964
 							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
1081 965
 							if errcode > 0 {
1082 966
 								c.ServeFailJSONWithSGJErrorCode(errcode)
@@ -1085,6 +969,10 @@ func (c *HisApiController) CreateHisPrescription() {
1085 969
 
1086 970
 							s.StartTime = pTime
1087 971
 							service.CreateHisDoctorAdvice(&s)
972
+							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
973
+							redis := service.RedisClient()
974
+							redis.Set(key, "", time.Second)
975
+							defer redis.Close()
1088 976
 							var randNum int
1089 977
 							randNum = rand.Intn(10000) + 1000
1090 978
 							timestamp := time.Now().Unix()
@@ -1092,7 +980,8 @@ func (c *HisApiController) CreateHisPrescription() {
1092 980
 							timeFormat := tempTime.Format("20060102150405")
1093 981
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
1094 982
 							service.CreateHisDoctorAdvice(&s)
1095
-
983
+							keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
984
+							redis.Set(keyOne, "", time.Second)
1096 985
 						}
1097 986
 					}
1098 987
 				}
@@ -1117,23 +1006,74 @@ func (c *HisApiController) CreateHisPrescription() {
1117 1006
 								c.ServeFailJSONWithSGJErrorCode(errcode)
1118 1007
 								return
1119 1008
 							}
1120
-							service.CreateHisProjectTwo(&p)
1121 1009
 
1010
+							service.CreateHisProjectTwo(&p)
1122 1011
 							var randNum int
1123 1012
 							randNum = rand.Intn(10000) + 1000
1124 1013
 							timestamp := time.Now().Unix()
1125 1014
 							tempTime := time.Unix(timestamp, 0)
1126 1015
 							timeFormat := tempTime.Format("20060102150405")
1127 1016
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
1017
+
1018
+							//新增或者编辑项目,修改对应的标签数据
1019
+							labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
1020
+							if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
1021
+								var label models.HisLabelPrintInfo
1022
+								project, _ := service.GetProjectDetail(p.ProjectId)
1023
+								if project.CostClassify == 3 { //类别为检验检查
1024
+									if p.TeamId > 0 { //检验检查组套
1025
+										tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
1026
+										if tempLabel.ID == 0 {
1027
+											team, _ := service.GetProjectTeamDetail(p.TeamId)
1028
+											label.Number = tempPrescription.PrescriptionNumber
1029
+											label.ProjectId = project.ID
1030
+											label.Status = 1
1031
+											label.IsPrint = 2
1032
+											label.DoctorId = info.DoctorId
1033
+											label.UserOrgId = p.UserOrgId
1034
+											label.PatientId = patient_id
1035
+											label.RecordDate = recordDateTime
1036
+											label.Ctime = time.Now().Unix()
1037
+											label.Mtime = time.Now().Unix()
1038
+											label.ItemId = p.TeamId
1039
+											label.FeedetlSn = p.FeedetlSn
1040
+											label.PProjectId = p.ID
1041
+											label.ProjectName = team.ProjectTeam
1042
+											label.PatientName = patient.Name
1043
+											service.CreateHisLabelRecord(&label)
1044
+										}
1045
+									} else { //单条检验检查项目
1046
+										label.Number = tempPrescription.PrescriptionNumber
1047
+										label.ProjectId = project.ID
1048
+										label.Status = 1
1049
+										label.DoctorId = info.DoctorId
1050
+										label.UserOrgId = p.UserOrgId
1051
+										label.PatientId = patient_id
1052
+										label.RecordDate = recordDateTime
1053
+										label.IsPrint = 2
1054
+										label.Ctime = time.Now().Unix()
1055
+										label.Mtime = time.Now().Unix()
1056
+										label.FeedetlSn = p.FeedetlSn
1057
+										label.PProjectId = p.ID
1058
+										label.ItemId = p.TeamId
1059
+										label.ProjectName = project.ProjectName
1060
+										label.PatientName = patient.Name
1061
+										service.CreateHisLabelRecord(&label)
1062
+									}
1063
+								}
1064
+							}
1065
+
1128 1066
 							service.SaveHisProjectTwo(&p)
1129 1067
 
1130 1068
 							if p.Type == 3 { //处理透前准备耗材数量数据
1131 1069
 								consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
1132 1070
 								if consumables.ID > 0 {
1133
-									consumables.Count = int64(p.Count)
1071
+									cnt, _ := strconv.ParseInt(p.Count, 10, 64)
1072
+									consumables.Count = cnt
1134 1073
 									service.UpdateConsumables(&consumables)
1135 1074
 								}
1136 1075
 							}
1076
+
1137 1077
 						}
1138 1078
 					}
1139 1079
 				}
@@ -1443,10 +1383,12 @@ func (c *HisApiController) DeletePrescription() {
1443 1383
 	if err == nil {
1444 1384
 		if len(projects) > 0 {
1445 1385
 			for _, item := range projects {
1386
+				service.DeletePrintInfo(item.ID) //删除打印信息
1446 1387
 				if stockConfig.IsOpen == 1 {
1447 1388
 					if item.Type == 3 {
1448 1389
 						good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
1449
-						f_count, _ := strconv.ParseFloat(strconv.FormatInt(int64(item.Count), 10), 64)
1390
+						//cnt, _ := strconv.ParseInt(item.Count, 10, 64)
1391
+						f_count, _ := strconv.ParseFloat(item.Count, 64)
1450 1392
 						good.Total = good.Total + f_count
1451 1393
 						service.UpdateGoodInfo(&good)
1452 1394
 					}
@@ -1531,10 +1473,16 @@ func (c *HisApiController) DeleteProject() {
1531 1473
 	}
1532 1474
 	err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
1533 1475
 	if err == nil {
1476
+		service.DeletePrintInfo(id)
1477
+		label, _ := service.GetProjectById(adminInfo.CurrentOrgId, id, project.RecordDate, project.PatientId)
1478
+		label.Status = 0
1479
+		service.CreateHisLabelRecord(&label)
1480
+
1534 1481
 		if stockConfig.IsOpen == 1 {
1535 1482
 			if project.Type == 3 {
1536 1483
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
1537
-				f_count, _ := strconv.ParseFloat(strconv.FormatInt(int64(project.Count), 10), 64)
1484
+
1485
+				f_count, _ := strconv.ParseFloat(project.Count, 64)
1538 1486
 				good.Total = good.Total + f_count
1539 1487
 				service.UpdateGoodInfo(&good)
1540 1488
 			}
@@ -2032,8 +1980,7 @@ func (c *HisApiController) setProjectWithJSONTwo(project *models.HisPrescription
2032 1980
 
2033 1981
 	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
2034 1982
 		total, _ := json["total"].(string)
2035
-		totals, _ := strconv.ParseInt(total, 10, 64)
2036
-		project.Count = totals
1983
+		project.Count = total
2037 1984
 	}
2038 1985
 
2039 1986
 	if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
@@ -2179,6 +2126,41 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
2179 2126
 	//	advice.WeekDay = week_day
2180 2127
 	//}
2181 2128
 
2129
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
2130
+		drugSpecUnit, _ := json["min_unit"].(string)
2131
+		advice.DrugSpecUnit = drugSpecUnit
2132
+	}
2133
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
2134
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
2135
+		advice.SingleDose = singleDose
2136
+	}
2137
+	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
2138
+		singleDoseUnit, _ := json["single_dose_unit"].(string)
2139
+		advice.SingleDoseUnit = singleDoseUnit
2140
+	}
2141
+
2142
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
2143
+		deliveryWay, _ := json["delivery_way"].(string)
2144
+		advice.DeliveryWay = deliveryWay
2145
+	}
2146
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
2147
+		executionFrequency, _ := json["execution_frequency"].(string)
2148
+		advice.ExecutionFrequency = executionFrequency
2149
+	}
2150
+
2151
+	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
2152
+		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
2153
+		advice.Price = price
2154
+	}
2155
+	if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
2156
+		med_list_codg, _ := json["medical_insurance_number"].(string)
2157
+		advice.MedListCodg = med_list_codg
2158
+	}
2159
+	if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
2160
+		day := int64(json["day"].(float64))
2161
+		advice.Day = day
2162
+	}
2163
+
2182 2164
 	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
2183 2165
 		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
2184 2166
 		advice.PrescribingNumberUnit = prescribingNumberUnit
@@ -2191,6 +2173,7 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
2191 2173
 			hisAdvice, err := service.GetHisDoctorAdvicesById(advice.ID)
2192 2174
 			if err == nil {
2193 2175
 				if hisAdvice.ID > 0 {
2176
+
2194 2177
 					advice.ExecutionTime = hisAdvice.ExecutionTime
2195 2178
 					advice.ExecutionStaff = hisAdvice.ExecutionStaff
2196 2179
 					advice.ExecutionState = hisAdvice.ExecutionState
@@ -2199,6 +2182,16 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
2199 2182
 					advice.CheckState = hisAdvice.CheckState
2200 2183
 					advice.StartTime = hisAdvice.StartTime
2201 2184
 					advice.HospApprFlag = hisAdvice.HospApprFlag
2185
+
2186
+					if hisAdvice.SingleDose != advice.SingleDose || hisAdvice.DeliveryWay != advice.DeliveryWay || hisAdvice.ExecutionFrequency != advice.ExecutionFrequency || hisAdvice.Day != advice.Day || hisAdvice.PrescribingNumber != advice.PrescribingNumber || hisAdvice.Price != advice.Price || hisAdvice.Remark != advice.Remark {
2187
+						advice.ExecutionTime = 0
2188
+						advice.ExecutionStaff = 0
2189
+						advice.ExecutionState = 2
2190
+						advice.CheckTime = 0
2191
+						advice.Checker = 0
2192
+						advice.CheckState = 2
2193
+					}
2194
+
2202 2195
 					//advice.Groupno = hisAdvice.Groupno
2203 2196
 
2204 2197
 				}
@@ -2326,40 +2319,6 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
2326 2319
 	//	advice.StartTime = start_time
2327 2320
 	//}
2328 2321
 
2329
-	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
2330
-		drugSpecUnit, _ := json["min_unit"].(string)
2331
-		advice.DrugSpecUnit = drugSpecUnit
2332
-	}
2333
-	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
2334
-		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
2335
-		advice.SingleDose = singleDose
2336
-	}
2337
-	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
2338
-		singleDoseUnit, _ := json["single_dose_unit"].(string)
2339
-		advice.SingleDoseUnit = singleDoseUnit
2340
-	}
2341
-
2342
-	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
2343
-		deliveryWay, _ := json["delivery_way"].(string)
2344
-		advice.DeliveryWay = deliveryWay
2345
-	}
2346
-	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
2347
-		executionFrequency, _ := json["execution_frequency"].(string)
2348
-		advice.ExecutionFrequency = executionFrequency
2349
-	}
2350
-
2351
-	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
2352
-		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
2353
-		advice.Price = price
2354
-	}
2355
-	if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
2356
-		med_list_codg, _ := json["medical_insurance_number"].(string)
2357
-		advice.MedListCodg = med_list_codg
2358
-	}
2359
-	if json["day"] != nil || reflect.TypeOf(json["day"]).String() == "float64" {
2360
-		day := int64(json["day"].(float64))
2361
-		advice.Day = day
2362
-	}
2363 2322
 	return 0
2364 2323
 }
2365 2324
 
@@ -2406,8 +2365,8 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
2406 2365
 
2407 2366
 	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
2408 2367
 		total, _ := json["total"].(string)
2409
-		totals, _ := strconv.ParseInt(total, 10, 64)
2410
-		project.Count = totals
2368
+		//totals, _ := strconv.ParseInt(total, 10, 64)
2369
+		project.Count = total
2411 2370
 	}
2412 2371
 
2413 2372
 	if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
@@ -2463,7 +2422,7 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
2463 2422
 		if stockConfig.IsOpen == 1 {
2464 2423
 			if project.Type == 3 {
2465 2424
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2466
-				f_count, _ := strconv.ParseFloat(strconv.FormatInt(int64(project.Count), 10), 64)
2425
+				f_count, _ := strconv.ParseFloat(project.Count, 64)
2467 2426
 				good.Total = good.Total - f_count
2468 2427
 				service.UpdateGoodInfo(&good)
2469 2428
 			}
@@ -2476,12 +2435,18 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
2476 2435
 			if project.Type == 3 {
2477 2436
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
2478 2437
 				if project.Count < temp_project.Count {
2479
-					other_count := temp_project.Count - project.Count
2438
+					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
2439
+					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
2440
+
2441
+					other_count := f_count_two - f_count_one
2480 2442
 					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
2481 2443
 					good.Total = good.Total + other_count_two
2482 2444
 					service.UpdateGoodInfo(&good)
2483 2445
 				} else if project.Count > temp_project.Count {
2484
-					other_count := project.Count - temp_project.Count
2446
+					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
2447
+					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
2448
+
2449
+					other_count := f_count_one - f_count_two
2485 2450
 					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
2486 2451
 					good.Total = good.Total - other_count_two
2487 2452
 					service.UpdateGoodInfo(&good)
@@ -3287,13 +3252,15 @@ func (c *HisApiController) GetUploadInfo() {
3287 3252
 	if tempOrder.ID == 0 {
3288 3253
 		if settle_accounts_type == 1 { //日结
3289 3254
 			fmt.Println(reg_type)
3290
-			if reg_type == 11 {
3291
-				fmt.Println(reg_type)
3255
+
3256
+			if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
3257
+
3292 3258
 				prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
3293 3259
 			} else {
3294 3260
 				prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
3295 3261
 			}
3296 3262
 		} else { //月结
3263
+
3297 3264
 			start_time_str := c.GetString("start_time")
3298 3265
 			end_time_str := c.GetString("end_time")
3299 3266
 			timeLayout := "2006-01-02"
@@ -3338,7 +3305,8 @@ func (c *HisApiController) GetUploadInfo() {
3338 3305
 			}
3339 3306
 			if item.Type == 2 { //项目
3340 3307
 				for _, subItem := range item.HisPrescriptionProject {
3341
-					total = total + (subItem.Price * float64(subItem.Count))
3308
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
3309
+					total = total + (subItem.Price * cnt)
3342 3310
 				}
3343 3311
 			}
3344 3312
 
@@ -3347,7 +3315,11 @@ func (c *HisApiController) GetUploadInfo() {
3347 3315
 			}
3348 3316
 		}
3349 3317
 
3350
-		allTotal := fmt.Sprintf("%.2f", total)
3318
+		if reg_type == 1111 || reg_type == 1112 {
3319
+			reg_type = 11
3320
+		}
3321
+
3322
+		allTotal := fmt.Sprintf("%.4f", total)
3351 3323
 		totals, _ := strconv.ParseFloat(allTotal, 64)
3352 3324
 		order := &models.HisOrder{
3353 3325
 			UserOrgId:             adminUser.CurrentOrgId,
@@ -3392,8 +3364,8 @@ func (c *HisApiController) GetUploadInfo() {
3392 3364
 					cus := &Custom{
3393 3365
 						AdviceId:         subItem.ID,
3394 3366
 						ProjectId:        0,
3395
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
3396
-						Cut:              fmt.Sprintf("%.2f", subItem.PrescribingNumber),
3367
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
3368
+						Cut:              fmt.Sprintf("%.4f", subItem.PrescribingNumber),
3397 3369
 						FeedetlSn:        subItem.FeedetlSn,
3398 3370
 						Price:            fmt.Sprintf("%.2f", subItem.Price),
3399 3371
 						MedListCodg:      subItem.MedListCodg,
@@ -3404,13 +3376,14 @@ func (c *HisApiController) GetUploadInfo() {
3404 3376
 			}
3405 3377
 			if item.Type == 2 { //项目
3406 3378
 				for _, subItem := range item.HisPrescriptionProject {
3379
+					cnt, _ := strconv.ParseFloat(subItem.Count, 64)
3407 3380
 					cus := &Custom{
3408 3381
 						AdviceId:         0,
3409 3382
 						ProjectId:        subItem.ID,
3410
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
3411
-						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
3383
+						DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
3384
+						Cut:              fmt.Sprintf("%.4f", cnt),
3412 3385
 						FeedetlSn:        subItem.FeedetlSn,
3413
-						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
3386
+						Price:            fmt.Sprintf("%.4f", float64(subItem.Price)),
3414 3387
 						MedListCodg:      subItem.MedListCodg,
3415 3388
 						Type:             2,
3416 3389
 					}
@@ -3422,10 +3395,10 @@ func (c *HisApiController) GetUploadInfo() {
3422 3395
 					ItemId:           item.ID,
3423 3396
 					AdviceId:         0,
3424 3397
 					ProjectId:        0,
3425
-					DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
3426
-					Cut:              fmt.Sprintf("%.2f", float64(item.Count)),
3398
+					DetItemFeeSumamt: fmt.Sprintf("%.4f", item.Price),
3399
+					Cut:              fmt.Sprintf("%.4f", float64(item.Count)),
3427 3400
 					FeedetlSn:        item.FeedetlSn,
3428
-					Price:            fmt.Sprintf("%.2f", float64(item.Price)),
3401
+					Price:            fmt.Sprintf("%.4f", float64(item.Price)),
3429 3402
 					MedListCodg:      item.XtHisAddtionConfig.Code,
3430 3403
 					Type:             3,
3431 3404
 				}
@@ -5112,7 +5085,7 @@ func (c *HisApiController) PreSettle() {
5112 5085
 
5113 5086
 	if settle_accounts_type == 1 { //日结
5114 5087
 
5115
-		if reg_type == 11 {
5088
+		if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
5116 5089
 
5117 5090
 			prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
5118 5091
 		} else {
@@ -5171,7 +5144,8 @@ func (c *HisApiController) PreSettle() {
5171 5144
 		}
5172 5145
 		if item.Type == 2 { //项目
5173 5146
 			for _, subItem := range item.HisPrescriptionProject {
5174
-				total = total + (subItem.Price * float64(subItem.Count))
5147
+				cnt, _ := strconv.ParseFloat(subItem.Count, 64)
5148
+				total = total + (subItem.Price * cnt)
5175 5149
 			}
5176 5150
 		}
5177 5151
 
@@ -5229,12 +5203,12 @@ func (c *HisApiController) PreSettle() {
5229 5203
 
5230 5204
 		if item.Type == 2 { //项目
5231 5205
 			for _, subItem := range item.HisPrescriptionProject {
5232
-
5206
+				cnt, _ := strconv.ParseFloat(subItem.Count, 64)
5233 5207
 				cus := &Custom{
5234 5208
 					AdviceId:         0,
5235 5209
 					ProjectId:        subItem.ID,
5236
-					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
5237
-					Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
5210
+					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
5211
+					Cut:              fmt.Sprintf("%.2f", cnt),
5238 5212
 					FeedetlSn:        subItem.FeedetlSn,
5239 5213
 					Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
5240 5214
 					MedListCodg:      subItem.MedListCodg,
@@ -5323,6 +5297,15 @@ func (c *HisApiController) PreSettle() {
5323 5297
 	}
5324 5298
 }
5325 5299
 
5300
+type CustomOrderInfo struct {
5301
+	Name  string
5302
+	Spec  string
5303
+	Unit  string
5304
+	Count float64
5305
+	Price float64
5306
+	Total float64
5307
+}
5308
+
5326 5309
 func (c *HisApiController) GetPrivateExpensesInfo() {
5327 5310
 	order_id, _ := c.GetInt64("id", 0)
5328 5311
 	his_patient_id, _ := c.GetInt64("his_patient_id", 0)
@@ -5336,16 +5319,56 @@ func (c *HisApiController) GetPrivateExpensesInfo() {
5336 5319
 	his, _ := service.GetHisPatientByIdThree(his_patient_id)
5337 5320
 	org_id := c.GetAdminUserInfo().CurrentOrgId
5338 5321
 	adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
5339
-	order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5322
+	//order_info, _ := service.GetHisOrderDetailByNumber(order.Number, org_id)
5323
+
5324
+	orderInfos, _ := service.GetHisOrderInfoByNumberOne(order.Number)
5325
+	orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
5326
+	orderInfos_three, _ := service.GetHisOrderInfoByNumberThree(order.Number)
5327
+
5328
+	var orderInfos_four []*models.HisOrderInfoTwo
5329
+	for _, item := range orderInfos_three {
5330
+		if item.HisPrescriptionProject.HisProject.CostClassify == 3 {
5331
+			item.HisPrescriptionProject.IsCheckTeam = 1
5332
+			orderInfos_four = append(orderInfos_four, item)
5333
+
5334
+		}
5335
+		if item.HisPrescriptionProject.HisProject.CostClassify != 3 {
5336
+			item.HisPrescriptionProject.IsCheckTeam = 2
5337
+			orderInfos_two = append(orderInfos_two, item)
5338
+		}
5339
+	}
5340
+
5341
+	new_order_info := RemoveRepeatedTeam(orderInfos_four)
5342
+	var cus_slice []CustomOrderInfo
5343
+	for _, item := range new_order_info {
5344
+		var cus CustomOrderInfo
5345
+		cus.Name = item.HisPrescriptionProject.XtHisProjectTeam.ProjectTeam
5346
+		cus.Unit = ""
5347
+		cus.Spec = ""
5348
+		var total float64
5349
+		for _, subItem := range orderInfos_four {
5350
+			if item.HisPrescriptionProject.TeamId == subItem.HisPrescriptionProject.TeamId {
5351
+				total = total + subItem.DetItemFeeSumamt
5352
+				fmt.Println(subItem.DetItemFeeSumamt)
5353
+			}
5354
+		}
5355
+		cus.Count = 1
5356
+		cus.Total = total
5357
+		cus_slice = append(cus_slice, cus)
5358
+	}
5359
+
5360
+	orderInfos = append(orderInfos, orderInfos_two...)
5361
+
5340 5362
 	patient, _ := service.GetPatientByID(org_id, order.PatientId)
5341 5363
 	c.ServeSuccessJSON(map[string]interface{}{
5342
-		"order":         order,
5343
-		"order_info":    order_info,
5344
-		"patient":       patient,
5345
-		"admin_info":    adminInfo,
5346
-		"his":           his,
5347
-		"current_admin": role,
5348
-		"org_config":    miConfig,
5364
+		"order":          order,
5365
+		"order_info":     orderInfos,
5366
+		"patient":        patient,
5367
+		"admin_info":     adminInfo,
5368
+		"his":            his,
5369
+		"current_admin":  role,
5370
+		"org_config":     miConfig,
5371
+		"new_order_info": cus_slice,
5349 5372
 	})
5350 5373
 
5351 5374
 }
@@ -5509,3 +5532,20 @@ func (c *HisApiController) GetAllOrder() {
5509 5532
 	return
5510 5533
 
5511 5534
 }
5535
+
5536
+func RemoveRepeatedTeam(arr []*models.HisOrderInfoTwo) (newArr []*models.HisOrderInfoTwo) {
5537
+	newArr = make([]*models.HisOrderInfoTwo, 0)
5538
+	for i := 0; i < len(arr); i++ {
5539
+		repeat := false
5540
+		for j := i + 1; j < len(arr); j++ {
5541
+			if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
5542
+				repeat = true
5543
+				break
5544
+			}
5545
+		}
5546
+		if !repeat {
5547
+			newArr = append(newArr, arr[i])
5548
+		}
5549
+	}
5550
+	return
5551
+}

+ 7 - 3
controllers/his_hospital_api_controller.go View File

@@ -468,7 +468,8 @@ func (c *HisHospitalApiController) GetSettleInfo() {
468 468
 		}
469 469
 		if item.Type == 2 { //项目
470 470
 			for _, subItem := range item.HisPrescriptionProject {
471
-				total = total + (subItem.Price * float64(subItem.Count))
471
+				cut, _ := strconv.ParseFloat(subItem.Count, 64)
472
+				total = total + (subItem.Price * cut)
472 473
 			}
473 474
 		}
474 475
 
@@ -532,12 +533,15 @@ func (c *HisHospitalApiController) GetSettleInfo() {
532 533
 			}
533 534
 		}
534 535
 		if item.Type == 2 { //项目
536
+
535 537
 			for _, subItem := range item.HisPrescriptionProject {
538
+				cut, _ := strconv.ParseFloat(subItem.Count, 64)
539
+
536 540
 				cus := &Custom{
537 541
 					AdviceId:         0,
538 542
 					ProjectId:        subItem.ID,
539
-					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
540
-					Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
543
+					DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cut),
544
+					Cut:              fmt.Sprintf("%.2f", cut),
541 545
 					FeedetlSn:        subItem.FeedetlSn,
542 546
 					Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
543 547
 					MedListCodg:      subItem.MedListCodg,

+ 389 - 204
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -86,7 +86,6 @@ func (this *DialysisAPIController) Scheduals() {
86 86
 	redis := service.RedisClient()
87 87
 	defer redis.Close()
88 88
 
89
-	// cur_date := time.Now().Format("2006-01-02")
90 89
 	key := "scheduals_" + schedualDate + "_" + strconv.FormatInt(orgID, 10)
91 90
 
92 91
 	scheduals_json_str, _ := redis.Get(key).Result()
@@ -105,6 +104,7 @@ func (this *DialysisAPIController) Scheduals() {
105 104
 				prescriptions, _ := service.GetAllPrescriptionsByList(orgID, date.Unix())
106 105
 				assessmentBefores, _ := service.GetAllAssessmentBeforesByList(orgID, date.Unix())
107 106
 				dialysisOrders, _ := service.GetAllDialysisOrdersByList(orgID, date.Unix())
107
+
108 108
 				treatmentSummarys, _ := service.GetAllTreatmentSummarysByList(orgID, date.Unix())
109 109
 				AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByList(orgID, date.Unix())
110 110
 				hisAdvices, _ := service.GetAllHisAdvicesByList(orgID, date.Unix())
@@ -325,209 +325,189 @@ func (this *DialysisAPIController) DialysisRecord() {
325 325
 
326 326
 	adminInfo := this.GetMobileAdminUserInfo()
327 327
 
328
+	ch := make(chan struct{})
329
+	count := 25 // count 表示活动的协程个数
330
+	var patient models.Patients
331
+	var receiverTreatmentAccess *models.ReceiveTreatmentAsses
332
+	var predialysisEvaluation *models.PredialysisEvaluation
333
+	var lastPredialysisEvaluation *models.PredialysisEvaluation
334
+	var doctorAdvices []*models.DoctorAdvice
335
+	var dialysisOrder *models.DialysisOrder
336
+	var doubleCheck *models.DoubleCheck
337
+	var monitorRecords []*models.MonitoringRecord
338
+	var lastMonitorRecord *models.MonitoringRecord
339
+	var assessmentAfterDislysis *models.AssessmentAfterDislysis
340
+	var lastAssessmentAfterDislysis *models.AssessmentAfterDislysis
341
+	var treatmentSummary *models.TreatmentSummary
342
+	var dialysisPrescribe *models.DialysisPrescription
343
+	var dialysisSolution *models.DialysisSolution
344
+	var lastDialysisPrescribe *models.DialysisPrescription
345
+	var systemDialysisPrescribe *models.SystemPrescription
346
+	var is_project_open_config models.XtHisProjectConfig
347
+	var projects []*models.HisPrescriptionProject
348
+	var stockType []*models.GoodsTypeOne
349
+	var prepare []*models.XtDialysisBeforePrepare
350
+	var lastAssessment models.XtPatientVascularAccess
351
+	var prescribeOne *models.DialysisPrescription
352
+	var lastDryWeightDislysis *models.SgjPatientDryweight
353
+	var gobalConfig models.GobalConfig
354
+	var operators []*models.SgjUserAdminRoles
355
+
328 356
 	// 先走redis,没有走数据库
329
-	patient, _ := service.FindPatientByIdWithDiseases(adminInfo.Org.Id, patientID)
357
+	schedual, _ := service.MobileGetSchedualDetailOne(adminInfo.Org.Id, patientID, date.Unix())
358
+	go func() {
359
+		patient, _ = service.FindPatientByIdWithDiseases(adminInfo.Org.Id, patientID)
360
+		ch <- struct{}{}
361
+	}()
330 362
 
331
-	//if getPatientErr != nil {
332
-	//	this.ErrorLog("获取患者信息失败:%v", getPatientErr)
333
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
334
-	//	return
335
-	//} else if patient.ID == 0 {
336
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
337
-	//	return
338
-	//}
363
+	go func() {
364
+		receiverTreatmentAccess, _ = service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
365
+		ch <- struct{}{}
366
+	}()
339 367
 
340
-	// 先走redis,没有走数据库
341
-	schedual, _ := service.MobileGetSchedualDetail(adminInfo.Org.Id, patientID, date.Unix())
368
+	go func() {
369
+		predialysisEvaluation, _ = service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
370
+		ch <- struct{}{}
371
+	}()
342 372
 
343
-	//if getSchedualErr != nil {
344
-	//	this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
345
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
346
-	//	return
347
-	//}
373
+	go func() {
374
+		lastPredialysisEvaluation, _ = service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
375
+		ch <- struct{}{}
376
+	}()
348 377
 
349
-	// 先走redis,没有走数据库
350
-	receiverTreatmentAccess, _ := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.Org.Id, patientID, date.Unix())
351
-	//if getRTARErr != nil {
352
-	//	this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
353
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
354
-	//	return
355
-	//}
378
+	go func() {
379
+		doctorAdvices, _ = service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
380
+		ch <- struct{}{}
381
+	}()
356 382
 
357
-	// // 先走redis,没有走数据库
358
-	predialysisEvaluation, _ := service.MobileGetPredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
359
-	//if getPEErr != nil {
360
-	//	this.ErrorLog("获取透前评估失败:%v", getPEErr)
361
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
362
-	//	return
363
-	//}
383
+	go func() {
384
+		dialysisOrder, _ = service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
364 385
 
365
-	// // 先走redis,没有走数据库
366
-	lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluation(adminInfo.Org.Id, patientID, date.Unix())
367
-	//if getLPEErr != nil {
368
-	//	this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
369
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
370
-	//	return
371
-	//}
386
+		ch <- struct{}{}
387
+	}()
372 388
 
373
-	// // 先走redis,没有走数据库
374
-	doctorAdvices, _ := service.MobileGetDoctorAdvicesByGroups(adminInfo.Org.Id, patientID, date.Unix())
389
+	go func() {
390
+		doubleCheck, _ = service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
391
+		ch <- struct{}{}
392
+	}()
375 393
 
376
-	//if getDoctorAdvicesErr != nil {
377
-	//	this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
378
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
379
-	//	return
380
-	//}
394
+	go func() {
395
+		monitorRecords, _ = service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
396
+		ch <- struct{}{}
397
+	}()
381 398
 
382
-	// // 先走redis,没有走数据库
383
-	dialysisOrder, _ := service.MobileGetSchedualDialysisRecord(adminInfo.Org.Id, patientID, date.Unix())
384
-	//if getDialysisOrderErr != nil {
385
-	//	this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
386
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
387
-	//	return
388
-	//}
399
+	go func() {
400
+		lastMonitorRecord, _ = service.MobileGetLastMonitorRecord(adminInfo.Org.Id, patientID, date.Unix())
401
+		ch <- struct{}{}
402
+	}()
389 403
 
390
-	// // 先走redis,没有走数据库
391
-	doubleCheck, _ := service.MobileGetDoubleCheck(adminInfo.Org.Id, patientID, date.Unix())
392
-	//if getDoubleCheckErr != nil {
393
-	//	this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
394
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
395
-	//	return
396
-	//}
404
+	go func() {
405
+		assessmentAfterDislysis, _ = service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
397 406
 
398
-	// // 先走redis,没有走数据库
399
-	monitorRecords, _ := service.MobileGetMonitorRecords(adminInfo.Org.Id, patientID, date.Unix())
400
-	//if getMonitorRecordsErr != nil {
401
-	//	this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
402
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
403
-	//	return
404
-	//}
405
-	var lastMonitorRecord *models.MonitoringRecord
407
+		ch <- struct{}{}
408
+	}()
406 409
 
407
-	// // 先走redis,没有走数据库
408
-	lastMonitorRecord, getLastErr := service.MobileGetLastMonitorRecord(adminInfo.Org.Id, patientID, date.Unix())
409
-	if getLastErr != nil {
410
-		this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
411
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
412
-		return
413
-	}
410
+	go func() {
411
+		lastAssessmentAfterDislysis, _ = service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
412
+		ch <- struct{}{}
413
+	}()
414 414
 
415
-	// // 先走redis,没有走数据库
416
-	assessmentAfterDislysis, _ := service.MobileGetAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
417
-	//if getAADErr != nil {
418
-	//	this.ErrorLog("获取透后评估失败:%v", getAADErr)
419
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
420
-	//	return
421
-	//}
415
+	go func() {
416
+		treatmentSummary, _ = service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
417
+		ch <- struct{}{}
418
+	}()
422 419
 
423
-	// // 先走redis,没有走数据库
424
-	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminInfo.Org.Id, patientID, date.Unix())
425
-	//if getLAADErr != nil {
426
-	//	this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
427
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
428
-	//	return
429
-	//}
420
+	go func() {
421
+		dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
422
+		ch <- struct{}{}
423
+	}()
430 424
 
431
-	// // 先走redis,没有走数据库
432
-	treatmentSummary, _ := service.MobileGetTreatmentSummary(adminInfo.Org.Id, patientID, date.Unix())
433
-	//if getTreatmentSummaryErr != nil {
434
-	//	this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
435
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
436
-	//	return
437
-	//}
425
+	go func() {
426
+		dialysisSolution, _ = service.MobileGetDialysisSolutionByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
427
+		ch <- struct{}{}
428
+	}()
438 429
 
439
-	// // 先走redis,没有走数据库
440
-	dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, date.Unix(), schedual.ModeId)
441
-
442
-	// //if getDialysisPrescribeErr != nil {
443
-	// //	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
444
-	// //	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
445
-	// //	return
446
-	// //}
447
-
448
-	// // 先走redis,没有走数据库
449
-	dialysisSolution, _ := service.MobileGetDialysisSolutionByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
450
-	// //if getDialysisSolutionErr != nil {
451
-	// //	this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
452
-	// //	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
453
-	// //	return
454
-	// //}
455
-
456
-	// // 先走redis,没有走数据库
457
-	lastDialysisPrescribe, _ := service.MobileGetLastDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
458
-	// //fmt.Println("上次透析处方",lastDialysisPrescribe.DialyzerPerfusionApparatus)
459
-	// //if getDialysisPrescribeErr != nil {
460
-	// //	this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
461
-	// //	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
462
-	// //	return
463
-	// //}
464
-
465
-	// //获取系统透析处方模版
466
-	// // 先走redis,没有走数据库
467
-	systemDialysisPrescribe, _ := service.MobileGetSystemDialysisPrescribeByModeId(adminInfo.Org.Id, schedual.ModeId)
468
-	// //if getSystemDialysisPrescribeErr != nil {
469
-	// //	this.ErrorLog("获取系统透析处方失败:%v", getSystemDialysisPrescribeErr)
470
-	// //	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
471
-	// //	return
472
-	// //}
473
-
474
-	// //dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminInfo.Org.Id, patientID)
475
-
476
-	// //operators, _ := service.GetAllAdminUserES(adminInfo.Org.Id, adminInfo.App.Id)
430
+	go func() {
431
+		lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeId(adminInfo.Org.Id, patientID, schedual.ModeId)
477 432
 
478
-	// 先走redis,没有走数据库
479
-	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
433
+		ch <- struct{}{}
434
+	}()
480 435
 
481
-	// 先走redis,没有走数据库
482
-	_, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
436
+	go func() {
437
+		systemDialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeId(adminInfo.Org.Id, schedual.ModeId)
438
+		ch <- struct{}{}
439
+	}()
483 440
 
484
-	// 先走redis,没有走数据库
485
-	projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
441
+	go func() {
442
+		// 先走redis,没有走数据库
443
+		_, is_project_open_config = service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
444
+		ch <- struct{}{}
445
+	}()
486 446
 
487
-	// // 先走redis,没有走数据库
488
-	stockType, _ := service.GetStockType(adminInfo.Org.Id)
447
+	go func() {
448
+		// 先走redis,没有走数据库
449
+		projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
450
+		ch <- struct{}{}
451
+	}()
489 452
 
490
-	// 先走redis,没有走数据库
491
-	prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
453
+	go func() {
454
+		// // 先走redis,没有走数据库
455
+		stockType, _ = service.GetStockType(adminInfo.Org.Id)
456
+		ch <- struct{}{}
457
+	}()
492 458
 
493
-	// //获取最后一次血管通路
494
-	// 先走redis,没有走数据库
495
-	lastAssessment, _ := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
459
+	go func() {
460
+		// 先走redis,没有走数据库
461
+		prepare, _ = service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
462
+		ch <- struct{}{}
463
+	}()
496 464
 
497
-	// 先走redis,没有走数据库
498
-	prescribeOne, _ := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
499
-	var his_advices []*models.HisDoctorAdviceInfo
500
-	if is_open_config.IsOpen == 1 {
465
+	go func() {
466
+		// //获取最后一次血管通路
501 467
 		// 先走redis,没有走数据库
502
-		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
503
-	}
468
+		lastAssessment, _ = service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
469
+		ch <- struct{}{}
470
+	}()
504 471
 
505
-	// if getLPEErr != nil {
506
-	// 	this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
507
-	// 	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
508
-	// 	return
509
-	// }
472
+	go func() {
473
+		// 先走redis,没有走数据库
474
+		prescribeOne, _ = service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
475
+		ch <- struct{}{}
476
+	}()
510 477
 
511
-	// 先走redis,没有走数据库
512
-	lastDryWeightDislysis, _ := service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
513
-	//if getDryErr != nil {
514
-	//	this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
515
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
516
-	//	return
517
-	//}
478
+	go func() {
479
+		// 先走redis,没有走数据库
480
+		lastDryWeightDislysis, _ = service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
481
+		ch <- struct{}{}
482
+	}()
518 483
 
519
-	// //headNurses, _ := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminInfo.Org.Id, adminInfo.App.Id, models.SpecialPermissionTypeHeadNurse)
484
+	go func() {
485
+		// 先走redis,没有走数据库
486
+		_, gobalConfig = service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
487
+		ch <- struct{}{}
488
+	}()
520 489
 
521
-	// 先走redis,没有走数据库
522
-	_, gobalConfig := service.FindAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
523
-	// //goodTypes, _ := service.FindAllGoodTypeByType(1)          //查出所有库存配置的系统类型
524
-	// //goodInfos, _ := service.FindAllGoodInfo(adminInfo.Org.Id) //查出所有库存配置的系统类型
490
+	go func() {
491
+		// 先走redis,没有走数据库
492
+		operators, _ = service.GetAllStarfEs(adminInfo.Org.Id)
493
+		ch <- struct{}{}
494
+	}()
525 495
 
526
-	// 先走redis,没有走数据库
527
-	operators, _ := service.GetAllStarfEs(adminInfo.Org.Id)
496
+	for range ch {
497
+		// 每次从ch中接收数据,表明一个活动的协程结束
498
+		count--
499
+		// 当所有活动的协程都结束时,关闭管道
500
+		if count == 0 {
501
+			close(ch)
502
+		}
503
+	}
504
+	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
505
+	var his_advices []*models.HisDoctorAdviceInfo
506
+	if is_open_config.IsOpen == 1 {
507
+		// 先走redis,没有走数据库
508
+		his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.Org.Id, patientID, date.Unix())
509
+	}
528 510
 
529
-	//consumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patientID, date.Unix())
530
-	//lastConsumables, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patientID, date.Unix())
531 511
 	returnData := map[string]interface{}{
532 512
 		"patient":                        patient,
533 513
 		"schedual":                       schedual,
@@ -645,9 +625,13 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
645 625
 		service.AddSigleSummaryRecord(&summary)
646 626
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
647 627
 		redis := service.RedisClient()
648
-		defer redis.Close()
649 628
 		//清空key 值
650 629
 		redis.Set(key, "", time.Second)
630
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
631
+		redis.Set(keyOne, "", time.Second)
632
+		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
633
+		redis.Set(keyThree, "", time.Second)
634
+		defer redis.Close()
651 635
 		c.ServeSuccessJSON(map[string]interface{}{
652 636
 			"summary": summary,
653 637
 		})
@@ -669,6 +653,15 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
669 653
 		summary.Modifier = adminUserInfo.AdminUser.Id
670 654
 		summary.ID = treatmentSummary.ID
671 655
 		service.UpdateSummeRecord(&summary)
656
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
657
+		redis := service.RedisClient()
658
+		//清空key 值
659
+		redis.Set(key, "", time.Second)
660
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
661
+		redis.Set(keyOne, "", time.Second)
662
+		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
663
+		redis.Set(keyThree, "", time.Second)
664
+		defer redis.Close()
672 665
 		c.ServeSuccessJSON(map[string]interface{}{
673 666
 			"summary": summary,
674 667
 		})
@@ -1119,10 +1112,12 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1119 1112
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1120 1113
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1121 1114
 		redis := service.RedisClient()
1122
-		defer redis.Close()
1123 1115
 		//清空key 值
1124 1116
 		redis.Set(key, "", time.Second)
1125 1117
 
1118
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
1119
+		redis.Set(keyOne, "", time.Second)
1120
+		defer redis.Close()
1126 1121
 		if err == nil {
1127 1122
 			c.ServeSuccessJSON(map[string]interface{}{
1128 1123
 				"assessmentAfterDislysis": assessmentAfterDislysis,
@@ -1142,6 +1137,13 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1142 1137
 
1143 1138
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1144 1139
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1140
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1141
+		redis := service.RedisClient()
1142
+		//清空key 值
1143
+		redis.Set(key, "", time.Second)
1144
+
1145
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
1146
+		redis.Set(keyOne, "", time.Second)
1145 1147
 		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1146 1148
 		if err == nil {
1147 1149
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -1267,6 +1269,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1267 1269
 
1268 1270
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
1269 1271
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1272
+
1270 1273
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1271 1274
 	//
1272 1275
 	//if template.TemplateId == 2 || template.TemplateId == 6 {
@@ -1456,8 +1459,38 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1456 1459
 		//清空key 值
1457 1460
 		redis.Set(key, "", time.Second)
1458 1461
 
1462
+		keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1463
+		//清空key 值
1464
+		redis.Set(keyOne, "", time.Second)
1465
+
1466
+		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
1467
+		//清空key 值
1468
+		redis.Set(keyTwo, "", time.Second)
1469
+
1470
+		keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
1471
+		redis.Set(keySix, "", time.Second)
1472
+
1473
+		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1474
+		redis.Set(keySeven, "", time.Second)
1475
+
1459 1476
 		if err == nil {
1460 1477
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1478
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_by_mode"
1479
+			//清空key 值
1480
+			redis.Set(keyThree, "", time.Second)
1481
+
1482
+			keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":system_dialysis_prescribe"
1483
+			//清空key 值
1484
+			redis.Set(keyFour, "", time.Second)
1485
+			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
1486
+			redis.Set(keyFive, "", time.Second)
1487
+
1488
+			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1489
+			redis.Set(keySeven, "", time.Second)
1490
+
1491
+			keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1492
+			//清空key 值
1493
+			redis.Set(keyOne, "", time.Second)
1461 1494
 			if updateErr != nil {
1462 1495
 				utils.ErrorLog("%v", updateErr)
1463 1496
 			}
@@ -1509,8 +1542,21 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1509 1542
 		defer redis.Close()
1510 1543
 		//清空key 值
1511 1544
 		redis.Set(key, "", time.Second)
1545
+
1546
+		keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1547
+		//清空key 值
1548
+		redis.Set(keyOne, "", time.Second)
1549
+
1550
+		keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
1551
+		redis.Set(keySix, "", time.Second)
1552
+
1553
+		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1554
+		redis.Set(keySeven, "", time.Second)
1512 1555
 		if err == nil {
1513 1556
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1557
+			keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1558
+			//清空key 值
1559
+			redis.Set(keyOne, "", time.Second)
1514 1560
 			if updateErr != nil {
1515 1561
 				utils.ErrorLog("%v", updateErr)
1516 1562
 			}
@@ -1591,14 +1637,14 @@ func (c *DialysisAPIController) Finish() {
1591 1637
 	}
1592 1638
 	fmt.Println(endmonitorRecords.UltrafiltrationVolume)
1593 1639
 
1594
-	assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.Org.Id, id, recordDate.Unix())
1640
+	assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1595 1641
 	if getAADErr != nil {
1596 1642
 		c.ErrorLog("获取透后评估失败:%v", getAADErr)
1597 1643
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1598 1644
 		return
1599 1645
 	}
1600 1646
 
1601
-	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.Org.Id, id, recordDate.Unix())
1647
+	lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1602 1648
 
1603 1649
 	_, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.Org.Id, id, recordDate.Unix())
1604 1650
 
@@ -1614,7 +1660,7 @@ func (c *DialysisAPIController) Finish() {
1614 1660
 		tempassessmentAfterDislysis.PatientId = id
1615 1661
 		tempassessmentAfterDislysis.UserOrgId = adminUserInfo.Org.Id
1616 1662
 	}
1617
-
1663
+	fmt.Println("上机状态233323232232332322332233232323223", dialysisOrder.Stage)
1618 1664
 	if dialysisOrder.Stage == 1 {
1619 1665
 		temp_time := (float64(endDate.Unix()) - float64(dialysisOrder.StartTime)) / 3600
1620 1666
 		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
@@ -1623,7 +1669,7 @@ func (c *DialysisAPIController) Finish() {
1623 1669
 		c, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
1624 1670
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1625 1671
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", c*60), 10, 64)
1626
-		fmt.Println(hour)
1672
+		fmt.Println("323332322332323223232323232323232323", hour)
1627 1673
 		fmt.Println(minute)
1628 1674
 		tempassessmentAfterDislysis.ActualTreatmentHour = hour
1629 1675
 		tempassessmentAfterDislysis.ActualTreatmentMinute = minute
@@ -1648,7 +1694,7 @@ func (c *DialysisAPIController) Finish() {
1648 1694
 		tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
1649 1695
 
1650 1696
 	}
1651
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 {
1697
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 9675 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 {
1652 1698
 		evaluation, _ := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, recordDate.Unix())
1653 1699
 		if evaluation.SystolicBloodPressure == 0 {
1654 1700
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
@@ -1657,6 +1703,11 @@ func (c *DialysisAPIController) Finish() {
1657 1703
 			}
1658 1704
 			fmt.Println("prew", pre)
1659 1705
 			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1706
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1707
+
1708
+			redis := service.RedisClient()
1709
+			redis.Set(key, "", time.Second)
1710
+			defer redis.Close()
1660 1711
 			fmt.Println(getNurseErr)
1661 1712
 		}
1662 1713
 		if evaluation.DiastolicBloodPressure == 0 {
@@ -1665,6 +1716,14 @@ func (c *DialysisAPIController) Finish() {
1665 1716
 				DiastolicBloodPressure: evaluation.DiastolicBloodPressure,
1666 1717
 			}
1667 1718
 			getNurseErr := service.UpdatePredialysisEvaluationTwo(&pres, evaluation.ID)
1719
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1720
+
1721
+			redis := service.RedisClient()
1722
+			redis.Set(key, "", time.Second)
1723
+
1724
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
1725
+			redis.Set(keyOne, "", time.Second)
1726
+			defer redis.Close()
1668 1727
 			fmt.Println(getNurseErr)
1669 1728
 		}
1670 1729
 		if evaluation.PulseFrequency == 0 {
@@ -1673,6 +1732,13 @@ func (c *DialysisAPIController) Finish() {
1673 1732
 				PulseFrequency: evaluation.PulseFrequency,
1674 1733
 			}
1675 1734
 			getNurseErr := service.UpdatePredialysisEvaluationThree(&press, evaluation.ID)
1735
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1736
+
1737
+			redis := service.RedisClient()
1738
+			redis.Set(key, "", time.Second)
1739
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
1740
+			redis.Set(keyOne, "", time.Second)
1741
+			defer redis.Close()
1676 1742
 			fmt.Println(getNurseErr)
1677 1743
 		}
1678 1744
 	}
@@ -1768,6 +1834,17 @@ func (c *DialysisAPIController) Finish() {
1768 1834
 	}
1769 1835
 
1770 1836
 	err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
1837
+
1838
+	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1839
+	redis := service.RedisClient()
1840
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
1841
+	redis.Set(keyOne, "", time.Second)
1842
+
1843
+	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_last"
1844
+	redis.Set(keyTwo, "", time.Second)
1845
+	defer redis.Close()
1846
+	//清空key 值
1847
+	redis.Set(key, "", time.Second)
1771 1848
 	if err != nil {
1772 1849
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1773 1850
 		return
@@ -1783,6 +1860,15 @@ func (c *DialysisAPIController) Finish() {
1783 1860
 	}
1784 1861
 	if dialysisOrder.Stage == 1 {
1785 1862
 		err := service.ModifyDialysisRecord(dialysisOrder.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
1863
+
1864
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
1865
+		redis := service.RedisClient()
1866
+		defer redis.Close()
1867
+		//清空key 值
1868
+		redis.Set(key, "", time.Second)
1869
+
1870
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
1871
+		redis.Set(keyOne, "", time.Second)
1786 1872
 		//结束时候透析次数加1
1787 1873
 		service.UpdateSolutionByPatientId(id)
1788 1874
 		dialysisOrder.Stage = 2
@@ -1906,15 +1992,6 @@ func (this *DialysisAPIController) StartDialysis() {
1906 1992
 	}
1907 1993
 
1908 1994
 	nurse, getNurseErr = service.GetAdminUserByUserID(puncture_nurse)
1909
-	//if getNurseErr != nil {
1910
-	//	this.ErrorLog("获取护士失败:%v", getNurseErr)
1911
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1912
-	//	return
1913
-	//} else if nurse == nil {
1914
-	//	this.ErrorLog("护士不存在")
1915
-	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1916
-	//	return
1917
-	//}
1918 1995
 
1919 1996
 	deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.Org.Id, bedID)
1920 1997
 	if getDeviceNumberErr != nil {
@@ -2049,6 +2126,10 @@ func (this *DialysisAPIController) StartDialysis() {
2049 2126
 		//清空key 值
2050 2127
 		redis.Set(keyOne, "", time.Second)
2051 2128
 
2129
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
2130
+		//清空key 值
2131
+		redis.Set(keyTwo, "", time.Second)
2132
+
2052 2133
 		if createErr != nil {
2053 2134
 			this.ErrorLog("上机失败:%v", createErr)
2054 2135
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -2098,7 +2179,6 @@ func (this *DialysisAPIController) StartDialysis() {
2098 2179
 
2099 2180
 			if template.TemplateId == 43 {
2100 2181
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / float64(totalMin))
2101
-				fmt.Println("hhhh232332322323232332", ultrafiltration_rate)
2102 2182
 			}
2103 2183
 
2104 2184
 			if template.TemplateId == 20 || template.TemplateId == 22 { //adminUserInfo.Org.Id == 9538
@@ -2146,6 +2226,12 @@ func (this *DialysisAPIController) StartDialysis() {
2146 2226
 	// 如果当天有插入数据,则不再往透析纪录里插入数据
2147 2227
 	if newdialysisRecord.ID > 0 {
2148 2228
 		err := service.CreateMonitor(&record)
2229
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2230
+		redis := service.RedisClient()
2231
+		defer redis.Close()
2232
+		//清空key 值
2233
+		redis.Set(key, "", time.Second)
2234
+
2149 2235
 		if err != nil {
2150 2236
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2151 2237
 			return
@@ -2164,9 +2250,11 @@ func (this *DialysisAPIController) StartDialysis() {
2164 2250
 	}()
2165 2251
 
2166 2252
 	this.ServeSuccessJSON(map[string]interface{}{
2253
+
2167 2254
 		"dialysis_order": newdialysisRecord,
2168 2255
 		"monitor":        record,
2169 2256
 	})
2257
+	return
2170 2258
 }
2171 2259
 
2172 2260
 func (c *DialysisAPIController) PostSolution() {
@@ -2278,6 +2366,8 @@ func (c *DialysisAPIController) PostSolution() {
2278 2366
 	epo := c.GetString("epo")
2279 2367
 	epo_count, _ := c.GetFloat("epo_count", 0)
2280 2368
 	max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
2369
+	pre_impulse := c.GetString("pre_impulse")
2370
+	impulse, _ := strconv.ParseFloat(pre_impulse, 64)
2281 2371
 	if mode_id > 0 {
2282 2372
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
2283 2373
 	}
@@ -2383,6 +2473,7 @@ func (c *DialysisAPIController) PostSolution() {
2383 2473
 		Epo:                        epo,
2384 2474
 		EpoCount:                   epo_count,
2385 2475
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2476
+		PreImpulse:                 impulse,
2386 2477
 	}
2387 2478
 
2388 2479
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -2479,6 +2570,7 @@ func (c *DialysisAPIController) PostSolution() {
2479 2570
 		Epo:                        epo,
2480 2571
 		EpoCount:                   epo_count,
2481 2572
 		MaxUltrafiltrationRate:     max_ultrafiltration_rate,
2573
+		PreImpulse:                 impulse,
2482 2574
 	}
2483 2575
 	service.SavePrescriptionAndCreateSolution(&solution, &prescription)
2484 2576
 
@@ -2494,6 +2586,17 @@ func (c *DialysisAPIController) PostSolution() {
2494 2586
 	redis.Set(soulution_key, "", time.Second)
2495 2587
 	//查询最近透析准备表里是否存在 透析器 灌流器
2496 2588
 
2589
+	keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
2590
+	redis.Set(keyOne, "", time.Second)
2591
+
2592
+	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
2593
+	redis.Set(keyTwo, "", time.Second)
2594
+
2595
+	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
2596
+	redis.Set(keyThree, "", time.Second)
2597
+
2598
+	keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
2599
+	redis.Set(keyFour, "", time.Second)
2497 2600
 	//splitStr := strings.Split(dialysis_dialyszers, ",")
2498 2601
 	//
2499 2602
 	//splitIrrigation := strings.Split(dialysis_irrigation, ",")
@@ -2851,12 +2954,33 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
2851 2954
 
2852 2955
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
2853 2956
 	redis := service.RedisClient()
2854
-	defer redis.Close()
2957
+
2855 2958
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
2856 2959
 	redis.Set(key, "", time.Second)
2857 2960
 	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
2961
+	fmt.Println("keyOne23332233223322332322332", keyOne)
2858 2962
 	//清空key 值
2859 2963
 	redis.Set(keyOne, "", time.Second)
2964
+	scheduleDateStartOne := startDate.Format("2006-01-02")
2965
+	keyTwo := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
2966
+	fmt.Println("keyTwo2332323232233223232323", keyTwo)
2967
+	redis.Set(keyTwo, "", time.Second)
2968
+
2969
+	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":doctor_advices"
2970
+	redis.Set(keyThree, "", time.Second)
2971
+	keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":monitor_records"
2972
+	redis.Set(keyFour, "", time.Second)
2973
+
2974
+	keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":patient_info"
2975
+	redis.Set(keyFive, "", time.Second)
2976
+
2977
+	keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":his_doctor_advice"
2978
+	redis.Set(keySix, "", time.Second)
2979
+
2980
+	keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":device_list_all"
2981
+	redis.Set(keySeven, "", time.Second)
2982
+
2983
+	defer redis.Close()
2860 2984
 	if updateErr != nil {
2861 2985
 		this.ErrorLog("修改上机失败:%v", updateErr)
2862 2986
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -2935,6 +3059,14 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
2935 3059
 	}
2936 3060
 
2937 3061
 	updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
3062
+	redis := service.RedisClient()
3063
+	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
3064
+	//清空key 值
3065
+	redis.Set(key, "", time.Second)
3066
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
3067
+	//清空key 值
3068
+	redis.Set(keyOne, "", time.Second)
3069
+	redis.Close()
2938 3070
 	if updateErr != nil {
2939 3071
 		c.ErrorLog("修改下机失败:%v", updateErr)
2940 3072
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -2949,6 +3081,20 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
2949 3081
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
2950 3082
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
2951 3083
 		updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecords.PatientId, tempDialysisRecords.UserOrgId, tempDialysisRecords.DialysisDate, hour, minute)
3084
+
3085
+		redis := service.RedisClient()
3086
+		keyTen := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":assessment_after_dislysis"
3087
+		redis.Set(keyTen, "", time.Second)
3088
+
3089
+		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":assessment_after_dislysis_last"
3090
+		redis.Set(keyTwo, "", time.Second)
3091
+
3092
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
3093
+
3094
+		redis.Set(key, "", time.Second)
3095
+		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
3096
+		redis.Set(keyThree, "", time.Second)
3097
+		defer redis.Close()
2952 3098
 		if updateAssessmentErr != nil {
2953 3099
 			utils.ErrorLog("%v", updateAssessmentErr)
2954 3100
 		}
@@ -2965,7 +3111,7 @@ func (c *DialysisAPIController) GetLongAdvice() {
2965 3111
 	patient_id, _ := c.GetInt64("id")
2966 3112
 	adminUserInfo := c.GetMobileAdminUserInfo()
2967 3113
 	_, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.Org.Id)
2968
-
3114
+	_, hisConfig := service.FindXTHisRecordByOrgId(adminUserInfo.Org.Id)
2969 3115
 	//patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
2970 3116
 	if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有	不开启推送功能,不做任何处理
2971 3117
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -2975,9 +3121,9 @@ func (c *DialysisAPIController) GetLongAdvice() {
2975 3121
 	} else { //开启推送提醒
2976 3122
 		//开启推送提醒逻辑    提交长期处方的时候,弹起长期医嘱推送
2977 3123
 		var advice_three []*models.DoctorAdvice
2978
-		//groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
2979
-		advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.Org.Id, patient_id)
2980
-		advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.Org.Id, patient_id)
3124
+
3125
+		advices, err := service.GetLastLongAdviceByGroupNoOne(adminUserInfo.Org.Id, patient_id)
3126
+		advices_two, err := service.GetLastLongAdviceByGroupNoFour(adminUserInfo.Org.Id, patient_id)
2981 3127
 
2982 3128
 		for _, advice := range advices {
2983 3129
 			if advice.FrequencyType == 3 {
@@ -3042,10 +3188,11 @@ func (c *DialysisAPIController) GetLongAdvice() {
3042 3188
 		}
3043 3189
 		if err == nil {
3044 3190
 			c.ServeSuccessJSON(map[string]interface{}{
3045
-				"status":         "2",
3046
-				"advices":        advices,
3047
-				"advices_two":    RemoveRepeatedElement(advice_three),
3048
-				"is_open_remind": config.IsOpenRemind,
3191
+				"status":          "2",
3192
+				"advices":         advices,
3193
+				"advices_two":     RemoveRepeatedElement(advice_three),
3194
+				"is_open_remind":  config.IsOpenRemind,
3195
+				"his_config_open": hisConfig.IsOpen,
3049 3196
 			})
3050 3197
 		}
3051 3198
 	}
@@ -3352,9 +3499,15 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
3352 3499
 		list, err := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, groupNo)
3353 3500
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(RecordDate, 10) + ":doctor_advices"
3354 3501
 		redis := service.RedisClient()
3355
-		defer redis.Close()
3356 3502
 		//清空key 值
3357 3503
 		redis.Set(key, "", time.Second)
3504
+
3505
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3506
+		redis.Set(keyOne, "", time.Second)
3507
+
3508
+		keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
3509
+		defer redis.Close()
3510
+		redis.Set(keyThree, "", time.Second)
3358 3511
 		if err != nil {
3359 3512
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3360 3513
 			return
@@ -3398,7 +3551,18 @@ func (c *DialysisAPIController) UploadDryWeight() {
3398 3551
 			UserId:        adminUserInfo.AdminUser.Id,
3399 3552
 		}
3400 3553
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3401
-
3554
+		redis := service.RedisClient()
3555
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
3556
+		redis.Set(keyOne, "", time.Second)
3557
+		loc, _ := time.LoadLocation("Local")
3558
+		nowTime := time.Now()
3559
+		nowDay := nowTime.Format("2006-01-02")
3560
+		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
3561
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3562
+		redis.Set(key, "", time.Second)
3563
+		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
3564
+		redis.Set(keyTwo, "", time.Second)
3565
+		redis.Close()
3402 3566
 		if createErr == nil {
3403 3567
 			c.ServeSuccessJSON(map[string]interface{}{
3404 3568
 				"msg":    "提交成功",
@@ -3431,6 +3595,18 @@ func (c *DialysisAPIController) UploadDryWeight() {
3431 3595
 		}
3432 3596
 
3433 3597
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3598
+		redis := service.RedisClient()
3599
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
3600
+		redis.Set(keyOne, "", time.Second)
3601
+		loc, _ := time.LoadLocation("Local")
3602
+		nowTime := time.Now()
3603
+		nowDay := nowTime.Format("2006-01-02")
3604
+		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
3605
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3606
+		redis.Set(key, "", time.Second)
3607
+		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
3608
+		redis.Set(keyTwo, "", time.Second)
3609
+		redis.Close()
3434 3610
 		if createErr == nil {
3435 3611
 			c.ServeSuccessJSON(map[string]interface{}{
3436 3612
 				"msg":    "提交成功",
@@ -3483,7 +3659,7 @@ func (c *DialysisAPIController) GetSchedule() {
3483 3659
 func (c *DialysisAPIController) GetPatientId() {
3484 3660
 
3485 3661
 	id, _ := c.GetInt64("id")
3486
-
3662
+	//orgid := c.GetMobileAdminUserInfo().Org.Id
3487 3663
 	patientId, _ := service.GetPatientId(id)
3488 3664
 	//获取该患者的所有传染病
3489 3665
 	list, _ := service.GetPatientInfectious(id)
@@ -4604,12 +4780,21 @@ func (c *DialysisAPIController) GetMobilePrintStockGood() {
4604 4780
 }
4605 4781
 
4606 4782
 func (c *DialysisAPIController) BatchDeleteMonitor() {
4607
-	fmt.Println("jin2222245555555555")
4783
+
4608 4784
 	ids := c.GetString("ids")
4609
-	fmt.Println("dis22222222", ids)
4785
+	//patient_id, _ := c.GetInt64("patient_id")
4786
+	//monitoring_date, _ := c.GetInt64("monitoring_date")
4610 4787
 	idArray := strings.Split(ids, ",")
4611 4788
 	err := service.BatchDeleteMonitor(idArray)
4612 4789
 	fmt.Print("err", err)
4790
+	//orgid := c.GetMobileAdminUserInfo().Org.Id
4791
+	//redis := service.RedisClient()
4792
+	//key := strconv.FormatInt(orgid, 10) + ":" + ":monitor_record_list_all"
4793
+	//redis.Set(key, "", time.Second)
4794
+	//keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_records"
4795
+	//redis.Set(keyOne, "", time.Second)
4796
+	//fmt.Println("keyo呢32332322332332232332",keyOne)
4797
+	//redis.Close()
4613 4798
 	c.ServeSuccessJSON(map[string]interface{}{
4614 4799
 		"msg": "批量删除成功",
4615 4800
 	})

+ 63 - 2
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -170,9 +170,11 @@ func (this *DialysisAPIController) AddMonitorRecord() {
170 170
 	err := service.CreateMonitor(&record)
171 171
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
172 172
 	redis := service.RedisClient()
173
-	defer redis.Close()
174 173
 	//清空key 值
175 174
 	redis.Set(key, "", time.Second)
175
+	keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
176
+	redis.Set(keyOne, "", time.Second)
177
+	defer redis.Close()
176 178
 	if err != nil {
177 179
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
178 180
 		return
@@ -332,9 +334,13 @@ func (this *DialysisAPIController) EditMonitorRecord() {
332 334
 	err = service.UpdateMonitor(monitor)
333 335
 	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
334 336
 	redis := service.RedisClient()
335
-	defer redis.Close()
336 337
 	//清空key 值
337 338
 	redis.Set(key, "", time.Second)
339
+	keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
340
+	redis.Set(keyOne, "", time.Second)
341
+
342
+	defer redis.Close()
343
+
338 344
 	if err != nil {
339 345
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
340 346
 		return
@@ -372,6 +378,15 @@ func (this *DialysisAPIController) DeleteMonitor() {
372 378
 		return
373 379
 	}
374 380
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
381
+	orgid := this.GetMobileAdminUserInfo().Org.Id
382
+	redis := service.RedisClient()
383
+	key := strconv.FormatInt(orgid, 10) + ":" + ":monitor_record_list_all"
384
+	redis.Set(key, "", time.Second)
385
+	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
386
+	redis.Set(keyOne, "", time.Second)
387
+	fmt.Println("keyo呢32332322332332232332", keyOne)
388
+	redis.Close()
389
+
375 390
 	if err != nil {
376 391
 		this.ErrorLog("删除透析监测记录失败:%v", err)
377 392
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
@@ -485,7 +500,30 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
485 500
 				UpdatedTime:  time.Now().Unix(),
486 501
 			}
487 502
 			createErr := service.CreateSchedule(newSchedule)
503
+			redis := service.RedisClient()
504
+
505
+			//处方
506
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
507
+			redis.Set(keyOne, "", time.Second)
488 508
 
509
+			//医嘱
510
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
511
+			redis.Set(keyTwo, "", time.Second)
512
+
513
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
514
+			redis.Set(keySix, "", time.Second)
515
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
516
+			redis.Set(keyThree, "", time.Second)
517
+
518
+			keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
519
+			redis.Set(keyFour, "", time.Second)
520
+
521
+			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
522
+			redis.Set(keyFive, "", time.Second)
523
+
524
+			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
525
+			redis.Set(keySeven, "", time.Second)
526
+			redis.Close()
489 527
 			if createErr != nil {
490 528
 				this.ErrorLog("紧急排班失败:%v", createErr)
491 529
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
@@ -522,6 +560,29 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
522 560
 					daySchedule.ScheduleType = scheduleType
523 561
 					daySchedule.UpdatedTime = time.Now().Unix()
524 562
 					err := service.UpdateSchedule(&daySchedule)
563
+					redis := service.RedisClient()
564
+					//处方
565
+					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
566
+					redis.Set(keyOne, "", time.Second)
567
+
568
+					//医嘱
569
+					keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
570
+					redis.Set(keyTwo, "", time.Second)
571
+
572
+					keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
573
+					redis.Set(keySix, "", time.Second)
574
+					keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
575
+					redis.Set(keyThree, "", time.Second)
576
+
577
+					keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
578
+					redis.Set(keyFour, "", time.Second)
579
+
580
+					keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
581
+					redis.Set(keyFive, "", time.Second)
582
+
583
+					keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
584
+					redis.Set(keySeven, "", time.Second)
585
+					redis.Close()
525 586
 					if err != nil {
526 587
 						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
527 588
 						return

+ 130 - 34
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -240,7 +240,12 @@ func (c *PatientApiController) CreateDoctorAdvice() {
240 240
 	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
241 241
 
242 242
 	err := service.CreateDoctorAdvice(&advice)
243
-
243
+	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
244
+	redis := service.RedisClient()
245
+	defer redis.Close()
246
+	redis.Set(key, "", time.Second)
247
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
248
+	redis.Set(keyOne, "", time.Second)
244 249
 	if err != nil {
245 250
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
246 251
 		return
@@ -255,11 +260,13 @@ func (c *PatientApiController) CreateDoctorAdvice() {
255 260
 
256 261
 func (c *PatientApiController) EditDoctorAdvice() {
257 262
 	id, _ := c.GetInt64("id", 0)
263
+	patient_id, _ := c.GetInt64("patient_id")
264
+	doc_advice_date, _ := c.GetInt64("advice_date")
258 265
 	if id <= 0 {
259 266
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
260 267
 		return
261 268
 	}
262
-
269
+	redis := service.RedisClient()
263 270
 	adminUserInfo := c.GetMobileAdminUserInfo()
264 271
 
265 272
 	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -306,17 +313,34 @@ func (c *PatientApiController) EditDoctorAdvice() {
306 313
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
307 314
 			if advice.StartTime == sourceAdvice.StartTime {
308 315
 				err = service.UpdateDoctorAdvice(&advice)
316
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
317
+
318
+				defer redis.Close()
319
+				redis.Set(key, "", time.Second)
320
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
321
+				redis.Set(keyOne, "", time.Second)
309 322
 				isChangeGroup = false
310 323
 			} else {
311 324
 				err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
312 325
 				isChangeGroup = false
326
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
313 327
 
328
+				defer redis.Close()
329
+				redis.Set(key, "", time.Second)
330
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
331
+				redis.Set(keyOne, "", time.Second)
314 332
 			}
315 333
 		} else if len(adviceSlice) > 1 {
316 334
 
317 335
 			//判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
318 336
 			if advice.StartTime == sourceAdvice.StartTime {
319 337
 				err = service.UpdateDoctorAdvice(&advice)
338
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
339
+
340
+				defer redis.Close()
341
+				redis.Set(key, "", time.Second)
342
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
343
+				redis.Set(keyOne, "", time.Second)
320 344
 				isChangeGroup = false
321 345
 
322 346
 			} else {
@@ -324,6 +348,12 @@ func (c *PatientApiController) EditDoctorAdvice() {
324 348
 				gruopNo = gruopNo + 1
325 349
 				advice.GroupNo = gruopNo
326 350
 				err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
351
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
352
+
353
+				defer redis.Close()
354
+				redis.Set(key, "", time.Second)
355
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
356
+				redis.Set(keyOne, "", time.Second)
327 357
 				isChangeGroup = true
328 358
 
329 359
 			}
@@ -331,6 +361,13 @@ func (c *PatientApiController) EditDoctorAdvice() {
331 361
 	} else {
332 362
 		isChangeGroup = false
333 363
 		err = service.UpdateDoctorAdvice(&advice)
364
+		redis := service.RedisClient()
365
+		defer redis.Close()
366
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
367
+		redis.Set(key, "", time.Second)
368
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
369
+		redis.Set(keyOne, "", time.Second)
370
+
334 371
 	}
335 372
 	if err != nil {
336 373
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
@@ -510,6 +547,7 @@ func (c *PatientApiController) DeleteDoctorAdvice() {
510 547
 
511 548
 func (c *PatientApiController) ExecDoctorAdvice() {
512 549
 	execution_time := c.GetString("execution_time")
550
+
513 551
 	origin, _ := c.GetInt64("origin", 0)
514 552
 	groupno, _ := c.GetInt64("groupno", -1)
515 553
 
@@ -587,14 +625,35 @@ func (c *PatientApiController) ExecDoctorAdvice() {
587 625
 			err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
588 626
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
589 627
 			redis := service.RedisClient()
590
-			defer redis.Close()
591 628
 			//清空key 值
592 629
 			redis.Set(key, "", time.Second)
630
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
631
+			redis.Set(keyTwo, "", time.Second)
632
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
633
+			redis.Set(keyThree, "", time.Second)
634
+			toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", execution_time)
635
+			theTime := toTime.Format("2006-01-02")
636
+
637
+			fmt.Println("theTIME", theTime)
638
+			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
639
+			fmt.Println("keyFour323223323232323232", keyFour)
640
+			redis.Set(keyFour, "", time.Second)
641
+			defer redis.Close()
593 642
 		} else {
594 643
 
595 644
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
596 645
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
597 646
 			redis := service.RedisClient()
647
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
648
+			redis.Set(keyTwo, "", time.Second)
649
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
650
+			redis.Set(keyThree, "", time.Second)
651
+			toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", execution_time)
652
+			theTime := toTime.Format("2006-01-02")
653
+			fmt.Println("theTIME", theTime)
654
+			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
655
+			fmt.Println("keyFour323223323232323232", keyFour)
656
+			redis.Set(keyFour, "", time.Second)
598 657
 			defer redis.Close()
599 658
 			//清空key 值
600 659
 			redis.Set(key, "", time.Second)
@@ -904,9 +963,15 @@ func (c *PatientApiController) ExecDoctorAdvice() {
904 963
 			err = service.SaveHisDoctorAdvice(item)
905 964
 			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
906 965
 			redis := service.RedisClient()
907
-			defer redis.Close()
908 966
 			//清空key 值
909 967
 			redis.Set(key, "", time.Second)
968
+			keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + ":advice_list_all"
969
+			redis.Set(keyTwo, "", time.Second)
970
+			keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
971
+			redis.Set(keyThree, "", time.Second)
972
+			keyFour := "scheduals_" + execution_time + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
973
+			redis.Set(keyFour, "", time.Second)
974
+			defer redis.Close()
910 975
 		}
911 976
 
912 977
 		if err == nil {
@@ -1570,14 +1635,18 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1570 1635
 	// 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
1571 1636
 	// 	}
1572 1637
 	// }
1573
-	fmt.Println("hh233232323232evaluation", evaluation)
1638
+
1574 1639
 	err = service.UpadatePredialysisEvaluation(&evaluation)
1575
-	fmt.Println("除非3333223323233232323323232", err)
1640
+
1576 1641
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
1577 1642
 	redis := service.RedisClient()
1578 1643
 	defer redis.Close()
1579 1644
 	//清空key 值
1580 1645
 	redis.Set(key, "", time.Second)
1646
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
1647
+	redis.Set(keyOne, "", time.Second)
1648
+	keyTwo := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1649
+	redis.Set(keyTwo, "", time.Second)
1581 1650
 	if err != nil {
1582 1651
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
1583 1652
 		return
@@ -2120,9 +2189,10 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2120 2189
 		evaluation.PunctureNeedle = punctureNeedle
2121 2190
 	}
2122 2191
 
2123
-	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "float64" {
2192
+	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "string" {
2124 2193
 
2125 2194
 		humor_excessive_symptom, _ := dataBody["humor_excessive_symptom"].(string)
2195
+
2126 2196
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2127 2197
 	}
2128 2198
 
@@ -2203,6 +2273,10 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2203 2273
 		evaluation.BloodPressureDuringDialysis = blood_pressure_during_dialysis
2204 2274
 	}
2205 2275
 
2276
+	if dataBody["pre_dialysis_drugs"] != nil && reflect.TypeOf(dataBody["pre_dialysis_drugs"]).String() == "string" {
2277
+		pre_dialysis_drugs := dataBody["pre_dialysis_drugs"].(string)
2278
+		evaluation.PreDialysisDrugs = pre_dialysis_drugs
2279
+	}
2206 2280
 	return
2207 2281
 }
2208 2282
 
@@ -2542,6 +2616,7 @@ func (c *PatientApiController) GetPatientMonitor() {
2542 2616
 	adminInfo := c.GetMobileAdminUserInfo()
2543 2617
 	orgID := adminInfo.Org.Id
2544 2618
 	monitor, err := service.GetMonitorRecord(orgID, theStartTime, partition, patient_id)
2619
+
2545 2620
 	if err != nil {
2546 2621
 		c.ErrorLog("获取排班信息失败:%v", err)
2547 2622
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -2615,12 +2690,10 @@ func (c *PatientApiController) GetPatientMonitor() {
2615 2690
 						break
2616 2691
 					}
2617 2692
 				}
2618
-				records := make([]*models.VMMonitoringRecord, 0)
2619
-				// 透析监测
2693
+
2620 2694
 				for _, it := range monitorlist {
2621
-					records := append(records, it)
2622 2695
 					if item.PatientId == it.PatientId {
2623
-						monitor[key].MonitoringRecord = records
2696
+						monitor[key].MonitoringRecord = append(monitor[key].MonitoringRecord, it)
2624 2697
 					}
2625 2698
 				}
2626 2699
 
@@ -2836,7 +2909,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2836 2909
 			advice.CheckState = item.CheckState
2837 2910
 			advice.ExecutionState = item.ExecutionState
2838 2911
 			advice.ExecutionStaff = item.ExecutionStaff
2839
-			advice.PrescribingNumber = float64(item.Count)
2912
+			//advice.PrescribingNumber = float64(item.Count)
2840 2913
 			advice.PrescribingNumberUnit = item.Unit
2841 2914
 			advice.AdviceDoctor = item.Doctor
2842 2915
 			if item.Type == 3 {
@@ -3097,9 +3170,12 @@ func (c *PatientApiController) CreateGroupAdvice() {
3097 3170
 		newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
3098 3171
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
3099 3172
 		redis := service.RedisClient()
3100
-		defer redis.Close()
3101 3173
 		//清空key 值
3102 3174
 		redis.Set(key, "", time.Second)
3175
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3176
+		redis.Set(keyOne, "", time.Second)
3177
+
3178
+		defer redis.Close()
3103 3179
 		if createErr != nil {
3104 3180
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3105 3181
 			return
@@ -3125,26 +3201,6 @@ func (c *PatientApiController) CreateGroupAdvice() {
3125 3201
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
3126 3202
 			return
3127 3203
 		}
3128
-		//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
3129
-
3130
-		//if appRole.UserType == 3{
3131
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdvicePermissionDeniedModify)
3132
-		//	return
3133
-		//}
3134
-
3135
-		//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
3136
-		//
3137
-		//if appRole.UserType == 3 {
3138
-		//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
3139
-		//	if getPermissionErr != nil {
3140
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3141
-		//		return
3142
-		//	} else if headNursePermission == nil {
3143
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
3144
-		//		return
3145
-		//	}
3146
-		//}
3147
-
3148 3204
 		var advice models.DoctorAdvice
3149 3205
 		code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "create")
3150 3206
 		if code > 0 {
@@ -3185,6 +3241,14 @@ func (c *PatientApiController) CreateGroupAdvice() {
3185 3241
 		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
3186 3242
 
3187 3243
 		err := service.CreateDoctorAdvice(&advice)
3244
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
3245
+		redis := service.RedisClient()
3246
+		//清空key 值
3247
+		redis.Set(key, "", time.Second)
3248
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3249
+		redis.Set(keyOne, "", time.Second)
3250
+		fmt.Println("key`2232333332233223233232", key)
3251
+		defer redis.Close()
3188 3252
 		if err != nil {
3189 3253
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3190 3254
 			return
@@ -3298,7 +3362,9 @@ func (c *PatientApiController) setAdviceWithJSON(advice *models.GroupAdvice, jso
3298 3362
 func (c *PatientApiController) DelDoctorAdvice() {
3299 3363
 	groupno, _ := c.GetInt64("groupno", -1)
3300 3364
 	is_sub, _ := c.GetInt64("is_sub", -1) //是否子药
3301
-
3365
+	patient_id, _ := c.GetInt64("patient_id")
3366
+	doc_advice_date, _ := c.GetInt64("advice_date")
3367
+	redis := service.RedisClient()
3302 3368
 	if is_sub == 1 { //是
3303 3369
 
3304 3370
 		advice_id, _ := c.GetInt64("advice_id")
@@ -3314,6 +3380,15 @@ func (c *PatientApiController) DelDoctorAdvice() {
3314 3380
 		advice.Modifier = adminUserInfo.AdminUser.Id
3315 3381
 
3316 3382
 		err := service.DeleteDoctorAdvice(&advice)
3383
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
3384
+
3385
+		redis.Set(key, "", time.Second)
3386
+
3387
+		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3388
+		redis.Set(keyTwo, "", time.Second)
3389
+		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3390
+		redis.Set(keyThree, "", time.Second)
3391
+		redis.Close()
3317 3392
 		if err != nil {
3318 3393
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
3319 3394
 			return
@@ -3366,9 +3441,30 @@ func (c *PatientApiController) DelDoctorAdvice() {
3366 3441
 
3367 3442
 		var err error
3368 3443
 		if groupno > 0 {
3444
+
3369 3445
 			err = service.DeleteDoctorAdviceByGroupNo(&advice)
3446
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
3447
+			fmt.Println("key2332323223323232323232323", key)
3448
+
3449
+			redis.Set(key, "", time.Second)
3450
+
3451
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3452
+			redis.Set(keyTwo, "", time.Second)
3453
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3454
+			redis.Set(keyThree, "", time.Second)
3370 3455
 		} else {
3456
+
3371 3457
 			err = service.BatchDeleteDoctorAdvice(ids, adminUserInfo.AdminUser.Id)
3458
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
3459
+
3460
+			redis.Set(key, "", time.Second)
3461
+			fmt.Println("key2332323223323232323232323", key)
3462
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3463
+			fmt.Println("key2332323223323232323232323", keyTwo)
3464
+			redis.Set(keyTwo, "", time.Second)
3465
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3466
+			redis.Set(keyThree, "", time.Second)
3467
+			redis.Close()
3372 3468
 		}
3373 3469
 
3374 3470
 		if err != nil {

+ 19 - 9
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -270,12 +270,14 @@ func (c *MobileHisApiController) DeletePrescription() {
270 270
 	projects, _ := service.GetHisPrescriptionProjectsByID(prescription_id)
271 271
 	advices, _ := service.GetHisPrescriptionAdviceByID(prescription_id)
272 272
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
273
-	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
273
+	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
274 274
 
275 275
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
276 276
 	if err == nil {
277 277
 		if len(projects) > 0 {
278 278
 			for _, item := range projects {
279
+				service.DeletePrintInfo(item.ID)
280
+
279 281
 				if item.Type == 3 { //处理透前准备耗材数量数据
280 282
 					consumables, _ := service.FindHisConsumablesByID(item.UserOrgId, item.PatientId, item.RecordDate, item.ProjectId)
281 283
 					if consumables.ID > 0 {
@@ -287,7 +289,7 @@ func (c *MobileHisApiController) DeletePrescription() {
287 289
 				if stockConfig.IsOpen == 1 {
288 290
 					if item.Type == 3 {
289 291
 						good, _ := service.FindGoodInfoByIdTwo(item.ProjectId)
290
-						f_count, _ := strconv.ParseFloat(strconv.FormatInt(int64(item.Count), 10), 64)
292
+						f_count, _ := strconv.ParseFloat(item.Count, 64)
291 293
 						good.Total = good.Total + f_count
292 294
 						service.UpdateGoodInfo(&good)
293 295
 					}
@@ -361,10 +363,11 @@ func (c *MobileHisApiController) DeleteProject() {
361 363
 
362 364
 	err := service.DelelteProject(id, c.GetMobileAdminUserInfo().Org.Id)
363 365
 	if err == nil {
366
+		service.DeletePrintInfo(id)
364 367
 		if stockConfig.IsOpen == 1 {
365 368
 			if project.Type == 3 {
366 369
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
367
-				f_count, _ := strconv.ParseFloat(strconv.FormatInt(int64(project.Count), 10), 64)
370
+				f_count, _ := strconv.ParseFloat(project.Count, 64)
368 371
 				good.Total = good.Total + f_count
369 372
 				service.UpdateGoodInfo(&good)
370 373
 			}
@@ -762,7 +765,8 @@ func (c *MobileHisApiController) CreateHisPrescription() {
762 765
 							if p.Type == 3 { //处理透前准备耗材数量数据
763 766
 								consumables, _ := service.FindHisConsumablesByID(adminInfo.Org.Id, patient_id, recordDateTime, p.ProjectId)
764 767
 								if consumables.ID > 0 {
765
-									consumables.Count = int64(p.Count)
768
+									cnt, _ := strconv.ParseInt(p.Count, 10, 64)
769
+									consumables.Count = cnt
766 770
 									service.UpdateConsumables(&consumables)
767 771
 								}
768 772
 							}
@@ -1086,8 +1090,8 @@ func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescript
1086 1090
 
1087 1091
 	if json["total"] != nil && reflect.TypeOf(json["total"]).String() == "string" {
1088 1092
 		total, _ := json["total"].(string)
1089
-		totals, _ := strconv.ParseInt(total, 10, 64)
1090
-		project.Count = totals
1093
+		//totals, _ := strconv.ParseInt(total, 10, 64)
1094
+		project.Count = total
1091 1095
 	}
1092 1096
 
1093 1097
 	if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
@@ -1127,7 +1131,7 @@ func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescript
1127 1131
 		if stockConfig.IsOpen == 1 {
1128 1132
 			if project.Type == 3 {
1129 1133
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
1130
-				f_count, _ := strconv.ParseFloat(strconv.FormatInt(int64(project.Count), 10), 64)
1134
+				f_count, _ := strconv.ParseFloat(project.Count, 64)
1131 1135
 				good.Total = good.Total - f_count
1132 1136
 				service.UpdateGoodInfo(&good)
1133 1137
 			}
@@ -1140,12 +1144,18 @@ func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescript
1140 1144
 			if project.Type == 3 {
1141 1145
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
1142 1146
 				if project.Count < temp_project.Count {
1143
-					other_count := temp_project.Count - project.Count
1147
+					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
1148
+					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
1149
+
1150
+					other_count := f_count_two - f_count_one
1144 1151
 					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
1145 1152
 					good.Total = good.Total + other_count_two
1146 1153
 					service.UpdateGoodInfo(&good)
1147 1154
 				} else if project.Count > temp_project.Count {
1148
-					other_count := project.Count - temp_project.Count
1155
+					f_count_one, _ := strconv.ParseFloat(project.Count, 64)
1156
+					f_count_two, _ := strconv.ParseFloat(temp_project.Count, 64)
1157
+
1158
+					other_count := f_count_one - f_count_two
1149 1159
 					other_count_two, _ := strconv.ParseFloat(strconv.FormatInt(int64(other_count), 10), 64)
1150 1160
 					good.Total = good.Total - other_count_two
1151 1161
 					service.UpdateGoodInfo(&good)

+ 42 - 53
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View File

@@ -189,14 +189,13 @@ func (this *NewDialysisApiController) SavePatient() {
189 189
 		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
190 190
 		ids = append(ids, id)
191 191
 	}
192
-	fmt.Print("传染病2", contagions)
192
+
193 193
 	is_infectious := int64(dataBody["is_infectious"].(float64))
194
-	fmt.Print("传染病", is_infectious)
194
+
195 195
 	adminssionNumber := dataBody["admissionNumber"].(string)
196
-	fmt.Print("住院号", adminssionNumber)
197 196
 
198 197
 	fistdate := dataBody["fistDate"].(string)
199
-	fmt.Print("首次透析日期", fistdate)
198
+
200 199
 	timeLayouts := "2006-01-02"
201 200
 	loc, _ := time.LoadLocation("Local")
202 201
 	times, err := time.ParseInLocation(timeLayouts+" 15:04:05", fistdate+" 00:00:00", loc)
@@ -205,14 +204,14 @@ func (this *NewDialysisApiController) SavePatient() {
205 204
 	fmt.Print(fisttime)
206 205
 
207 206
 	diagonse := dataBody["diagnose"].(string)
208
-	fmt.Print("诊断", diagonse)
207
+
209 208
 	avatar := dataBody["avatar"].(string)
210
-	fmt.Print("头像", avatar)
209
+
211 210
 	//慢性病
212 211
 	requipmentId := dataBody["requipmentId"].(string)
213
-	fmt.Print("设备ID", requipmentId)
212
+
214 213
 	slowContagions := dataBody["resultThree"].([]interface{})
215
-	fmt.Print("慢性传染病", slowContagions)
214
+
216 215
 	idss := make([]int64, 0)
217 216
 	for _, contagion := range slowContagions {
218 217
 		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
@@ -224,25 +223,23 @@ func (this *NewDialysisApiController) SavePatient() {
224 223
 		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
225 224
 		idsss = append(ids, id)
226 225
 	}
227
-	fmt.Print("慢性病", slowDiseases)
228 226
 
229 227
 	bloodPatient := int64(dataBody["bloodPatient"].(float64))
230
-	fmt.Print("血透病人", bloodPatient)
228
+
231 229
 	slowpatient := int64(dataBody["slowPatient"].(float64))
232
-	fmt.Print("慢病病人", slowpatient)
230
+
233 231
 	memberpatient := int64(dataBody["memberPatient"].(float64))
234
-	fmt.Print("会员病人", memberpatient)
232
+
235 233
 	//会员
236 234
 	memberFistDate := dataBody["memberFistDate"].(string)
237
-	fmt.Print("首次透析日期", memberFistDate)
235
+
238 236
 	//membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
239 237
 	membertimes, _ := time.ParseInLocation(timeLayouts+" 15:04:05", memberFistDate+" 00:00:00", loc)
240 238
 	memtime := membertimes.Unix()
241
-	fmt.Print("会员透析日期", memtime)
239
+
242 240
 	patient_type := int64(dataBody["patientType"].(float64))
243
-	fmt.Print("病种", patient_type)
241
+
244 242
 	treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
245
-	fmt.Print("治疗方式", treatmentmethod)
246 243
 
247 244
 	//查询身份证号码是否存在
248 245
 	thisPatientOne, _ := service.FindPatientByIdCardNoFive(orgid, idCard)
@@ -296,7 +293,6 @@ func (this *NewDialysisApiController) SavePatient() {
296 293
 		err = service.CreateOldPatient(&patients)
297 294
 		fmt.Print("报错", err)
298 295
 		patient, err := service.GetLastOldPatient(orgid)
299
-		fmt.Print("病人ID", patient.ID)
300 296
 		//添加转归
301 297
 		patientLapseto := models.PatientLapseto{
302 298
 			LapsetoType: lapseto,
@@ -336,6 +332,11 @@ func (this *NewDialysisApiController) SavePatient() {
336 332
 			RelativePhone:     relative_phone,
337 333
 		}
338 334
 		err = service.CreateNewPatient(&patientsNew)
335
+		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.ID, 10) + ":patient_info"
336
+		redis := service.RedisClient()
337
+		defer redis.Close()
338
+		//清空key 值
339
+		redis.Set(key, "", time.Second)
339 340
 		fmt.Print("报错", err)
340 341
 		if err != nil {
341 342
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -1234,55 +1235,46 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1234 1235
 
1235 1236
 	adminInfo := this.GetMobileAdminUserInfo()
1236 1237
 	orgid := adminInfo.Org.Id
1237
-	fmt.Print("机构ID", orgid)
1238 1238
 	dataBody := make(map[string]interface{}, 0)
1239 1239
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
1240 1240
 	fmt.Print("err", err)
1241 1241
 	id := int64(dataBody["id"].(float64))
1242
-	fmt.Print("id", id)
1243 1242
 	name := dataBody["name"].(string)
1244
-	fmt.Println("姓名", name)
1245 1243
 	sex := int64(dataBody["sex"].(float64))
1246
-	fmt.Print("性别", sex)
1247 1244
 	idCard := dataBody["idCard"].(string)
1248
-	fmt.Print("身份证", idCard)
1249 1245
 	birthday := dataBody["birthday"].(string)
1250 1246
 	births := strings.Split(birthday, "-")
1251
-	fmt.Print("生日", birthday)
1252 1247
 	birYear, _ := strconv.Atoi(births[0])
1253 1248
 	age := time.Now().Year() - birYear
1254 1249
 	ages := int64(age)
1255
-	fmt.Println("age是多少", ages)
1256 1250
 	timeLayout := "2006-01-02 15:04:05"
1257 1251
 	theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
1258 1252
 	birth := theTime.Unix()
1259 1253
 	fmt.Print(birth)
1260 1254
 	phone := dataBody["phone"].(string)
1261
-	fmt.Print("电话号码", phone)
1262 1255
 	relative_phone := dataBody["relative_phone"].(string)
1263 1256
 	patientType := dataBody["result"].([]interface{})
1264 1257
 	fmt.Print("患者标签", patientType)
1265 1258
 	dialysis := dataBody["dialysis"].(string)
1266
-	fmt.Print("透析号", dialysis)
1259
+
1267 1260
 	patientsoure := int64(dataBody["patientsoure"].(float64))
1268
-	fmt.Print("患者来源", patientsoure)
1261
+
1269 1262
 	lapseto := int64(dataBody["lapseto"].(float64))
1270
-	fmt.Print("留置状态", lapseto)
1263
+
1271 1264
 	contagions := dataBody["resultTwo"].([]interface{})
1272
-	fmt.Print("传染病", contagions)
1265
+
1273 1266
 	ids := make([]int64, 0)
1274 1267
 	for _, contagion := range contagions {
1275 1268
 		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
1276 1269
 		ids = append(ids, id)
1277 1270
 	}
1278
-	fmt.Print("传染病2", contagions)
1271
+
1279 1272
 	is_infectious := int64(dataBody["is_infectious"].(float64))
1280
-	fmt.Print("传染病", is_infectious)
1273
+
1281 1274
 	adminssionNumber := dataBody["admissionNumber"].(string)
1282
-	fmt.Print("住院号", adminssionNumber)
1283 1275
 
1284 1276
 	fistdate := dataBody["fistDate"].(string)
1285
-	fmt.Print("首次透析日期", fistdate)
1277
+
1286 1278
 	timeLayouts := "2006-01-02"
1287 1279
 	loc, _ := time.LoadLocation("Local")
1288 1280
 	times, err := time.ParseInLocation(timeLayouts+" 15:04:05", fistdate+" 00:00:00", loc)
@@ -1291,14 +1283,14 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1291 1283
 	fmt.Print(fisttime)
1292 1284
 
1293 1285
 	diagonse := dataBody["diagnose"].(string)
1294
-	fmt.Print("诊断", diagonse)
1286
+
1295 1287
 	avatar := dataBody["avatar"].(string)
1296
-	fmt.Print("头像", avatar)
1288
+
1297 1289
 	//慢性病
1298 1290
 	requipmentId := dataBody["requipmentId"].(string)
1299
-	fmt.Print("设备ID", requipmentId)
1291
+
1300 1292
 	slowContagions := dataBody["resultThree"].([]interface{})
1301
-	fmt.Print("慢性传染病", slowContagions)
1293
+
1302 1294
 	idss := make([]int64, 0)
1303 1295
 	for _, contagion := range slowContagions {
1304 1296
 		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
@@ -1312,27 +1304,26 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1312 1304
 		idsss = append(ids, id)
1313 1305
 	}
1314 1306
 	fmt.Print("idsss", idsss)
1315
-	fmt.Print("慢性病", slowDiseases)
1307
+
1316 1308
 	bloodPatient := int64(dataBody["bloodPatient"].(float64))
1317
-	fmt.Print("血透病人", bloodPatient)
1309
+
1318 1310
 	slowpatient := int64(dataBody["slowPatient"].(float64))
1319
-	fmt.Print("慢病病人", slowpatient)
1311
+
1320 1312
 	memberpatient := int64(dataBody["memberPatient"].(float64))
1321
-	fmt.Print("会员病人", memberpatient)
1313
+
1322 1314
 	//会员
1323 1315
 	memberFistDate := dataBody["memberFistDate"].(string)
1324
-	fmt.Print("首次透析日期", memberFistDate)
1316
+
1325 1317
 	//membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
1326 1318
 	membertimes, _ := time.ParseInLocation(timeLayouts+" 15:04:05", memberFistDate+" 00:00:00", loc)
1327 1319
 	memtime := membertimes.Unix()
1328
-	fmt.Print("会员透析日期", memtime)
1320
+
1329 1321
 	patient_type := int64(dataBody["patientType"].(float64))
1330
-	fmt.Print("病种", patient_type)
1322
+
1331 1323
 	treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
1332
-	fmt.Print("治疗方式", treatmentmethod)
1333 1324
 
1334 1325
 	deathtime := dataBody["death_time"].(string)
1335
-	fmt.Print("首次透析日期", deathtime)
1326
+
1336 1327
 	deathtimes, err := time.ParseInLocation(timeLayouts+" 15:04:05", deathtime+" 00:00:00", loc)
1337 1328
 	//times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
1338 1329
 	death_time := deathtimes.Unix()
@@ -1366,7 +1357,6 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1366 1357
 		//查询号透析号是否相同
1367 1358
 		thisPatientother, _ := service.FindPatientByDialysisNoOne(orgid, dialysis, id)
1368 1359
 		if thisPatientother.ID > 0 && thisPatientother.ID != patient.BloodId {
1369
-			fmt.Println("进来没有")
1370 1360
 			returnData := make(map[string]interface{}, 0)
1371 1361
 			returnData["msg"] = "透析号码已存在"
1372 1362
 			this.ServeSuccessJSON(returnData)
@@ -1396,12 +1386,11 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1396 1386
 			RelativePhone:     relative_phone,
1397 1387
 		}
1398 1388
 		err = service.UpdatedPatient(patients, patient.BloodId)
1399
-		//patientLapseto := models.PatientLapseto{
1400
-		//	LapsetoType: lapseto,
1401
-		//	LapsetoTime: time.Now().Unix(),
1402
-		//	UpdatedTime: time.Now().Unix(),
1403
-		//}
1404
-		//err = service.UpdatePatientLapseto(patient.BloodId, patientLapseto)
1389
+		key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient.BloodId, 10) + ":patient_info"
1390
+		redis := service.RedisClient()
1391
+		defer redis.Close()
1392
+		//清空key 值
1393
+		redis.Set(key, "", time.Second)
1405 1394
 		fmt.Println("编辑转归失败", err)
1406 1395
 		patientsNew := models.XtPatientsNew{
1407 1396
 			ID:                id,

+ 18 - 1
controllers/patient_api_controller.go View File

@@ -1414,7 +1414,12 @@ func (c *PatientApiController) CreateGroupAdvice() {
1414 1414
 	}
1415 1415
 
1416 1416
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
1417
-
1417
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
1418
+	redis := service.RedisClient()
1419
+	defer redis.Close()
1420
+	redis.Set(key, "", time.Second)
1421
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
1422
+	redis.Set(keyOne, "", time.Second)
1418 1423
 	if err != nil {
1419 1424
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1420 1425
 		return
@@ -1497,6 +1502,12 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1497 1502
 	advice.AdviceDoctor = adminUserInfo.AdminUser.Id
1498 1503
 
1499 1504
 	err := service.CreateDoctorAdvice(&advice)
1505
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1506
+	redis := service.RedisClient()
1507
+	defer redis.Close()
1508
+	redis.Set(key, "", time.Second)
1509
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
1510
+	redis.Set(keyOne, "", time.Second)
1500 1511
 	if err != nil {
1501 1512
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1502 1513
 		return
@@ -2199,6 +2210,12 @@ func (c *PatientApiController) UpdateDoctorAdvice() {
2199 2210
 	advice.Modifier = adminUserInfo.AdminUser.Id
2200 2211
 
2201 2212
 	err := service.UpdateDoctorAdvice(&advice)
2213
+	redis := service.RedisClient()
2214
+	defer redis.Close()
2215
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
2216
+	redis.Set(key, "", time.Second)
2217
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2218
+	redis.Set(keyOne, "", time.Second)
2202 2219
 	if err != nil {
2203 2220
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
2204 2221
 		return

+ 22 - 2
controllers/schedule_api_controller.go View File

@@ -367,13 +367,33 @@ func (c *ScheduleApiController) CreateSchedule() {
367 367
 	}
368 368
 
369 369
 	redis := service.RedisClient()
370
-	defer redis.Close()
371 370
 	err = service.CreateSchedule(&schedule)
372
-
373 371
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
372
+
374 373
 	redis.Set(key, "", time.Second)
374
+	//处方
375
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
376
+	redis.Set(keyOne, "", time.Second)
377
+
378
+	//医嘱
379
+	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
380
+	redis.Set(keyTwo, "", time.Second)
375 381
 
382
+	keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_befores_list_all"
383
+	redis.Set(keySix, "", time.Second)
384
+	keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_after_dislysis_list_all"
385
+	redis.Set(keyThree, "", time.Second)
386
+
387
+	keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":monitor_record_list_all"
388
+	redis.Set(keyFour, "", time.Second)
389
+
390
+	keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":treatment_summarys_list_all"
391
+	redis.Set(keyFive, "", time.Second)
392
+
393
+	keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
394
+	redis.Set(keySeven, "", time.Second)
376 395
 	fmt.Println(err)
396
+	defer redis.Close()
377 397
 	if err != nil {
378 398
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
379 399
 		return

+ 1 - 0
models/good_models.go View File

@@ -79,6 +79,7 @@ type GoodInfo struct {
79 79
 	Total                       float64              `gorm:"column:total" json:"total" form:"total"`
80 80
 	StWarehousingInfo           []*StWarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"xt_warehouse_info"`
81 81
 	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
82
+	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
82 83
 }
83 84
 
84 85
 func (GoodInfo) TableName() string {

+ 34 - 8
models/his_charge_models.go View File

@@ -1,14 +1,14 @@
1 1
 package models
2 2
 
3 3
 type HisChargePrescriptionProject struct {
4
-	ID         int64 `gorm:"column:id" json:"id" form:"id"`
5
-	ProjectId  int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
-	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
-	Status     int64 `gorm:"column:status" json:"status" form:"status"`
8
-	PatientId  int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
-	RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
-	Count      int64 `gorm:"column:count" json:"count" form:"count"`
11
-	Type       int64 `gorm:"column:type" json:"type" form:"type"`
4
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
5
+	ProjectId  int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
6
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
7
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
8
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
10
+	Count      string `gorm:"column:count" json:"count" form:"count"`
11
+	Type       int64  `gorm:"column:type" json:"type" form:"type"`
12 12
 
13 13
 	HisChargeProject  HisChargeProject  `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"project"`
14 14
 	HisChargeGoodInfo HisChargeGoodInfo `gorm:"ForeignKey:ProjectId;AssociationForeignKey:ID" json:"good_info"`
@@ -172,8 +172,34 @@ type HisChargeGoodInfo struct {
172 172
 	GoodName           string `gorm:"column:good_name" json:"good_name" form:"good_name"`
173 173
 	GoodUnit           int64  `gorm:"column:good_unit" json:"good_unit"`
174 174
 	SpecificationnName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
175
+	RegisterNumber     string `gorm:"column:register_number" json:"register_number" form:"register_number"`
175 176
 }
176 177
 
177 178
 func (HisChargeGoodInfo) TableName() string {
178 179
 	return "xt_good_information"
179 180
 }
181
+
182
+type HisLabelPrintInfo struct {
183
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
184
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
185
+	Number      string `gorm:"column:number" json:"number" form:"number"`
186
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
187
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
188
+	DoctorId    int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
189
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
190
+	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
191
+	ProjectId   int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
192
+	IsPrint     int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
193
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
194
+	ItemId      int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
195
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
196
+	PProjectId  int64  `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
197
+
198
+	FeedetlSn   string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
199
+	DoctorName  string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
200
+	PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
201
+}
202
+
203
+func (HisLabelPrintInfo) TableName() string {
204
+	return "his_label_print_info"
205
+}

+ 160 - 4
models/his_models.go View File

@@ -467,9 +467,8 @@ type TempHisOrder struct {
467 467
 	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
468 468
 	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
469 469
 	AccountPrice          float64   `gorm:"column:account_price" json:"account_price" form:"account_price"`
470
-
471
-	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
472
-	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
470
+	FaPiaoCode            string    `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
471
+	FaPiaoNumber          string    `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
473 472
 
474 473
 	AdminUser AdminUser `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
475 474
 
@@ -508,6 +507,7 @@ type HisPrescription struct {
508 507
 	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"project"`
509 508
 	HisAdditionalCharge    []*HisAdditionalCharge    `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
510 509
 	HisPrescriptionInfo    HisPrescriptionInfo       `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"info"`
510
+	HisOrder               HisOrder                  `gorm:"ForeignKey:PrescriptionId;AssociationForeignKey:ID" json:"addition"`
511 511
 	Total                  string                    `gorm:"-" json:"total" form:"total"`
512 512
 	PType                  int64                     `gorm:"column:p_type" json:"p_type" form:"p_type"`
513 513
 	MedType                string                    `gorm:"column:med_type" json:"med_type" form:"med_type"`
@@ -749,7 +749,7 @@ type HisPrescriptionProject struct {
749 749
 	HisPatientId       int64      `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
750 750
 	RecordDate         int64      `gorm:"column:record_date" json:"record_date" form:"record_date"`
751 751
 	PrescriptionId     int64      `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
752
-	Count              int64      `gorm:"column:count" json:"count" form:"count"`
752
+	Count              string     `gorm:"column:count" json:"count" form:"count"`
753 753
 	FeedetlSn          string     `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
754 754
 	MedListCodg        string     `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
755 755
 	SingleDose         string     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
@@ -778,6 +778,7 @@ type HisPrescriptionProject struct {
778 778
 	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
779 779
 	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
780 780
 	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
781
+	IsCheckTeam   int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
781 782
 }
782 783
 
783 784
 func (HisPrescriptionProject) TableName() string {
@@ -1015,6 +1016,49 @@ func (HisOrderInfo) TableName() string {
1015 1016
 	return "his_order_info"
1016 1017
 }
1017 1018
 
1019
+type HisOrderInfoTwo struct {
1020
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1021
+	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1022
+	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1023
+	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1024
+	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1025
+	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
1026
+	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
1027
+	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1028
+	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
1029
+	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
1030
+	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1031
+	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
1032
+	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1033
+	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
1034
+	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1035
+	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
1036
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1037
+	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
1038
+	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1039
+	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1040
+	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1041
+	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
1042
+	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1043
+	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
1044
+	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1045
+	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1046
+	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1047
+	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1048
+	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1049
+	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
1050
+	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1051
+	Type             int64   `gorm:"column:type" json:"type" form:"type"`
1052
+	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1053
+
1054
+	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1055
+	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1056
+}
1057
+
1058
+func (HisOrderInfoTwo) TableName() string {
1059
+	return "his_order_info"
1060
+}
1061
+
1018 1062
 type VMHisPatient struct {
1019 1063
 	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1020 1064
 	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
@@ -1475,3 +1519,115 @@ type NewHisOrder struct {
1475 1519
 func (NewHisOrder) TableName() string {
1476 1520
 	return "his_order"
1477 1521
 }
1522
+
1523
+type VMHisOrderTwo struct {
1524
+	ID                    int64     `gorm:"column:id" json:"id" form:"id"`
1525
+	UserOrgId             int64     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1526
+	HisPatientId          int64     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1527
+	SettleAccountsDate    int64     `gorm:"column:settle_accounts_date" json:"settle_accounts_date" form:"settle_accounts_date"`
1528
+	Ctime                 int64     `gorm:"column:ctime" json:"ctime" form:"ctime"`
1529
+	Mtime                 int64     `gorm:"column:mtime" json:"mtime" form:"mtime"`
1530
+	Status                int64     `gorm:"column:status" json:"status" form:"status"`
1531
+	Number                string    `gorm:"column:number" json:"number" form:"number"`
1532
+	PatientId             int64     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1533
+	Infcode               int64     `gorm:"column:infcode" json:"infcode" form:"infcode"`
1534
+	WarnMsg               string    `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
1535
+	Cainfo                string    `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
1536
+	ErrMsg                string    `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
1537
+	RespondTime           string    `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
1538
+	InfRefmsgid           string    `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
1539
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status" form:"order_status"`
1540
+	MdtrtId               string    `gorm:"column:mdtrt_id" json:"mdtrt_id" form:"mdtrt_id"`
1541
+	SetlId                string    `gorm:"column:setl_id" json:"setl_id" form:"setl_id"`
1542
+	PsnNo                 string    `gorm:"column:psn_no" json:"psn_no" form:"psn_no"`
1543
+	PsnName               string    `gorm:"column:psn_name" json:"psn_name" form:"psn_name"`
1544
+	PsnCertType           string    `gorm:"column:psn_cert_type" json:"psn_cert_type" form:"psn_cert_type"`
1545
+	Certno                string    `gorm:"column:certno" json:"certno" form:"certno"`
1546
+	Gend                  string    `gorm:"column:gend" json:"gend" form:"gend"`
1547
+	Naty                  string    `gorm:"column:naty" json:"naty" form:"naty"`
1548
+	Brdy                  time.Time `gorm:"column:brdy" json:"brdy" form:"brdy"`
1549
+	Age                   float64   `gorm:"column:age" json:"age" form:"age"`
1550
+	Insutype              string    `gorm:"column:insutype" json:"insutype" form:"insutype"`
1551
+	PsnType               string    `gorm:"column:psn_type" json:"psn_type" form:"psn_type"`
1552
+	CvlservFlag           string    `gorm:"column:cvlserv_flag" json:"cvlserv_flag" form:"cvlserv_flag"`
1553
+	SetlTime              string    `gorm:"column:setl_time" json:"setl_time" form:"setl_time"`
1554
+	MdtrtCertType         string    `gorm:"column:mdtrt_cert_type" json:"mdtrt_cert_type" form:"mdtrt_cert_type"`
1555
+	MedType               string    `gorm:"column:med_type" json:"med_type" form:"med_type"`
1556
+	MedfeeSumamt          float64   `gorm:"column:medfee_sumamt" json:"medfee_sumamt" form:"medfee_sumamt"`
1557
+	FulamtOwnpayAmt       float64   `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1558
+	OverlmtSelfPay        float64   `gorm:"column:overlmt_self_pay" json:"overlmt_self_pay" form:"overlmt_self_pay"`
1559
+	PreselfpayAmt         float64   `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1560
+	InscpScpAmt           float64   `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1561
+	ActPayDedc            float64   `gorm:"column:act_pay_dedc" json:"act_pay_dedc" form:"act_pay_dedc"`
1562
+	HifpPay               float64   `gorm:"column:hifp_pay" json:"hifp_pay" form:"hifp_pay"`
1563
+	CvlservPay            float64   `gorm:"column:cvlserv_pay" json:"cvlserv_pay" form:"cvlserv_pay"`
1564
+	PoolPropSelfpay       float64   `gorm:"column:pool_prop_selfpay" json:"pool_prop_selfpay" form:"pool_prop_selfpay"`
1565
+	HifesPay              float64   `gorm:"column:hifes_pay" json:"hifes_pay" form:"hifes_pay"`
1566
+	HifmiPay              float64   `gorm:"column:hifmi_pay" json:"hifmi_pay" form:"hifmi_pay"`
1567
+	HifobPay              float64   `gorm:"column:hifob_pay" json:"hifob_pay" form:"hifob_pay"`
1568
+	MafPay                float64   `gorm:"column:maf_pay" json:"maf_pay" form:"maf_pay"`
1569
+	OthPay                float64   `gorm:"column:oth_pay" json:"oth_pay" form:"oth_pay"`
1570
+	FundPaySumamt         float64   `gorm:"column:fund_pay_sumamt" json:"fund_pay_sumamt" form:"fund_pay_sumamt"`
1571
+	PsnPartAmt            float64   `gorm:"column:psn_part_amt" json:"psn_part_amt" form:"psn_part_amt"`
1572
+	AcctPay               float64   `gorm:"column:acct_pay" json:"acct_pay" form:"acct_pay"`
1573
+	PsnCashPay            float64   `gorm:"column:psn_cash_pay" json:"psn_cash_pay" form:"psn_cash_pay"`
1574
+	HospPartAmt           float64   `gorm:"column:hosp_part_amt" json:"hosp_part_amt" form:"hosp_part_amt"`
1575
+	Balc                  float64   `gorm:"column:balc" json:"balc" form:"balc"`
1576
+	AcctMulaidPay         float64   `gorm:"column:acct_mulaid_pay" json:"acct_mulaid_pay" form:"acct_mulaid_pay"`
1577
+	MedinsSetlId          string    `gorm:"column:medins_setl_id" json:"medins_setl_id" form:"medins_setl_id"`
1578
+	ClrOptins             string    `gorm:"column:clr_optins" json:"clr_optins" form:"clr_optins"`
1579
+	ClrWay                string    `gorm:"column:clr_way" json:"clr_way" form:"clr_way"`
1580
+	ClrType               string    `gorm:"column:clr_type" json:"clr_type" form:"clr_type"`
1581
+	SetlDetail            string    `gorm:"column:setl_detail" json:"setl_detail" form:"setl_detail"`
1582
+	IsMedicineInsurance   int64     `gorm:"column:is_medicine_insurance" json:"is_medicine_insurance" form:"is_medicine_insurance"`
1583
+	PayWay                int64     `gorm:"column:pay_way" json:"pay_way" form:"pay_way"`
1584
+	PayPrice              float64   `gorm:"column:pay_price" json:"pay_price" form:"pay_price"`
1585
+	PayCardNo             string    `gorm:"column:pay_card_no" json:"pay_card_no" form:"pay_card_no"`
1586
+	DiscountPrice         float64   `gorm:"column:discount_price" json:"discount_price" form:"discount_price"`
1587
+	PreferentialPrice     float64   `gorm:"column:preferential_price" json:"preferential_price" form:"preferential_price"`
1588
+	RealityPrice          float64   `gorm:"column:reality_price" json:"reality_price" form:"reality_price"`
1589
+	FoundPrice            float64   `gorm:"column:found_price" json:"found_price" form:"found_price"`
1590
+	MedicalInsurancePrice float64   `gorm:"column:medical_insurance_price" json:"medical_insurance_price" form:"medical_insurance_price"`
1591
+	PrivatePrice          float64   `gorm:"column:private_price" json:"private_price" form:"private_price"`
1592
+	DepartmentName        string    `gorm:"-" json:"department_name" form:"department_name"`
1593
+	DoctorName            string    `gorm:"-" json:"doctor_name" form:"doctor_name"`
1594
+	Creator               int64     `gorm:"column:creator" json:"creator" form:"creator"`
1595
+	PType                 int64     `gorm:"column:p_type" json:"p_type" form:"p_type"`
1596
+
1597
+	FaPiaoCode   string `gorm:"column:fa_piao_code" json:"fa_piao_code" form:"fa_piao_code"`
1598
+	FaPiaoNumber string `gorm:"column:fa_piao_number" json:"fa_piao_number" form:"fa_piao_number"`
1599
+
1600
+	AdminUser AdminUser `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
1601
+
1602
+	SettleType      int64 `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
1603
+	SettleStartTime int64 `gorm:"column:settle_start_time" json:"settle_start_time" form:"settle_start_time"`
1604
+	SettleEndTime   int64 `gorm:"column:settle_end_time" json:"settle_end_time" form:"settle_end_time"`
1605
+
1606
+	HisOrderInfo           HisOrderInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"order_info"`
1607
+	Patients               Patients               `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
1608
+	HisPatient             HisPatient             `gorm:"ForeignKey:MdtrtId;AssociationForeignKey:Number" json:"his_patient"`
1609
+	HisHospitalCheckRecord HisHospitalCheckRecord `gorm:"ForeignKey:MdtrtId,PatientId;AssociationForeignKey:Number,PatientId" json:"his_hospital_patient"`
1610
+
1611
+	HisPrescriptionInfo HisPrescriptionInfo `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"p_info"`
1612
+
1613
+	HisFundSettleListResult HisFundSettleListResult `gorm:"ForeignKey:ID;AssociationForeignKey:OrderId" json:"result"`
1614
+	IsPre                   int64                   `gorm:"column:is_pre" json:"is_pre" form:"is_pre"`
1615
+	Diagnosis               string                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
1616
+}
1617
+
1618
+func (VMHisOrderTwo) TableName() string {
1619
+	return "his_order"
1620
+}
1621
+
1622
+type HisStockPriceConfig struct {
1623
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
1624
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1625
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1626
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1627
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
1628
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
1629
+}
1630
+
1631
+func (HisStockPriceConfig) TableName() string {
1632
+	return "his_stock_price_config"
1633
+}

+ 2 - 1
models/patient_models.go View File

@@ -335,7 +335,7 @@ type DialysisPrescriptionList struct {
335 335
 	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
336 336
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
337 337
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
338
-
338
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
339 339
 	HemodialysisPipelines      string  `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
340 340
 	HemodialysisPipelinesCount float64 `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
341 341
 	PunctureNeedle             string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
@@ -439,6 +439,7 @@ type DialysisSolution struct {
439 439
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
440 440
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
441 441
 	MaxUltrafiltrationRate     float64 `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
442
+	PreImpulse                 float64 `gorm:"column:pre_impulse" json:"pre_impulse" form:"pre_impulse"`
442 443
 }
443 444
 
444 445
 func (DialysisSolution) TableName() string {

+ 19 - 0
models/stock_models.go View File

@@ -1104,3 +1104,22 @@ type SgjCancelStockInfo struct {
1104 1104
 	RetailPrice       float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
1105 1105
 	PackingPrice      float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
1106 1106
 }
1107
+
1108
+type PatientWarehouseInfo struct {
1109
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
1110
+	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1111
+	Number            string `gorm:"column:number" json:"number" form:"number"`
1112
+	ProductDate       int64  `gorm:"column:product_date" json:"product_date" form:"product_date"`
1113
+	ExpiryDate        int64  `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1114
+	WarehousingUnit   string `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1115
+	Dealer            int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1116
+	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1117
+	GoodName          string `gorm:"column:good_name" json:"good_name"`
1118
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1119
+	PackingUnit       string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1120
+	Remark            string `gorm:"column:remark" json:"remark" form:"remark"`
1121
+}
1122
+
1123
+func (PatientWarehouseInfo) TableName() string {
1124
+	return "xt_warehouse_info"
1125
+}

+ 44 - 0
service/device_service.go View File

@@ -2,8 +2,10 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
+	"encoding/json"
5 6
 	"fmt"
6 7
 	"github.com/jinzhu/gorm"
8
+	"strconv"
7 9
 	"strings"
8 10
 	"time"
9 11
 )
@@ -720,3 +722,45 @@ func GetPatientInfectious(id int64) (infectious []*models.InfectiousDiseases, er
720 722
 	err = XTReadDB().Where("patient_id=? and status=1", id).Find(&infectious).Error
721 723
 	return infectious, err
722 724
 }
725
+
726
+func GetPatientIdOne(patient_id int64, orgId int64) (models.XtPatientsNew, error) {
727
+
728
+	patientsNew := models.XtPatientsNew{}
729
+	redis := RedisClient()
730
+	defer redis.Close()
731
+	key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":patient_info"
732
+
733
+	patient_info_str, _ := redis.Get(key).Result()
734
+
735
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
736
+		err = readDb.Model(&models.Patients{}).Where("blood_id = ? and user_org_id=? and status=1", patient_id, orgId).First(&patientsNew).Error
737
+		if err != nil {
738
+			if err == gorm.ErrRecordNotFound {
739
+				return patientsNew, nil
740
+			} else {
741
+				return patientsNew, err
742
+			}
743
+		} else {
744
+			if patientsNew.ID > 0 {
745
+				//缓存数据
746
+				patient_info_json, err := json.Marshal(&patientsNew)
747
+
748
+				if err == nil {
749
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
750
+				}
751
+			} else {
752
+				redis.Set(key, "null", time.Second*60*60*18)
753
+			}
754
+			return patientsNew, nil
755
+		}
756
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
757
+
758
+		if patient_info_str == "null" {
759
+			return patientsNew, nil
760
+		} else {
761
+			json.Unmarshal([]byte(patient_info_str), &patientsNew)
762
+			return patientsNew, nil
763
+		}
764
+
765
+	}
766
+}

+ 301 - 2
service/dialysis_service.go View File

@@ -649,14 +649,33 @@ func GetDialysisScheduals(orgID int64, scheduleDate int64) ([]*MDialysisSchedule
649 649
 		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
650 650
 		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
651 651
 		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
652
-		// Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
653 652
 		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
654 653
 		Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND  assessment_date = ?", orgID, scheduleDate).
655 654
 		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
656 655
 		Preload("TreatmentSummary", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
657 656
 		Preload("Advices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
658 657
 		Preload("AssessmentAfterDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
659
-		// Preload("DialysisOrder.MonitoringRecords", "status = 1 AND user_org_id = ?", orgID).
658
+		Where("status = 1 AND user_org_id = ?", orgID)
659
+	if scheduleDate != 0 {
660
+		db = db.Where("schedule_date = ?", scheduleDate)
661
+	}
662
+
663
+	err := db.Find(&vms).Error
664
+	return vms, err
665
+}
666
+
667
+func GetDialysisSchedualsOne(orgID int64, scheduleDate int64) ([]*MDialysisScheduleVM, error) {
668
+	var vms []*MDialysisScheduleVM
669
+	db := readDb.
670
+		Table("xt_schedule").
671
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
672
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
673
+		//Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
674
+		//Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND  assessment_date = ?", orgID, scheduleDate).
675
+		//Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
676
+		//Preload("TreatmentSummary", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
677
+		//Preload("Advices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
678
+		//Preload("AssessmentAfterDislysis", "status = 1 AND user_org_id = ? and assessment_date = ?", orgID, scheduleDate).
660 679
 		Where("status = 1 AND user_org_id = ?", orgID)
661 680
 	if scheduleDate != 0 {
662 681
 		db = db.Where("schedule_date = ?", scheduleDate)
@@ -1096,11 +1115,95 @@ func GetLastLongAdviceByGroupNo(orgId int64, patient_id int64) (advice []*models
1096 1115
 	return
1097 1116
 }
1098 1117
 
1118
+func GetLastLongAdviceByGroupNoOne(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1119
+
1120
+	redis := RedisClient()
1121
+	defer redis.Close()
1122
+	key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":long_advice"
1123
+	long_advice_str, _ := redis.Get(key).Result()
1124
+
1125
+	if len(long_advice_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1126
+		err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1127
+		if err != nil {
1128
+			if err == gorm.ErrRecordNotFound {
1129
+				return nil, nil
1130
+			} else {
1131
+				return nil, err
1132
+			}
1133
+		} else {
1134
+			if len(advice) > 0 {
1135
+				//缓存数据
1136
+				starfes_str, err := json.Marshal(advice)
1137
+				if err == nil {
1138
+					redis.Set(key, starfes_str, time.Second*60*60*18)
1139
+					return advice, nil
1140
+				}
1141
+			} else {
1142
+				redis.Set(key, "null", time.Second*60*60*18)
1143
+				return advice, nil
1144
+			}
1145
+			return advice, nil
1146
+		}
1147
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1148
+		if long_advice_str == "null" {
1149
+			return advice, nil
1150
+		} else {
1151
+			json.Unmarshal([]byte(long_advice_str), &advice)
1152
+			return advice, nil
1153
+		}
1154
+	}
1155
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1156
+	return
1157
+}
1158
+
1099 1159
 func GetLastLongAdviceByGroupNoThree(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1100 1160
 	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 ", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1101 1161
 	return
1102 1162
 }
1103 1163
 
1164
+func GetLastLongAdviceByGroupNoFour(orgId int64, patient_id int64) (advice []*models.DoctorAdvice, err error) {
1165
+	//err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 ", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1166
+	//return
1167
+
1168
+	redis := RedisClient()
1169
+	defer redis.Close()
1170
+	key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":long_advice"
1171
+	long_advice_str, _ := redis.Get(key).Result()
1172
+
1173
+	if len(long_advice_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1174
+		err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND  advice_type = 1 AND frequency_type = 2 AND stop_state = 2 AND parent_id = 0 ", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1175
+		if err != nil {
1176
+			if err == gorm.ErrRecordNotFound {
1177
+				return nil, nil
1178
+			} else {
1179
+				return nil, err
1180
+			}
1181
+		} else {
1182
+			if len(advice) > 0 {
1183
+				//缓存数据
1184
+				starfes_str, err := json.Marshal(advice)
1185
+				if err == nil {
1186
+					redis.Set(key, starfes_str, time.Second*60*60*18)
1187
+					return advice, nil
1188
+				}
1189
+			} else {
1190
+				redis.Set(key, "null", time.Second*60*60*18)
1191
+				return advice, nil
1192
+			}
1193
+			return advice, nil
1194
+		}
1195
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1196
+		if long_advice_str == "null" {
1197
+			return advice, nil
1198
+		} else {
1199
+			json.Unmarshal([]byte(long_advice_str), &advice)
1200
+			return advice, nil
1201
+		}
1202
+	}
1203
+	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 1  AND stop_state = 2 AND parent_id = 0 AND frequency_type <> 0", orgId, patient_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1204
+	return
1205
+}
1206
+
1104 1207
 func FindAllDoctorAdviceByTime(now int64, end int64, patient_id int64, orgId int64, temp_id string) (advice []*models.DoctorAdvice, err error) {
1105 1208
 	err = readDb.Model(&models.DoctorAdvice{}).Where("status = 1 AND user_org_id = ? AND patient_id = ? AND advice_type = 2   AND advice_date > ? AND advice_date <= ? AND template_id = ?  ", orgId, patient_id, end, now, temp_id).Preload("ChildDoctorAdvice", "status = 1").Find(&advice).Error
1106 1209
 	return
@@ -1281,3 +1384,199 @@ func FindAllHisProjectById(orgID int64, patient_id int64, record_time int64) (ad
1281 1384
 	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id=? and status=1 and patient_id = ? AND record_date = ?", orgID, patient_id, record_time).Find(&advice).Error
1282 1385
 	return
1283 1386
 }
1387
+
1388
+func GetAllPcPatientListByList(orgID int64) (patients []*MSchedualPatientVMList, err error) {
1389
+	redis := RedisClient()
1390
+	defer redis.Close()
1391
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
1392
+	patient_info_str, _ := redis.Get(key).Result()
1393
+
1394
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1395
+		err = readDb.Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
1396
+		if err != nil {
1397
+			if err == gorm.ErrRecordNotFound {
1398
+				if len(patients) <= 0 {
1399
+					redis.Set(key, "null", time.Second*60*60*18)
1400
+				}
1401
+				return nil, nil
1402
+			} else {
1403
+				return nil, err
1404
+			}
1405
+		} else {
1406
+			if len(patients) > 0 {
1407
+				//缓存数据
1408
+				patient_info_json, err := json.Marshal(&patients)
1409
+				if err == nil {
1410
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
1411
+				}
1412
+			} else {
1413
+				redis.Set(key, "null", time.Second*60*60*18)
1414
+			}
1415
+			return patients, nil
1416
+		}
1417
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1418
+		if patient_info_str == "null" {
1419
+			return nil, nil
1420
+		} else {
1421
+			json.Unmarshal([]byte(patient_info_str), &patients)
1422
+			return patients, nil
1423
+		}
1424
+	}
1425
+}
1426
+
1427
+func GetAllPcAdvicestByList(orgID int64, scheduleDate int64) (advices []*VMDoctorAdvice, err error) {
1428
+	redis := RedisClient()
1429
+	defer redis.Close()
1430
+	key := strconv.FormatInt(orgID, 10) + ":" + ":advice_list_all"
1431
+	advice_list_str, _ := redis.Get(key).Result()
1432
+
1433
+	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1434
+		err = readDb.Where("status = 1 AND user_org_id = ? AND advice_type = 2 AND advice_date = ? ", orgID, scheduleDate).Find(&advices).Error
1435
+		if err != nil {
1436
+			if err == gorm.ErrRecordNotFound {
1437
+				if len(advices) <= 0 {
1438
+					redis.Set(key, "null", time.Second*60*60*18)
1439
+				}
1440
+				return nil, nil
1441
+			} else {
1442
+				return nil, err
1443
+			}
1444
+		} else {
1445
+			if len(advices) > 0 {
1446
+				//缓存数据
1447
+				advice_list_str, err := json.Marshal(&advices)
1448
+				if err == nil {
1449
+					redis.Set(key, advice_list_str, time.Second*60*60*18)
1450
+				}
1451
+			} else {
1452
+				redis.Set(key, "null", time.Second*60*60*18)
1453
+			}
1454
+			return advices, nil
1455
+		}
1456
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1457
+		if advice_list_str == "null" {
1458
+			return nil, nil
1459
+		} else {
1460
+			json.Unmarshal([]byte(advice_list_str), &advices)
1461
+			return advices, nil
1462
+		}
1463
+
1464
+	}
1465
+}
1466
+
1467
+func GetAllPcDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVMList, err error) {
1468
+	redis := RedisClient()
1469
+	defer redis.Close()
1470
+	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
1471
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
1472
+
1473
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1474
+		err = readDb.Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
1475
+
1476
+		if err != nil {
1477
+			if err == gorm.ErrRecordNotFound {
1478
+				return nil, nil
1479
+			} else {
1480
+				return nil, err
1481
+			}
1482
+		} else {
1483
+			if len(dialysisOrders) > 0 {
1484
+				//缓存数据
1485
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
1486
+				if err == nil {
1487
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
1488
+				}
1489
+			} else {
1490
+				redis.Set(key, "null", time.Second*60*60*18)
1491
+			}
1492
+			return dialysisOrders, nil
1493
+		}
1494
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1495
+		if dialysis_orders_list_all == "null" {
1496
+			return nil, nil
1497
+		} else {
1498
+			json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
1499
+			return dialysisOrders, nil
1500
+		}
1501
+
1502
+	}
1503
+}
1504
+
1505
+func GetAllPcAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*AssessmentAfterDislysis, err error) {
1506
+	redis := RedisClient()
1507
+	defer redis.Close()
1508
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
1509
+	assessment_after_dislysis__all, _ := redis.Get(key).Result()
1510
+
1511
+	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1512
+		err = readDb.Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
1513
+		if err != nil {
1514
+			if err == gorm.ErrRecordNotFound {
1515
+				if len(assessmentAfterDislysis) <= 0 {
1516
+					redis.Set(key, "null", time.Second*60*60*18)
1517
+				}
1518
+				return nil, nil
1519
+			} else {
1520
+				return nil, err
1521
+			}
1522
+		} else {
1523
+			if len(assessmentAfterDislysis) > 0 {
1524
+				//缓存数据
1525
+				assessment_after_dislysis__all, err := json.Marshal(&assessmentAfterDislysis)
1526
+				if err == nil {
1527
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
1528
+				}
1529
+			} else {
1530
+				redis.Set(key, "null", time.Second*60*60*18)
1531
+			}
1532
+			return assessmentAfterDislysis, nil
1533
+		}
1534
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1535
+		if assessment_after_dislysis__all == "null" {
1536
+			return nil, nil
1537
+		} else {
1538
+			json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
1539
+			return assessmentAfterDislysis, nil
1540
+		}
1541
+
1542
+	}
1543
+}
1544
+
1545
+func GetAllPcTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*VMTreatmentSummary, err error) {
1546
+	redis := RedisClient()
1547
+	defer redis.Close()
1548
+	key := strconv.FormatInt(orgID, 10) + ":" + ":treatment_summarys_list_all"
1549
+	treatment_summarys_all, _ := redis.Get(key).Result()
1550
+
1551
+	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1552
+		err = readDb.Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&treatmentSummarys).Error
1553
+		if err != nil {
1554
+			if err == gorm.ErrRecordNotFound {
1555
+				if len(treatment_summarys_all) <= 0 {
1556
+					redis.Set(key, "null", time.Second*60*60*18)
1557
+				}
1558
+				return nil, nil
1559
+			} else {
1560
+				return nil, err
1561
+			}
1562
+		} else {
1563
+			if len(treatmentSummarys) > 0 {
1564
+				//缓存数据
1565
+				treatment_summarys_all, err := json.Marshal(&treatmentSummarys)
1566
+				if err == nil {
1567
+					redis.Set(key, treatment_summarys_all, time.Second*60*60*18)
1568
+				}
1569
+			} else {
1570
+				redis.Set(key, "null", time.Second*60*60*18)
1571
+			}
1572
+			return treatmentSummarys, nil
1573
+		}
1574
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1575
+		if treatment_summarys_all == "null" {
1576
+			return nil, nil
1577
+		} else {
1578
+			json.Unmarshal([]byte(treatment_summarys_all), &treatmentSummarys)
1579
+			return treatmentSummarys, nil
1580
+		}
1581
+	}
1582
+}

+ 3 - 3
service/gdyb_service.go View File

@@ -384,10 +384,10 @@ func Gdyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescri
384 384
 				//var randNum int
385 385
 				//randNum = rand.Intn(10000) + 1000
386 386
 				if len(subItem.MedListCodg) > 0 {
387
-
387
+					cut, _ := strconv.ParseFloat(subItem.Count, 64)
388 388
 					cus := &Custom{
389
-						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
390
-						Cut:              fmt.Sprintf("%.2f", float64(subItem.Count)),
389
+						DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cut),
390
+						Cut:              fmt.Sprintf("%.2f", cut),
391 391
 						FeedetlSn:        subItem.FeedetlSn,
392 392
 						Price:            fmt.Sprintf("%.2f", float64(subItem.Price)),
393 393
 						MedListCodg:      subItem.MedListCodg,

+ 34 - 119
service/gobal_config_service.go View File

@@ -2,10 +2,8 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
-	"encoding/json"
6 5
 	"fmt"
7 6
 	"github.com/jinzhu/gorm"
8
-	"strconv"
9 7
 	"time"
10 8
 )
11 9
 
@@ -20,47 +18,8 @@ func CreateDrugAutomaticReduceRecord(config *models.DrugStockConfig) (err error)
20 18
 }
21 19
 
22 20
 func FindAutomaticReduceRecordByOrgId(org_id int64) (err error, config models.GobalConfig) {
23
-	redis := RedisClient()
24
-	defer redis.Close()
25
-
26
-	// cur_date := time.Now().Format("2006-01-02")
27
-	key := strconv.FormatInt(org_id, 10) + ":gobal_config"
28
-	gobal_config_str, _ := redis.Get(key).Result()
29
-
30
-	if len(gobal_config_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
31
-		err = readDb.Model(&models.GobalConfig{}).Where("status = 1 AND org_id = ?", org_id).Find(&config).Error
32
-		if err != nil {
33
-			if err == gorm.ErrRecordNotFound {
34
-				if config.ID <= 0 {
35
-					redis.Set(key, "gobla_config_null", time.Second*60*60*18)
36
-				}
37
-				return nil, config
38
-			} else {
39
-				return err, config
40
-			}
41
-		} else {
42
-			if config.ID > 0 {
43
-				//缓存数据
44
-				gobal_config_str, err := json.Marshal(config)
45
-				if err == nil {
46
-					redis.Set(key, gobal_config_str, time.Second*60*60*18)
47
-					return nil, config
48
-				}
49
-			} else {
50
-				redis.Set(key, "gobla_config_null", time.Second*60*60*18)
51
-				return nil, config
52
-			}
53
-			return nil, config
54
-		}
55
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
56
-		if gobal_config_str == "gobla_config_null" {
57
-			return nil, config
58
-		} else {
59
-			json.Unmarshal([]byte(gobal_config_str), &config)
60
-			return nil, config
61
-		}
62
-
63
-	}
21
+	err = readDb.Model(&models.GobalConfig{}).Where("status = 1 AND org_id = ?", org_id).Find(&config).Error
22
+	return
64 23
 }
65 24
 
66 25
 func FindDrugStockAutomaticReduceRecordByOrgId(org_id int64) (err error, config models.DrugStockConfig) {
@@ -207,9 +166,9 @@ func FindAdviceInitConfig(org_id int64) (adviceInit models.AdviceInit, err error
207 166
 func GetPrint(ids []int64, orgid int64) (doctor []*models.DoctorAdvice, err error) {
208 167
 
209 168
 	if len(ids) == 1 {
210
-		err = XTReadDB().Model(&doctor).Where("groupno = ? and user_org_id = ?", ids[0], orgid).Find(&doctor).Error
169
+		err = XTReadDB().Model(&doctor).Where("groupno = ? and user_org_id = ? and status = 1", ids[0], orgid).Find(&doctor).Error
211 170
 	} else {
212
-		err = XTReadDB().Model(&doctor).Where("groupno IN(?) and user_org_id = ?", ids, orgid).Find(&doctor).Error
171
+		err = XTReadDB().Model(&doctor).Where("groupno IN(?) and user_org_id = ? and status = 1", ids, orgid).Find(&doctor).Error
213 172
 	}
214 173
 
215 174
 	return doctor, err
@@ -222,37 +181,13 @@ func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog,
222 181
 }
223 182
 
224 183
 func FindXTHisRecordByOrgId(org_id int64) (err error, config models.XtHisConfig) {
225
-	redis := RedisClient()
226
-	defer redis.Close()
227
-
228
-	// cur_date := time.Now().Format("2006-01-02")
229
-	key := strconv.FormatInt(org_id, 10) + ":" + ":his_config"
230
-	his_config_str, _ := redis.Get(key).Result()
231
-
232
-	if len(his_config_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
233
-		err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
234
-		if err != nil {
235
-			if err == gorm.ErrRecordNotFound {
236
-				return nil, config
237
-			} else {
238
-				return err, config
239
-			}
240
-		} else {
241
-			if config.ID > 0 {
242
-				//缓存数据
243
-				his_config_str, err := json.Marshal(config)
244
-				if err == nil {
245
-					redis.Set(key, his_config_str, time.Second*60*60*18)
246
-				}
247
-			} else {
248
-				redis.Set(key, " ", time.Second*60*60*18)
249
-			}
250
-			return nil, config
251
-		}
252
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
253
-		json.Unmarshal([]byte(his_config_str), &config)
254
-		return nil, config
255
-	}
184
+	err = readDb.Model(&models.XtHisConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
185
+	return
186
+}
187
+
188
+func FindHisStockPriceRecordByOrgId(org_id int64) (err error, config models.HisStockPriceConfig) {
189
+	err = readDb.Model(&models.HisStockPriceConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
190
+	return
256 191
 }
257 192
 
258 193
 func UpdateXTHisRecord(config *models.XtHisConfig) (err error) {
@@ -265,39 +200,25 @@ func CreateXTHisRecord(config *models.XtHisConfig) (err error) {
265 200
 	return
266 201
 }
267 202
 
203
+func CreateHisStockPriceRecord(config *models.HisStockPriceConfig) (err error) {
204
+	err = writeDb.Model(&models.HisStockPriceConfig{}).Create(config).Error
205
+	return
206
+}
207
+
208
+func UpdateHisStockPriceRecord(config *models.HisStockPriceConfig) (err error) {
209
+	err = writeDb.Save(config).Error
210
+	return
211
+}
212
+
268 213
 //TODO:项目开关
269 214
 func FindXTHisProjectByOrgId(org_id int64) (err error, config models.XtHisProjectConfig) {
270
-	redis := RedisClient()
271
-	defer redis.Close()
272
-
273
-	// cur_date := time.Now().Format("2006-01-02")
274
-	key := strconv.FormatInt(org_id, 10) + ":his_project_config"
275
-	his_project_config_str, _ := redis.Get(key).Result()
276
-
277
-	if len(his_project_config_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
278
-		err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
279
-		if err != nil {
280
-			if err == gorm.ErrRecordNotFound {
281
-				return nil, config
282
-			} else {
283
-				return err, config
284
-			}
285
-		} else {
286
-			if config.ID > 0 {
287
-				//缓存数据
288
-				his_project_config_str, err := json.Marshal(config)
289
-				if err == nil {
290
-					redis.Set(key, his_project_config_str, time.Second*60*60*18)
291
-				}
292
-			} else {
293
-				redis.Set(key, " ", time.Second*60*60*18)
294
-			}
295
-			return nil, config
296
-		}
297
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
298
-		json.Unmarshal([]byte(his_project_config_str), &config)
299
-		return nil, config
300
-	}
215
+	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
216
+	return
217
+}
218
+
219
+func FindXTHisProjectByOrgIdOne(org_id int64) (err error, config models.XtHisProjectConfig) {
220
+	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
221
+	return
301 222
 }
302 223
 
303 224
 func UpdateXTHisProjectRecord(config *models.XtHisProjectConfig) (err error) {
@@ -669,7 +590,7 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
669 590
 func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (drug []*models.VmBaseDrug, total int64, err error) {
670 591
 
671 592
 	offset := (page - 1) * limit
672
-	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
593
+	db := readDb2.Table("xt_base_drug").Where("status = 1")
673 594
 	likeKey := "%" + keyword + "%"
674 595
 	if orgid > 0 {
675 596
 		db = db.Where("org_id = ?", orgid)
@@ -790,7 +711,7 @@ func GetDrugCountList(startime int64, endtime int64, orgid int64) (info []*model
790 711
 }
791 712
 
792 713
 func GetMinCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
793
-	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
714
+	db := readDb2.Table("xt_drug_warehouse_info as x").Where("x.status = 1")
794 715
 
795 716
 	if startime > 0 {
796 717
 		db = db.Where("x.ctime >=?", startime)
@@ -806,7 +727,7 @@ func GetMinCountList(startime int64, endtime int64, orgid int64) (info []*models
806 727
 }
807 728
 
808 729
 func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseInfo, err error) {
809
-	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
730
+	db := readDb2.Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
810 731
 
811 732
 	if startime > 0 {
812 733
 		db = db.Where("x.ctime >=?", startime)
@@ -822,7 +743,7 @@ func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*mo
822 743
 }
823 744
 
824 745
 func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugAutomaticReduceDetail, err error) {
825
-	db := XTReadDB().Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
746
+	db := readDb2.Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
826 747
 
827 748
 	if startime > 0 {
828 749
 		db = db.Where("x.record_time >=?", startime)
@@ -840,7 +761,7 @@ func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*m
840 761
 
841 762
 func GetCancelDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
842 763
 
843
-	db := XTReadDB().Table(" xt_drug_cancel_stock_info as x").Where("x.status = 1")
764
+	db := readDb2.Table(" xt_drug_cancel_stock_info as x").Where("x.status = 1")
844 765
 
845 766
 	if startime > 0 {
846 767
 		db = db.Where("x.ctime >=?", startime)
@@ -883,7 +804,7 @@ func GetSingleOrderDetail(id int64, orgid int64) (info []*models.VmDrugWarehouse
883 804
 		db = db.Where("x.warehouse_out_id = ?", id)
884 805
 	}
885 806
 
886
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
807
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,sum(x.count) as count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price,x.warehouse_info_id").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id").Scan(&info).Error
887 808
 	return info, err
888 809
 }
889 810
 
@@ -933,9 +854,3 @@ func GetDrugFlowBatch(ware_out_id int64, drug_id int64, orgid int64) (flow []*mo
933 854
 	err = XTReadDB().Where("warehouse_out_id = ? and drug_id = ? and user_org_id = ? and status = 1", ware_out_id, drug_id, orgid).Find(&flow).Error
934 855
 	return flow, err
935 856
 }
936
-
937
-func FindXTHisProjectByOrgIdOne(org_id int64) (err error, config models.XtHisProjectConfig) {
938
-
939
-	err = readDb.Model(&models.XtHisProjectConfig{}).Where("status = 1 AND user_org_id = ?", org_id).Find(&config).Error
940
-	return err, config
941
-}

+ 72 - 48
service/his_service.go View File

@@ -2,10 +2,8 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
-	"encoding/json"
6 5
 	"fmt"
7 6
 	"github.com/jinzhu/gorm"
8
-	"strconv"
9 7
 	"strings"
10 8
 	"time"
11 9
 )
@@ -590,11 +588,14 @@ func GetChargeMonthHisPrescriptionFour(org_id int64, patient_id int64, start_dat
590 588
 }
591 589
 
592 590
 type OtherDrugWarehouseInfo struct {
593
-	ID               int64 `gorm:"column:id" json:"id" form:"id"`
594
-	DrugId           int64 `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
595
-	WarehousingCount int64 `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
596
-	Status           int64 `gorm:"column:status" json:"status" form:"status"`
597
-	OrgId            int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
591
+	ID               int64   `gorm:"column:id" json:"id" form:"id"`
592
+	DrugId           int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
593
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count" form:"warehousing_count"`
594
+	Status           int64   `gorm:"column:status" json:"status" form:"status"`
595
+	OrgId            int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
596
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
597
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
598
+	Price            float64 `gorm:"column:price" json:"price" form:"price"`
598 599
 }
599 600
 
600 601
 func (OtherDrugWarehouseInfo) TableName() string {
@@ -721,7 +722,7 @@ func (BaseDrugLib) TableName() string {
721 722
 }
722 723
 
723 724
 func GetAllDrugLibList(org_id int64) (list []*BaseDrugLib, err error) {
724
-	err = readDb.Model(&BaseDrugLib{}).Preload("OtherDrugWarehouseInfo", "status = 1").Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Find(&list).Error
725
+	err = readDb.Model(&BaseDrugLib{}).Where("org_id = ?  AND status = 1 AND  find_in_set('停用',drug_status) = 0", org_id).Preload("OtherDrugWarehouseInfo", "status = 1 and (stock_max_number > 0 or stock_min_number >0)").Find(&list).Error
725 726
 	return
726 727
 }
727 728
 
@@ -1515,7 +1516,7 @@ type HisPrescriptionProject struct {
1515 1516
 	HisPatientId       int64        `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1516 1517
 	RecordDate         int64        `gorm:"column:record_date" json:"record_date" form:"record_date"`
1517 1518
 	PrescriptionId     int64        `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
1518
-	Count              int64        `gorm:"column:count" json:"count" form:"count"`
1519
+	Count              string       `gorm:"column:count" json:"count" form:"count"`
1519 1520
 	FeedetlSn          string       `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1520 1521
 	MedListCodg        string       `gorm:"column:med_list_codg" json:"med_list_codg" form:"med_list_codg"`
1521 1522
 	SingleDose         string       `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
@@ -1585,6 +1586,43 @@ func GetHisOrderDetailByNumber(order_number string, org_id int64) (order []*HisO
1585 1586
 	return
1586 1587
 }
1587 1588
 
1589
+//func GetHisOrderInfoByNumber(order_number string) (order []*models.HisOrderInfo, err error) {
1590
+//	db := readDb.Model(&models.HisOrderInfo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1591
+//		return db.Preload("BaseDrugLib", "status = 1").Where("status = 1")
1592
+//	})
1593
+//	err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
1594
+//	return
1595
+//}
1596
+
1597
+func GetHisOrderInfoByNumberOne(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1598
+	db := readDb.Model(&models.HisOrderInfoTwo{}).Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
1599
+		return db.Preload("Drug", "status = 1").Where("status = 1")
1600
+	})
1601
+	err = db.Where("order_number = ? AND status = 1 AND advice_id > 0", order_number).Find(&order).Error
1602
+	return
1603
+}
1604
+
1605
+func GetHisOrderInfoByNumberTwo(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1606
+	db := readDb.Model(&models.HisOrderInfoTwo{})
1607
+	db = db.Joins("Join his_prescription_project as p  On p.id = his_order_info.project_id AND p.team_id = 0")
1608
+	db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1609
+		return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
1610
+	})
1611
+	err = db.Where("his_order_info.order_number = ? AND his_order_info.status = 1 AND his_order_info.project_id > 0 ", order_number).Find(&order).Error
1612
+	return
1613
+}
1614
+
1615
+func GetHisOrderInfoByNumberThree(order_number string) (order []*models.HisOrderInfoTwo, err error) {
1616
+	db := readDb.Model(&models.HisOrderInfoTwo{})
1617
+	db = db.Joins("Join his_prescription_project as p  On p.id = his_order_info.project_id AND p.team_id > 0")
1618
+
1619
+	db = db.Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1620
+		return db.Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("status = 1")
1621
+	})
1622
+	err = db.Where("his_order_info.order_number = ? AND his_order_info.status = 1 AND his_order_info.project_id > 0", order_number).Find(&order).Error
1623
+	return
1624
+}
1625
+
1588 1626
 type MedicalInsuranceCostCompare struct {
1589 1627
 	ID        int64   `gorm:"column:id" json:"id" form:"id"`
1590 1628
 	StartTime int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
@@ -1986,46 +2024,13 @@ func GetHisPrescriptionProjectsByID(id int64) (projects []*models.HisPrescriptio
1986 2024
 }
1987 2025
 
1988 2026
 func GetHisPrescriptionProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
1989
-	redis := RedisClient()
1990
-	defer redis.Close()
1991
-
1992
-	// cur_date := time.Now().Format("2006-01-02")
1993
-	key := strconv.FormatInt(user_org_id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_time, 10) + ":his_prescription_project"
1994
-	his_prescription_project_str, _ := redis.Get(key).Result()
1995
-
1996
-	if len(his_prescription_project_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1997
-		err = readDb.Model(&models.HisPrescriptionProject{}).Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1", user_org_id, patient_id, record_time).Find(&projects).Error
1998
-		if err != nil {
1999
-			if err == gorm.ErrRecordNotFound {
2000
-				if len(projects) <= 0 {
2001
-					redis.Set(key, "his_prescription_null", time.Second*60*60*18)
2002
-				}
2003
-				return nil, nil
2004
-			} else {
2005
-				return nil, err
2006
-			}
2007
-		} else {
2008
-			if len(projects) > 0 {
2009
-				//缓存数据
2010
-				his_prescription_project_str, err := json.Marshal(projects)
2011
-				if err == nil {
2012
-					redis.Set(key, his_prescription_project_str, time.Second*60*60*18)
2013
-				}
2014
-			} else {
2015
-				redis.Set(key, "his_prescription_null", time.Second*60*60*18)
2016
-			}
2017
-			return projects, nil
2018
-		}
2019
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2020
-		if his_prescription_project_str == "his_prescription_null" {
2021
-			return projects, nil
2022
-		} else {
2023
-			json.Unmarshal([]byte(his_prescription_project_str), &projects)
2024
-			return projects, nil
2025
-		}
2026
-
2027
-	}
2027
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id = 0", user_org_id, patient_id, record_time).Find(&projects).Error
2028
+	return
2029
+}
2028 2030
 
2031
+func GetHisPrescriptionTeamProjects(user_org_id int64, patient_id int64, record_time int64) (projects []*models.HisPrescriptionProject, err error) {
2032
+	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("XtHisProjectTeam", "status = 1").Preload("HisProject", "status = 1").Preload("GoodInfo", "status = 1").Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND  status = 1 AND team_id > 0", user_org_id, patient_id, record_time).Find(&projects).Error
2033
+	return
2029 2034
 }
2030 2035
 
2031 2036
 func GetHisPrescriptionProjectByID(id int64) (projects models.HisPrescriptionProject, err error) {
@@ -2194,3 +2199,22 @@ func FindAllHisProjectByTime(now int64, end int64, patient_id int64, orgId int64
2194 2199
 	err = readDb.Model(&models.HisPrescriptionProject{}).Where("status = 1 AND user_org_id = ? AND patient_id = ?  AND record_date > ? AND record_date <= ? AND project_id = ? ", orgId, patient_id, end, now, project_id).Find(&project).Error
2195 2200
 	return
2196 2201
 }
2202
+
2203
+func GetProjectByTeamId(user_org_id int64, team_id int64, patient_id int64, record_time int64) (label models.HisLabelPrintInfo, err error) {
2204
+	err = readDb.Model(&models.HisLabelPrintInfo{}).Where("user_org_id = ? AND item_id = ? AND patient_id = ? AND record_date = ? AND status = 1", user_org_id, team_id, patient_id, record_time).First(&label).Error
2205
+	return
2206
+}
2207
+
2208
+func GetProjectById(user_org_id int64, p_project_id int64, record_time int64, patient_id int64) (label models.HisLabelPrintInfo, err error) {
2209
+	err = readDb.Model(&models.HisLabelPrintInfo{}).Where("user_org_id = ? AND p_project_id = ? AND patient_id = ? AND record_date = ? AND status = 1", user_org_id, p_project_id, patient_id, record_time).First(&label).Error
2210
+	return
2211
+}
2212
+
2213
+func DeletePrintInfo(id int64) {
2214
+	writeDb.Model(&models.HisLabelPrintInfo{}).Where("p_project_id = ?", id).Updates(map[string]interface{}{"status": 0})
2215
+}
2216
+
2217
+func CreateHisLabelRecord(label *models.HisLabelPrintInfo) error {
2218
+	err := writeDb.Save(&label).Error
2219
+	return err
2220
+}

+ 113 - 84
service/mobile_dialysis_service.go View File

@@ -29,20 +29,6 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
29 29
 	var vms []*MDialysisScheduleVMForList
30 30
 	db := readDb.
31 31
 		Table("xt_schedule as sch").
32
-		// Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
33
-		// Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
34
-		// Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
35
-		// Preload("Advices", "status = 1 AND user_org_id = ? AND advice_type = 2 AND advice_date = ? ", orgID, scheduleDate).
36
-		// Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
37
-		// Preload("AssessmentBeforeDislysis", "status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).
38
-		// Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).
39
-		// Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
40
-		// Preload("TreatmentSummary", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
41
-		// Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
42
-		// Preload("HisAdvices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
43
-		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
44
-		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
45
-		// }).
46 32
 		Where("sch.status = 1 AND sch.user_org_id = ?", orgID)
47 33
 	if scheduleDate != 0 {
48 34
 		db = db.Where("schedule_date = ?", scheduleDate)
@@ -410,6 +396,17 @@ func MobileGetPatientDetail(orgID int64, patientID int64) (*MPatient, error) {
410 396
 	}
411 397
 }
412 398
 
399
+func MobileGetSchedualDetailOne(orgID int64, patientID int64, schedualDate int64) (*MDialysisScheduleVM, error) {
400
+	var vm MDialysisScheduleVM
401
+	err := readDb.
402
+		Table("xt_schedule").
403
+		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
404
+		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
405
+		Where("status = 1 AND user_org_id = ? AND schedule_date = ? AND patient_id = ?", orgID, schedualDate, patientID).
406
+		First(&vm).Error
407
+	return &vm, err
408
+}
409
+
413 410
 // 用户排班信息
414 411
 func MobileGetSchedualDetail(orgID int64, patientID int64, schedualDate int64) (*MDialysisScheduleVM, error) {
415 412
 	redis := RedisClient()
@@ -559,16 +556,13 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
559 556
 
560 557
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
561 558
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
562
-	fmt.Println("长度233232323322332322323", receive_treatment_asses_str)
563 559
 	if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
564 560
 		err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
565 561
 		if err != nil {
566
-			fmt.Println("h2323232woweewweweweweeweeewweewweweweewweewwewe", record.ID)
562
+
567 563
 			if err == gorm.ErrRecordNotFound {
568 564
 				if record.ID <= 0 {
569
-
570
-					redis.Set(key, "null", time.Second*60*60*18)
571
-					fmt.Println("j你来了呃呃呃呃呃呃呃呃呃呃")
565
+					redis.Set(key, "", time.Second*60*60*18)
572 566
 				}
573 567
 				return nil, nil
574 568
 			} else {
@@ -602,17 +596,14 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
602 596
 	var record models.PredialysisEvaluation
603 597
 	redis := RedisClient()
604 598
 	defer redis.Close()
605
-
606
-	// cur_date := time.Now().Format("2006-01-02")
607 599
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_before_dislysis"
608 600
 	assessment_before_dislysis_str, _ := redis.Get(key).Result()
609
-
610 601
 	if len(assessment_before_dislysis_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
611 602
 		err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
612 603
 		if err != nil {
613 604
 			if err == gorm.ErrRecordNotFound {
614 605
 				if record.ID <= 0 {
615
-					redis.Set(key, "null", time.Second*60*60*18)
606
+					redis.Set(key, "", time.Second*60*60*18)
616 607
 				}
617 608
 				return nil, nil
618 609
 			} else {
@@ -656,7 +647,7 @@ func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDat
656 647
 		if err != nil {
657 648
 			if err == gorm.ErrRecordNotFound {
658 649
 				if record.ID <= 0 {
659
-					redis.Set(key, "null", time.Second*60*60*18)
650
+					redis.Set(key, "", time.Second*60*60*18)
660 651
 				}
661 652
 				return nil, nil
662 653
 			} else {
@@ -710,7 +701,9 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
710 701
 
711 702
 	// cur_date := time.Now().Format("2006-01-02")
712 703
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
704
+	fmt.Println("医嘱keyh23232323223", key)
713 705
 	doctor_advices_str, _ := redis.Get(key).Result()
706
+	fmt.Println("长度hh2332233232233232", len(doctor_advices_str))
714 707
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
715 708
 		err := readDb.Model(&models.DoctorAdvice{}).
716 709
 			Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
@@ -720,7 +713,7 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
720 713
 		if err != nil {
721 714
 			if err == gorm.ErrRecordNotFound {
722 715
 				if len(records) <= 0 {
723
-					redis.Set(key, "null", time.Second*60*60*18)
716
+					redis.Set(key, "", time.Second*60*60*18)
724 717
 				}
725 718
 				return nil, nil
726 719
 			} else {
@@ -756,17 +749,12 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
756 749
 	redis := RedisClient()
757 750
 	defer redis.Close()
758 751
 
759
-	// cur_date := time.Now().Format("2006-01-02")
760 752
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_order"
761 753
 	dialysis_order_str, _ := redis.Get(key).Result()
762
-
763 754
 	if len(dialysis_order_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
764 755
 		err := readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
765 756
 		if err != nil {
766 757
 			if err == gorm.ErrRecordNotFound {
767
-				if record.ID <= 0 {
768
-					redis.Set(key, "null", time.Second*60*60*18)
769
-				}
770 758
 				return nil, nil
771 759
 			} else {
772 760
 				return nil, err
@@ -784,7 +772,9 @@ func MobileGetSchedualDialysisRecord(orgID int64, patientID int64, recordDate in
784 772
 			return &record, nil
785 773
 		}
786 774
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
775
+
787 776
 		if dialysis_order_str == "null" {
777
+			err = readDb.Model(&models.DialysisOrder{}).Preload("DeviceNumber", "org_id = ? AND  status = 1", orgID).Where("user_org_id = ? AND patient_id = ? AND  dialysis_date = ?", orgID, patientID, recordDate).First(&record).Error
788 778
 			return &record, nil
789 779
 		} else {
790 780
 			json.Unmarshal([]byte(dialysis_order_str), &record)
@@ -847,14 +837,14 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
847 837
 	// cur_date := time.Now().Format("2006-01-02")
848 838
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
849 839
 	monitor_records_str, _ := redis.Get(key).Result()
850
-
840
+	fmt.Println("监测23323232323233232", len(monitor_records_str))
851 841
 	if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
852 842
 		err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, recordDate).Order("operate_time asc").Find(&records).Error
853 843
 		if err != nil {
854 844
 			if err == gorm.ErrRecordNotFound {
855
-				if len(records) <= 0 {
856
-					redis.Set(key, "null", time.Second*60*60*18)
857
-				}
845
+				//if len(records) <= 0 {
846
+				//	redis.Set(key, "null", time.Second*60*60*18)
847
+				//}
858 848
 				return nil, nil
859 849
 			} else {
860 850
 				return nil, err
@@ -933,14 +923,26 @@ func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64)
933 923
 	}
934 924
 }
935 925
 
926
+func MobileGetAssessmentAfterDislysisOne(orgID int64, patientID int64, recordDate int64) (*models.AssessmentAfterDislysis, error) {
927
+	var record models.AssessmentAfterDislysis
928
+	err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
929
+	if err != nil {
930
+		if err == gorm.ErrRecordNotFound {
931
+			return nil, nil
932
+		} else {
933
+			return nil, err
934
+		}
935
+	}
936
+	return &record, nil
937
+}
938
+
936 939
 // 透后评估
937 940
 func MobileGetAssessmentAfterDislysis(orgID int64, patientID int64, recordDate int64) (*models.AssessmentAfterDislysis, error) {
938 941
 	var record models.AssessmentAfterDislysis
939 942
 	redis := RedisClient()
940 943
 	defer redis.Close()
941
-
942
-	// cur_date := time.Now().Format("2006-01-02")
943 944
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":assessment_after_dislysis"
945
+
944 946
 	assessment_after_dislysis_str, _ := redis.Get(key).Result()
945 947
 
946 948
 	if len(assessment_after_dislysis_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -1019,6 +1021,21 @@ func MobileGetLastTimeAssessmentAfterDislysis(orgID int64, patientID int64, maxD
1019 1021
 
1020 1022
 	}
1021 1023
 }
1024
+
1025
+func MobileGetLastTimeAssessmentAfterDislysisOne(orgID int64, patientID int64, maxDate int64) (*models.AssessmentAfterDislysis, error) {
1026
+	var record models.AssessmentAfterDislysis
1027
+	err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
1028
+	if err != nil {
1029
+		if err == gorm.ErrRecordNotFound {
1030
+			return nil, nil
1031
+		} else {
1032
+			return nil, err
1033
+		}
1034
+	}
1035
+	return &record, nil
1036
+
1037
+}
1038
+
1022 1039
 func MobileGetLast(orgID int64, patientID int64, maxDate int64) (models.AssessmentAfterDislysis, error) {
1023 1040
 	dislysis := models.AssessmentAfterDislysis{}
1024 1041
 	err := readDb.Model(&models.AssessmentAfterDislysis{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&dislysis).Error
@@ -1932,6 +1949,20 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
1932 1949
 	}
1933 1950
 }
1934 1951
 
1952
+// 透析方案
1953
+func MobileGetDialysisSolutionByModeIdSix(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
1954
+	var record models.DialysisSolution
1955
+	err := readDb.Model(&models.DialysisSolution{}).Where("patient_id = ? and user_org_id = ? and status = 1 AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
1956
+	if err != nil {
1957
+		if err == gorm.ErrRecordNotFound {
1958
+			return nil, nil
1959
+		} else {
1960
+			return nil, err
1961
+		}
1962
+	}
1963
+	return &record, nil
1964
+}
1965
+
1935 1966
 // 透析方案
1936 1967
 func MobileGetDialysisSolutionByModeId(orgID int64, patientID int64, mode_id int64) (*models.DialysisSolution, error) {
1937 1968
 	var record models.DialysisSolution
@@ -1984,9 +2015,9 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
1984 2015
 
1985 2016
 	// cur_date := time.Now().Format("2006-01-02")
1986 2017
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1987
-
2018
+	fmt.Println("key23323323223323")
1988 2019
 	dialysis_prescribe_str, _ := redis.Get(key).Result()
1989
-
2020
+	fmt.Println("c产杜3323232323232323232", len(dialysis_prescribe_str))
1990 2021
 	if len(dialysis_prescribe_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1991 2022
 		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
1992 2023
 		if err != nil {
@@ -2082,17 +2113,20 @@ func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.Dialy
2082 2113
 	return &record, nil
2083 2114
 }
2084 2115
 
2116
+func MobileGetLastDialysisPrescribeByModeIdSix(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
2117
+	var record models.DialysisPrescription
2118
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1  AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2119
+	if err != nil {
2120
+		if err == gorm.ErrRecordNotFound {
2121
+			return nil, nil
2122
+		} else {
2123
+			return nil, err
2124
+		}
2125
+	}
2126
+	return &record, nil
2127
+}
2128
+
2085 2129
 func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_id int64) (*models.DialysisPrescription, error) {
2086
-	//var record models.DialysisPrescription
2087
-	//err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1  AND mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2088
-	//if err != nil {
2089
-	//	if err == gorm.ErrRecordNotFound {
2090
-	//		return nil, nil
2091
-	//	} else {
2092
-	//		return nil, err
2093
-	//	}
2094
-	//}
2095
-	//return &record, nil
2096 2130
 
2097 2131
 	var record models.DialysisPrescription
2098 2132
 	redis := RedisClient()
@@ -2102,7 +2136,7 @@ func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_i
2102 2136
 	dialysis_prescribe_by_mode_id, _ := redis.Get(key).Result()
2103 2137
 
2104 2138
 	if len(dialysis_prescribe_by_mode_id) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2105
-		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and mode_id = ?", patientID, orgID, mode_id).First(&record).Error
2139
+		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2106 2140
 		if err != nil {
2107 2141
 			if err == gorm.ErrRecordNotFound {
2108 2142
 				if record.ID <= 0 {
@@ -2140,40 +2174,14 @@ func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, mode_i
2140 2174
 	}
2141 2175
 }
2142 2176
 
2143
-//func MobileGetLastDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate int64,mode_id int64) (*models.DialysisPrescription, error) {
2144
-//	var record models.DialysisPrescription
2145
-//	redis := RedisClient()
2146
-//	defer redis.Close()
2147
-//
2148
-//	// cur_date := time.Now().Format("2006-01-02")
2149
-//	key := strconv.FormatInt(orgID, 10) + ":"+ strconv.FormatInt(patientID, 10) +  ":" + strconv.FormatInt(recordDate, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_last"
2150
-//	dialysis_prescribe_last_str, _ := redis.Get(key).Result()
2151
-//
2152
-//	if len(dialysis_prescribe_last_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2153
-//		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1  AND mode_id = ?  AND record_date < ?", patientID, orgID, mode_id,recordDate).Last(&record).Error
2154
-//		if err != nil {
2155
-//			if err == gorm.ErrRecordNotFound {
2156
-//				return nil, nil
2157
-//			} else {
2158
-//				return nil, err
2159
-//			}
2160
-//		} else {
2161
-//			if record.ID > 0 {
2162
-//				//缓存数据
2163
-//				dialysis_prescribe_last_str, err := json.Marshal(record)
2164
-//				if err == nil {
2165
-//					redis.Set(key, dialysis_prescribe_last_str, time.Second*60*60*18)
2166
-//				}
2167
-//			} else {
2168
-//				redis.Set(key, " ", time.Second*60*60*18)
2169
-//			}
2170
-//			return &record, nil
2171
-//		}
2172
-//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2173
-//		json.Unmarshal([]byte(dialysis_prescribe_last_str), &record)
2174
-//		return &record, nil
2175
-//	}
2176
-//}
2177
+func MobileGetLastDialysisPrescribeByModeIdOne(orgID int64, patientID int64, mode_id int64) (models.DialysisPrescription, error) {
2178
+
2179
+	var record models.DialysisPrescription
2180
+
2181
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and mode_id = ?", patientID, orgID, mode_id).Last(&record).Error
2182
+
2183
+	return record, err
2184
+}
2177 2185
 
2178 2186
 func GetAllAvaildDeviceNumbers(orgID int64, record_date int64, schedule_type int) ([]*DeviceNumberViewModel, error) {
2179 2187
 	var vms []*DeviceNumberViewModel = make([]*DeviceNumberViewModel, 0)
@@ -2311,6 +2319,19 @@ func GetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDryweight
2311 2319
 	return &record, nil
2312 2320
 }
2313 2321
 
2322
+func MobileGetSystemDialysisPrescribeByModeIdSix(orgID int64, mode_id int64) (*models.SystemPrescription, error) {
2323
+	var record models.SystemPrescription
2324
+	err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).First(&record).Error
2325
+	if err != nil {
2326
+		if err == gorm.ErrRecordNotFound {
2327
+			return nil, nil
2328
+		} else {
2329
+			return nil, err
2330
+		}
2331
+	}
2332
+	return &record, nil
2333
+}
2334
+
2314 2335
 func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*models.SystemPrescription, error) {
2315 2336
 	var record models.SystemPrescription
2316 2337
 	redis := RedisClient()
@@ -2321,7 +2342,7 @@ func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*mode
2321 2342
 	system_dialysis_prescribe_str, _ := redis.Get(key).Result()
2322 2343
 
2323 2344
 	if len(system_dialysis_prescribe_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2324
-		err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).First(&record).Error
2345
+		err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).Last(&record).Error
2325 2346
 		if err != nil {
2326 2347
 			if err == gorm.ErrRecordNotFound {
2327 2348
 				if record.ID <= 0 {
@@ -2353,6 +2374,14 @@ func MobileGetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*mode
2353 2374
 	}
2354 2375
 }
2355 2376
 
2377
+func MobileGetSystemDialysisPrescribeByModeIdOne(orgID int64, mode_id int64) (models.SystemPrescription, error) {
2378
+	var record models.SystemPrescription
2379
+
2380
+	err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).Last(&record).Error
2381
+
2382
+	return record, err
2383
+}
2384
+
2356 2385
 func GetSystemDialysisPrescribeByModeId(orgID int64, mode_id int64) (*models.SystemPrescription, error) {
2357 2386
 	var record models.SystemPrescription
2358 2387
 	err := readDb.Model(&models.SystemPrescription{}).Where("user_org_id = ? and status = 1  AND mode_id = ?", orgID, mode_id).Last(&record).Error

+ 6 - 67
service/patient_service.go View File

@@ -204,9 +204,9 @@ func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions [
204 204
 	defer redis.Close()
205 205
 	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
206 206
 	prescriptions_list_all, _ := redis.Get(key).Result()
207
-
207
+	fmt.Println("铲毒23322332323232323", len(prescriptions_list_all))
208 208
 	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
209
-		err = readDb.Model(&models.DialysisPrescriptionList{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
209
+		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
210 210
 		if err != nil {
211 211
 			if err == gorm.ErrRecordNotFound {
212 212
 				if len(prescriptions) <= 0 {
@@ -246,7 +246,7 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
246 246
 	assessment_befores_list_all, _ := redis.Get(key).Result()
247 247
 
248 248
 	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
249
-		err = readDb.Model(&models.PredialysisEvaluationList{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
249
+		err = readDb.Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
250 250
 		if err != nil {
251 251
 			if err == gorm.ErrRecordNotFound {
252 252
 				if len(assessmentBefores) <= 0 {
@@ -270,6 +270,7 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
270 270
 		}
271 271
 	} else { //缓存数据了数据,将redis缓存的json字符串转为map
272 272
 		if assessment_befores_list_all == "null" {
273
+			fmt.Println("尽力2323232", assessment_befores_list_all)
273 274
 			return nil, nil
274 275
 		} else {
275 276
 			json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)
@@ -283,15 +284,12 @@ func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders
283 284
 	defer redis.Close()
284 285
 	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
285 286
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
286
-
287
+	fmt.Println("dialysis_orders_list_all23323223232323323232332", len(dialysis_orders_list_all))
287 288
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
288 289
 		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
289 290
 
290 291
 		if err != nil {
291 292
 			if err == gorm.ErrRecordNotFound {
292
-				if len(dialysisOrders) <= 0 {
293
-					redis.Set(key, "null", time.Second*60*60*18)
294
-				}
295 293
 				return nil, nil
296 294
 			} else {
297 295
 				return nil, err
@@ -1414,54 +1412,6 @@ func GetPatientScheduleList(orgID int64, patientID int64, page int64, limit int6
1414 1412
 
1415 1413
 func GetMonitorRecord(orgID int64, date int64, partition int64, patientId int64) ([]*models.NewVMMonitorDialysisSchedule, error) {
1416 1414
 	var mds []*models.NewVMMonitorDialysisSchedule
1417
-	//
1418
-	//if patientId == 0 {
1419
-	//	db := readDb.
1420
-	//		Model(&models.NewVMMonitorDialysisSchedule{}).
1421
-	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1422
-	//		Preload("DeviceZone", "status = 1 AND org_id = ?", orgID).
1423
-	//		Preload("TreatmentMode", "status = 1").
1424
-	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, date).
1425
-	//		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ?", orgID, date).
1426
-	//		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND assessment_date = ? ", orgID, date).
1427
-	//		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ? AND monitoring_date = ?", orgID, date).
1428
-	//		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, date).
1429
-	//		Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1430
-	//		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1431
-	//		Where("status = 1 AND user_org_id = ?", orgID)
1432
-	//	if date != 0 {
1433
-	//		db = db.Where("schedule_date = ? ", date)
1434
-	//	}
1435
-	//	if partition != 0 {
1436
-	//		db = db.Where("partition_id = ? ", partition)
1437
-	//	}
1438
-	//	err := db.Find(&mds).Error
1439
-	//	fmt.Println("err", err)
1440
-
1441
-	//if patientId > 0 {
1442
-	//	db := readDb.Table("xt_schedule as x").Where("x.status = 1")
1443
-	//	db = db.
1444
-	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
1445
-	//		Preload("TreatmentMode", "status = 1").
1446
-	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND patient_id = ?", orgID, patientId).
1447
-	//		Preload("AssessmentBeforeDislysis", "status = 1 AND  user_org_id = ? AND patient_id = ?", orgID, patientId).
1448
-	//		Preload("AssessmentAfterDislysis", "status = 1 AND  user_org_id = ? AND patient_id = ? ", orgID, patientId).
1449
-	//		Preload("MonitoringRecord", "status = 1 AND  user_org_id = ?  AND patient_id = ?", orgID, patientId).
1450
-	//		Preload("DialysisOrder", "status = 1 AND user_org_id = ? AND patient_id = ?", orgID, patientId).
1451
-	//		Preload("DialysisOrder.DeviceNumber", "status = 1 AND  org_id = ?", orgID).
1452
-	//		Preload("MonitorPatients", "status = 1 AND user_org_id = ?", orgID).
1453
-	//		Where("status = 1 AND user_org_id = ?", orgID)
1454
-	//	if partition != 0 {
1455
-	//		db = db.Where("partition_id = ? ", partition)
1456
-	//	}
1457
-	//
1458
-	//	db = db.Where("schedule_date <= ? ", time.Now().Unix())
1459
-	//
1460
-	//	db = db.Where("patient_id = ?", patientId)
1461
-	//	db = db.Order("schedule_date desc")
1462
-	//	err := db.Find(&mds).Error
1463
-	//	fmt.Println("err", err)
1464
-	//}
1465 1415
 
1466 1416
 	db := readDb.Model(&models.NewVMMonitorDialysisSchedule{})
1467 1417
 	if date > 0 {
@@ -2104,22 +2054,11 @@ func GetAllAssessmentAfterDislysisByListOne(orgID int64, scheduleDate int64) (as
2104 2054
 
2105 2055
 func GetAllMonitorList(orgID int64, scheduleDate int64) (monitor []*models.VMMonitoringRecord, err error) {
2106 2056
 
2107
-	//db := XTReadDB().Model(&monitor).Where("status = 1")
2108
-	//if orgID > 0 {
2109
-	//  db = db.Where("user_org_id = ?", orgID)
2110
-	//}
2111
-	//if scheduleDate > 0 {
2112
-	//  db = db.Where("monitoring_date = ?", scheduleDate)
2113
-	//}
2114
-	//
2115
-	//err = db.Find(&monitor).Error
2116
-	//return  monitor,err
2117
-
2118 2057
 	redis := RedisClient()
2119 2058
 	defer redis.Close()
2120 2059
 	key := strconv.FormatInt(orgID, 10) + ":" + ":monitor_record_list_all"
2121 2060
 	monitor_record_list_all, _ := redis.Get(key).Result()
2122
-
2061
+	fmt.Println("monitor_recorde_list", len(monitor_record_list_all))
2123 2062
 	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2124 2063
 		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2125 2064
 		if err != nil {

+ 6 - 6
service/self_drug_service.go View File

@@ -1034,12 +1034,12 @@ func GetLastDrugWarehouseOut(orgid int64) (models.DrugWarehouseOut, error) {
1034 1034
 	return info, err
1035 1035
 }
1036 1036
 
1037
-func GetLastDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1038
-
1039
-	info := models.XtDrugWarehouseInfo{}
1040
-	err := XTReadDB().Model(&info).Where("id=? and status = 1", drugid).Last(&info).Error
1041
-	return info, err
1042
-}
1037
+//func GetLastDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1038
+//
1039
+//	info := models.XtDrugWarehouseInfo{}
1040
+//	err := XTReadDB().Model(&info).Where("id=? and status = 1", drugid).Last(&info).Error
1041
+//	return info, err
1042
+//}
1043 1043
 
1044 1044
 func GetFirstDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
1045 1045
 

+ 366 - 123
service/stock_service.go View File

@@ -2,7 +2,6 @@ package service
2 2
 
3 3
 import (
4 4
 	"XT_New/models"
5
-	"encoding/json"
6 5
 	"fmt"
7 6
 	"github.com/jinzhu/gorm"
8 7
 	"strconv"
@@ -247,6 +246,7 @@ func ModifyGoodInfo(goodInfo *models.GoodInfo) (error, *models.GoodInfo) {
247 246
 		"packing_price":                  goodInfo.PackingPrice,
248 247
 		"default_count_unit":             goodInfo.DefaultCountUnit,
249 248
 		"min_unit":                       goodInfo.MinUnit,
249
+		"register_number":                goodInfo.RegisterNumber,
250 250
 	}).Error
251 251
 
252 252
 	writeDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND org_id = ?", goodInfo.ID, goodInfo.OrgId).Updates(map[string]interface{}{"good_type_id": goodInfo.GoodTypeId})
@@ -320,7 +320,7 @@ func FindGoodInfoById(id int64) (*models.GoodInfo, error) {
320 320
 }
321 321
 
322 322
 func FindAllGoodType(org_id int64) (goodType []*models.GoodsType, err error) {
323
-	err = readDb.Model(&models.GoodsType{}).Where("org_id = ? AND status = 1", org_id).Find(&goodType).Error
323
+	err = readDb2.Model(&models.GoodsType{}).Where("org_id = ? AND status = 1", org_id).Find(&goodType).Error
324 324
 	return goodType, err
325 325
 }
326 326
 
@@ -330,7 +330,7 @@ func FindAllGoodTypeOne(org_id int64) (goodType []*models.GoodsType, err error)
330 330
 }
331 331
 
332 332
 func FindAllGoodInfo(org_id int64) (goodInfo []*models.GoodInfo, err error) {
333
-	err = readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1", org_id).Find(&goodInfo).Error
333
+	err = readDb2.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1", org_id).Find(&goodInfo).Error
334 334
 	return goodInfo, err
335 335
 }
336 336
 
@@ -580,6 +580,20 @@ func CreateDrugFlow(drugflow []*models.DrugFlow) (err error) {
580 580
 	return
581 581
 }
582 582
 
583
+func GetDrugFlowIsExist(warhouseing int64, drug_id int64) (*models.DrugFlow, error) {
584
+
585
+	info := models.DrugFlow{}
586
+	err = XTReadDB().Where("warehousing_id = ? and drug_id = ? and status = 1", warhouseing, drug_id).Find(&info).Error
587
+
588
+	if err == gorm.ErrRecordNotFound {
589
+		return nil, err
590
+	}
591
+	if err != nil {
592
+		return nil, err
593
+	}
594
+	return &info, nil
595
+}
596
+
583 597
 func GetDrugByWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
584 598
 
585 599
 	info := models.XtDrugWarehouseInfo{}
@@ -590,7 +604,7 @@ func GetDrugByWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
590 604
 func UpdateDrugWarehouseingInfo(id int64, info models.XtDrugWarehouseInfo) error {
591 605
 
592 606
 	warehouseInfo := models.XtDrugWarehouseInfo{}
593
-	err := XTReadDB().Model(&warehouseInfo).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber}).Error
607
+	err := XTWriteDB().Model(&warehouseInfo).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber}).Error
594 608
 	return err
595 609
 }
596 610
 
@@ -600,6 +614,11 @@ func CreateDrugFlowOne(flow models.DrugFlow) error {
600 614
 	return err
601 615
 }
602 616
 
617
+func CreateDrugFlowTwo(flow *models.DrugFlow) error {
618
+
619
+	err := XTWriteDB().Create(&flow).Error
620
+	return err
621
+}
603 622
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
604 623
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
605 624
 
@@ -630,6 +649,12 @@ func FindWarehousingInfoByIdSeven(id int64) (models.WarehousingInfo, error) {
630 649
 	return info, err
631 650
 }
632 651
 
652
+func FindWarehousingInfoTen(goodId int64) (models.WarehousingInfo, error) {
653
+	info := models.WarehousingInfo{}
654
+	err := XTReadDB().Select(" good_id,sum(stock_count) as stock_count").Where("good_id = ? and status = 1", goodId).Find(&info).Error
655
+	return info, err
656
+}
657
+
633 658
 //药品先进先出,找出最先入库的批次
634 659
 
635 660
 func FindLastDrugWarehousingInfoByID(drug_id int64) (info models.XtDrugWarehouseInfo, err error) {
@@ -1133,7 +1158,7 @@ func FindReturnInfoById(id int64) (list []*models.SalesReturnInfo, err error) {
1133 1158
 }
1134 1159
 
1135 1160
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
1136
-	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Preload("GoodInfo", "status = 1").Find(&list).Error
1161
+	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Preload("WarehousingInfo", "status = 1").Preload("GoodInfo", "status = 1").Find(&list).Error
1137 1162
 	return list, err
1138 1163
 }
1139 1164
 
@@ -1526,6 +1551,12 @@ func GetLastCancelStockById(orgid int64) (models.CancelStock, error) {
1526 1551
 	return stock, err
1527 1552
 }
1528 1553
 
1554
+func GetLastDrugCancelStockById(orgid int64) (models.DrugCancelStock, error) {
1555
+	stock := models.DrugCancelStock{}
1556
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&stock).Error
1557
+	return stock, err
1558
+}
1559
+
1529 1560
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1530 1561
 	err := writeDb.Create(&cancelStock).Error
1531 1562
 	return err
@@ -1574,6 +1605,18 @@ func CreateCancelStockInfo(cancelStockInfo []*models.CancelStockInfo) (err error
1574 1605
 
1575 1606
 }
1576 1607
 
1608
+func CreateCancelStockInfoTwo(info *models.DrugCancelStockInfo) error {
1609
+
1610
+	err := XTWriteDB().Create(&info).Error
1611
+	return err
1612
+}
1613
+
1614
+func CreateCancelStockInfoOne(info *models.CancelStockInfo) error {
1615
+
1616
+	err := XTWriteDB().Create(&info).Error
1617
+	return err
1618
+}
1619
+
1577 1620
 func CreateDrugCancelStockInfo(cancelStockInfo []*models.DrugCancelStockInfo) (err error) {
1578 1621
 	if len(cancelStockInfo) > 0 {
1579 1622
 		utx := writeDb.Begin()
@@ -1646,7 +1689,7 @@ func FindAllStockOutList(orgId int64, page int64, limit int64, startTime int64,
1646 1689
 
1647 1690
 func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, startime int64, endtime int64, type_name int64) (list []*models.StockInfo, total int64, err error) {
1648 1691
 
1649
-	db := readDb.Model(&models.StockInfo{})
1692
+	db := readDb2.Model(&models.StockInfo{})
1650 1693
 	if startime > 0 {
1651 1694
 
1652 1695
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
@@ -1881,6 +1924,11 @@ func UpDateDrugWarehousingInfo(info *models.DrugWarehouseInfo) (err error) {
1881 1924
 	return err
1882 1925
 }
1883 1926
 
1927
+func UpDateDrugWarehousingInfoTwo(id int64, info *models.DrugWarehouseInfo) (err error) {
1928
+	err = writeDb.Model(&info).Where("id= ? and status = 1", id).Updates(map[string]interface{}{"number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "batch_number": info.BatchNumber}).Error
1929
+	return err
1930
+}
1931
+
1884 1932
 func GetDrugWarehouseOrderOne(id int64, drug_id int64) (models.DrugWarehouseInfo, error) {
1885 1933
 
1886 1934
 	info := models.DrugWarehouseInfo{}
@@ -2798,98 +2846,25 @@ func PostSearchStock(keyword string, orgid int64) (goods []*models.GoodsType, er
2798 2846
 }
2799 2847
 
2800 2848
 func GetStockType(orgid int64) (goodstype []*models.GoodsTypeOne, err error) {
2801
-	redis := RedisClient()
2802
-	defer redis.Close()
2803
-
2804
-	// cur_date := time.Now().Format("2006-01-02")
2805
-	key := strconv.FormatInt(orgid, 10) + ":stock_type"
2806
-	stock_type_str, _ := redis.Get(key).Result()
2807
-
2808
-	if len(stock_type_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2809
-		err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3)", orgid).
2810
-			Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&goodstype).Error
2811
-		if err != nil {
2812
-			if err == gorm.ErrRecordNotFound {
2813
-				if len(goodstype) <= 0 {
2814
-					redis.Set(key, "sotck_type_null", time.Second*60*60*18)
2815
-				}
2816
-				return nil, nil
2817
-			} else {
2818
-				return nil, err
2819
-			}
2820
-		} else {
2821
-			if len(goodstype) > 0 {
2822
-				//缓存数据
2823
-				stock_type_str, err := json.Marshal(goodstype)
2824
-				if err == nil {
2825
-					redis.Set(key, stock_type_str, time.Second*60*60*18)
2826
-				}
2827
-			} else {
2828
-				redis.Set(key, "sotck_type_null", time.Second*60*60*18)
2829
-			}
2830
-			return goodstype, nil
2831
-		}
2832
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2833
-		if stock_type_str == "sotck_type_null" {
2834
-			return goodstype, nil
2835
-		} else {
2836
-			json.Unmarshal([]byte(stock_type_str), &goodstype)
2837
-			return goodstype, nil
2838
-		}
2839
-
2840
-	}
2849
+	err = XTReadDB().Where("org_id = ? and status = 1 and (stock_attribute = 2 or stock_attribute = 3)", orgid).
2850
+		Preload("GoodInfo", "org_id = ? and status = 1", orgid).Find(&goodstype).Error
2851
+	return goodstype, err
2841 2852
 }
2842 2853
 
2843 2854
 func GetDialyStockOut(orgid int64, recordtime int64, patientId int64) (prepare []*models.XtDialysisBeforePrepare, err error) {
2844
-	redis := RedisClient()
2845
-	defer redis.Close()
2846
-
2847
-	// cur_date := time.Now().Format("2006-01-02")
2848
-	key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientId, 10) + ":" + strconv.FormatInt(recordtime, 10) + ":dialy_stock_out"
2849
-	dialy_stock_out_str, _ := redis.Get(key).Result()
2850
-
2851
-	if len(dialy_stock_out_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2852
-		db := XTReadDB().Table("dialysis_before_prepare as x").Where("x.status = 1")
2853
-		if orgid > 0 {
2854
-			db = db.Where("x.user_org_id = ?", orgid)
2855
-		}
2856
-		if recordtime > 0 {
2857
-			db = db.Where("x.record_date = ?", recordtime)
2858
-		}
2859
-		if patientId > 0 {
2860
-			db = db.Where("x.patient_id = ?", patientId)
2861
-		}
2862
-		err = db.Select("x.id,x.user_org_id,x.patient_id,x.record_date,x.good_id,x.good_type_id,x.count,x.commdity_code,t.specification_name").Joins("left join xt_good_information as t on t.id = x.good_id and t.org_id = ? and t.status = 1", orgid).Scan(&prepare).Error
2863
-		if err != nil {
2864
-			if err == gorm.ErrRecordNotFound {
2865
-				return nil, nil
2866
-			} else {
2867
-				if len(prepare) <= 0 {
2868
-					redis.Set(key, "prepare_null", time.Second*60*60*18)
2869
-				}
2870
-				return nil, err
2871
-			}
2872
-		} else {
2873
-			if len(prepare) > 0 {
2874
-				//缓存数据
2875
-				dialy_stock_out_str, err := json.Marshal(prepare)
2876
-				if err == nil {
2877
-					redis.Set(key, dialy_stock_out_str, time.Second*60*60*18)
2878
-				}
2879
-			} else {
2880
-				redis.Set(key, "prepare_null", time.Second*60*60*18)
2881
-			}
2882
-			return prepare, nil
2883
-		}
2884
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2885
-		if dialy_stock_out_str == "prepare_null" {
2886
-			return prepare, nil
2887
-		} else {
2888
-			json.Unmarshal([]byte(dialy_stock_out_str), &prepare)
2889
-			return prepare, nil
2890
-		}
2891 2855
 
2856
+	db := XTReadDB().Table("dialysis_before_prepare as x").Where("x.status = 1")
2857
+	if orgid > 0 {
2858
+		db = db.Where("x.user_org_id = ?", orgid)
2892 2859
 	}
2860
+	if recordtime > 0 {
2861
+		db = db.Where("x.record_date = ?", recordtime)
2862
+	}
2863
+	if patientId > 0 {
2864
+		db = db.Where("x.patient_id = ?", patientId)
2865
+	}
2866
+	err = db.Select("x.id,x.user_org_id,x.patient_id,x.record_date,x.good_id,x.good_type_id,x.count,x.commdity_code,t.specification_name").Joins("left join xt_good_information as t on t.id = x.good_id and t.org_id = ? and t.status = 1", orgid).Scan(&prepare).Error
2867
+	return prepare, err
2893 2868
 }
2894 2869
 
2895 2870
 func GetAutoReduceRecordInfoById(orgid int64, recordtime int64, goodid int64, goodtypeid int64) (*models.XtAutomaticReduceDetail, error) {
@@ -2977,7 +2952,7 @@ func UpdateGoodsInformation(info *models.GoodInfo, goodName string, goodType int
2977 2952
 
2978 2953
 func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
2979 2954
 
2980
-	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
2955
+	db := readDb2.Table("xt_warehouse_out_info as x").Where("x.status  =1")
2981 2956
 	err = db.Select("x.good_id,Sum(x.count) as count,x.remark,x.price,x.org_id").Where("x.ctime >=? and x.ctime<=? and x.org_id = ?", startime, endtime, orgid).Group("x.good_id").Scan(&houseOutInfo).Error
2982 2957
 	return houseOutInfo, err
2983 2958
 }
@@ -2985,10 +2960,10 @@ func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutI
2985 2960
 func GetGoodInfomationList(orgid int64, keyword string) (goodInfo []*models.GoodInfo, err error) {
2986 2961
 	key := "%" + keyword + "%"
2987 2962
 	if len(keyword) == 0 {
2988
-		err = XTReadDB().Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodInfo).Error
2963
+		err = readDb2.Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodInfo).Error
2989 2964
 
2990 2965
 	} else {
2991
-		err = XTReadDB().Where("org_id = ? and status = 1 AND good_name like ? AND  find_in_set('停用',good_status) = 0", orgid, key).Find(&goodInfo).Error
2966
+		err = readDb2.Where("org_id = ? and status = 1 AND good_name like ? AND  find_in_set('停用',good_status) = 0", orgid, key).Find(&goodInfo).Error
2992 2967
 
2993 2968
 	}
2994 2969
 	return goodInfo, err
@@ -3069,7 +3044,7 @@ func EditDrugWarehousingOne(warehouse models.DrugWarehouse, id int64) {
3069 3044
 
3070 3045
 func GetAllManufacturerList(orgid int64) (list []*models.Manufacturer, err error) {
3071 3046
 
3072
-	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
3047
+	err = readDb2.Where("org_id = ? and status = 1", orgid).Find(&list).Error
3073 3048
 	return list, err
3074 3049
 }
3075 3050
 
@@ -3235,26 +3210,32 @@ func GetWarehouseOrderInfoList(orgid int64) (list []*models.WarehousingInfo, err
3235 3210
 
3236 3211
 func GetSearchDrugList(keywords string, orgid int64) (drug []*models.BaseDrugLib, err error) {
3237 3212
 
3238
-	db := XTReadDB().Model(&drug).Where("org_id=? and status=1 ", orgid)
3213
+	db := XTReadDB().Model(&drug).Where("org_id=? and status=1  and drug_status<>'停用'", orgid)
3239 3214
 	if len(keywords) > 0 {
3240 3215
 		likekey := "%" + keywords + "%"
3241
-		err = db.Where("(drug_name LIKE ?)", likekey).Find(&drug).Error
3216
+		err = db.Where("(drug_name LIKE ?)", likekey).Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
3217
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid).Group("id")
3218
+		}).Find(&drug).Error
3242 3219
 	} else {
3243
-		err = db.Find(&drug).Error
3220
+		err = db.Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
3221
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid).Group("id")
3222
+		}).Find(&drug).Error
3244 3223
 	}
3245 3224
 	return
3246 3225
 }
3247 3226
 
3248 3227
 func GetSearchGoodList(keywords string, orgid int64) (good []*models.GoodInfo, err error) {
3249 3228
 
3250
-	db := XTReadDB().Model(&good).Where("org_id =? and status = 1", orgid)
3229
+	db := XTReadDB().Model(&good).Where("org_id =? and status = 1 and good_status <> '停用'", orgid)
3251 3230
 	if len(keywords) > 0 {
3252 3231
 		likekey := "%" + keywords + "%"
3253 3232
 		err = db.Where("(good_name Like ?)", likekey).Preload("StWarehousingInfo", func(db *gorm.DB) *gorm.DB {
3254 3233
 			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid)
3255 3234
 		}).Find(&good).Error
3256 3235
 	} else {
3257
-		err = db.Find(&good).Error
3236
+		err = db.Preload("StWarehousingInfo", func(db *gorm.DB) *gorm.DB {
3237
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid)
3238
+		}).Find(&good).Error
3258 3239
 	}
3259 3240
 	return
3260 3241
 }
@@ -3287,7 +3268,7 @@ func GetAutoMaticReduceDetail(orgid int64, patient_id int64, recordtime int64, g
3287 3268
 func DeleteAutoRedeceDetailTwo(orgid int64, patient_id int64, recordtime int64, goodid int64, goodtypeid int64) error {
3288 3269
 
3289 3270
 	detail := models.BloodAutomaticReduceDetail{}
3290
-	err := XTWriteDB().Model(&detail).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ? and good_type_id = ?", orgid, patient_id, recordtime, goodid, goodtypeid).Updates(map[string]interface{}{"status": 0}).Error
3271
+	err := XTWriteDB().Model(&detail).Where("org_id = ? and patient_id = ? and record_time = ? and status =1 and good_id = ? and good_type_id = ?", orgid, patient_id, recordtime, goodid, goodtypeid).Updates(map[string]interface{}{"status": 0, "count": 0}).Error
3291 3272
 	return err
3292 3273
 }
3293 3274
 
@@ -3296,6 +3277,12 @@ func UpDateWarehouseInfoByStockDelete(id int64, count int64) (err error) {
3296 3277
 	return err
3297 3278
 }
3298 3279
 
3280
+func UpDateWarehouStockFlowByStockDelete(id int64, recordtime int64, good_id int64, count int64, patient_id int64) (err error) {
3281
+
3282
+	err = writeDb.Model(&models.VmStockFlow{}).Where("warehousing_id = ? and system_time = ? and good_id = ? and patient_id = ?", id, recordtime, good_id, patient_id).UpdateColumn("count", gorm.Expr("count - ?", count)).Error
3283
+	return err
3284
+}
3285
+
3299 3286
 func UpDateWarehouseInfoByStockDeleteOne(id int64, count int64) (err error) {
3300 3287
 	err = writeDb.Model(&models.WarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_count", gorm.Expr("stock_count - ?", count)).Error
3301 3288
 	return err
@@ -3320,6 +3307,12 @@ func FindGoodInfoByIdTwo(id int64) (goodInfo models.GoodInfo, err error) {
3320 3307
 	return
3321 3308
 }
3322 3309
 
3310
+func GetGoodWarehouseInfo(good_id int64) (info []*models.WarehousingInfo, err error) {
3311
+
3312
+	err = readDb.Where("good_id = ? and status = 1 and stock_count<>0", good_id).Find(&info).Error
3313
+	return info, err
3314
+}
3315
+
3323 3316
 func GetAllStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.VmWarehousingInfo, total int64, err error) {
3324 3317
 
3325 3318
 	offset := (page - 1) * limit
@@ -3351,7 +3344,7 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
3351 3344
 func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.GoodInfo, total int64, err error) {
3352 3345
 
3353 3346
 	offset := (page - 1) * limit
3354
-	db := XTReadDB().Table("xt_good_information as x").Where("x.status= 1")
3347
+	db := readDb2.Table("xt_good_information as x").Where("x.status= 1")
3355 3348
 
3356 3349
 	likeKey := "%" + keyword + "%"
3357 3350
 	if len(likeKey) > 0 {
@@ -3438,7 +3431,7 @@ func GetStockOutList(good_id int64, orgid int64, limit int64, page int64, starti
3438 3431
 
3439 3432
 func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
3440 3433
 
3441
-	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
3434
+	db := readDb2.Table("xt_warehouse_info as x").Where("x.status = 1")
3442 3435
 	if startime > 0 {
3443 3436
 		db = db.Where("x.ctime >=?", startime)
3444 3437
 	}
@@ -3454,7 +3447,7 @@ func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*mode
3454 3447
 }
3455 3448
 
3456 3449
 func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
3457
-	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
3450
+	db := readDb2.Table("xt_warehouse_out_info as x").Where("x.status = 1")
3458 3451
 	if startime > 0 {
3459 3452
 		db = db.Where("x.ctime >=?", startime)
3460 3453
 	}
@@ -3472,7 +3465,7 @@ func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*
3472 3465
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
3473 3466
 
3474 3467
 	if endtime > 0 {
3475
-		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count,x.record_time 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
3468
+		err = readDb2.Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count,x.record_time 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
3476 3469
 	}
3477 3470
 	if endtime == 0 {
3478 3471
 		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count,x.record_time FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
@@ -3493,7 +3486,7 @@ func GetOrderDetialByOrderId(id int64, orgid int64) (out []*models.WarehouseOutI
3493 3486
 	if orgid > 0 {
3494 3487
 		db = db.Where("x.org_id = ?", orgid)
3495 3488
 	}
3496
-	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id").Order("x.ctime desc").Scan(&out).Error
3489
+	err = db.Select("x.id,x.warehouse_out_id,x.warehouse_info_id,x.good_id,sum(x.count) as count,x.price,x.total_price,x.product_date,x.expiry_date,x.ctime,x.org_id,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.number,x.remark,x.license_number,t.good_name,t.good_type_id,t.specification_name,t.min_number,t.packing_unit,t.min_unit").Joins("left join xt_good_information as t on t.id=x.good_id").Group("x.good_id,x.warehouse_info_id").Order("x.ctime desc").Scan(&out).Error
3497 3490
 	return out, err
3498 3491
 }
3499 3492
 
@@ -3541,7 +3534,7 @@ func FindUserDetailByIdOne(good_id int64, record_time int64, org_id int64) (user
3541 3534
 	db = db.Preload("GoodsType", "status = 1")
3542 3535
 	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
3543 3536
 	db = db.Preload("WarehouseOutInfo", "org_id = ? and status = 1 and good_id = ? and sys_record_time = ?", org_id, good_id, record_time)
3544
-	db = db.Where("status = 1 AND org_id = ? AND good_id = ? AND record_time = ? ", org_id, good_id, record_time)
3537
+	db = db.Where("status = 1 AND org_id = ? AND good_id = ? AND record_time = ? and count<> 0 ", org_id, good_id, record_time)
3545 3538
 	db = db.Count(&total)
3546 3539
 	err = db.Find(&user).Error
3547 3540
 
@@ -3586,8 +3579,8 @@ func GetExprotStockList(orgid int64, orderid []string, startime int64, endtime i
3586 3579
 
3587 3580
 func GetDrugWarehouOrderInfo(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
3588 3581
 
3589
-	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
3590
-	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
3582
+	db := readDb2.Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
3583
+	table := readDb2.Table("xt_base_drug as t").Where("t.status = 1")
3591 3584
 	fmt.Println(table)
3592 3585
 	if startime > 0 {
3593 3586
 		db = db.Where("x.ctime>=?", startime)
@@ -3759,6 +3752,19 @@ func GetDrugTotalCountOne(drugid int64, orgid int64, id int64) (models.VmDrugWar
3759 3752
 	return info, err
3760 3753
 }
3761 3754
 
3755
+func GetDrugTotalCountTwo(drugid int64) (list []*models.VmDrugWarehouseInfo, err error) {
3756
+
3757
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
3758
+	table := XTReadDB().Table("xt_base_drug as d").Where("d.status = 1")
3759
+	fmt.Println(table)
3760
+	if drugid > 0 {
3761
+		db = db.Where("x.drug_id = ?", drugid)
3762
+	}
3763
+	err = db.Select("x.drug_id,x.stock_max_number,x.stock_min_number,d.min_number").Joins("left join xt_base_drug as d on d.id = x.drug_id").Scan(&list).Error
3764
+
3765
+	return list, err
3766
+}
3767
+
3762 3768
 func GetDrugByGoodId(drugid int64) (models.BaseDrugLib, error) {
3763 3769
 
3764 3770
 	lib := models.BaseDrugLib{}
@@ -3871,7 +3877,7 @@ func GetCancelStockOrderPrintOne(idstr []string, orgid int64) (info []*models.Ca
3871 3877
 
3872 3878
 func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
3873 3879
 
3874
-	db := XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
3880
+	db := readDb2.Table("xt_cancel_stock_info as x").Where("x.status = 1")
3875 3881
 
3876 3882
 	if startime > 0 {
3877 3883
 		db = db.Where("x.ctime >=?", startime)
@@ -3916,6 +3922,21 @@ func GetWarehoureOrderInfoCount(goodid int64, orgid int64, id int64) (info model
3916 3922
 	return info, err
3917 3923
 }
3918 3924
 
3925
+func GetWarehoureOrderStockOutFlow(goodid int64, orgid int64, id int64) (info models.VmStockFlow, err error) {
3926
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status =1 and x.consumable_type = 2 or x.consumable_type = 3")
3927
+	if goodid > 0 {
3928
+		db = db.Where("x.good_id = ?", goodid)
3929
+	}
3930
+	if orgid > 0 {
3931
+		db = db.Where("x.user_org_id = ?", orgid)
3932
+	}
3933
+	if id > 0 {
3934
+		db = db.Where("x.warehousing_id = ?", id)
3935
+	}
3936
+	err = db.Select("x.good_id,sum(x.count) as count").Scan(&info).Error
3937
+	return info, err
3938
+}
3939
+
3919 3940
 func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3920 3941
 	stock := models.CancelStock{}
3921 3942
 	err := XTWriteDB().Model(&stock).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
@@ -3924,13 +3945,13 @@ func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3924 3945
 
3925 3946
 func GetStockBatchNumber(id int64, orgid int64) (info []*models.WarehousingInfo, err error) {
3926 3947
 
3927
-	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Group("number").Find(&info).Error
3948
+	err = XTReadDB().Model(&info).Where("good_id = ? and org_id = ? and status = 1 and number <> ''", id, orgid).Find(&info).Error
3928 3949
 	return info, err
3929 3950
 }
3930 3951
 
3931 3952
 func GetWarehouseOutInfoById(id int64, goodid int64) (info []*models.WarehouseOutInfo, err error) {
3932 3953
 
3933
-	err = XTReadDB().Model(&info).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&info).Error
3954
+	err = XTReadDB().Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&info).Error
3934 3955
 	return info, err
3935 3956
 }
3936 3957
 
@@ -3942,7 +3963,7 @@ func GetStockFlowBatchNumber(id int64, goodid int64) (stock []*models.VmStockFlo
3942 3963
 
3943 3964
 func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStockFlowOne, err error) {
3944 3965
 
3945
-	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1")
3966
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status = 1 and count > 0")
3946 3967
 	table := XTReadDB().Table("xt_patients as t").Where("t.status = 1")
3947 3968
 	fmt.Println(table)
3948 3969
 	tableone := XTReadDB().Table("xt_good_information as o").Where("o.status = 1")
@@ -3997,11 +4018,11 @@ func GetExportOutOrderDrugListOne(warehouse_out_id []string) (out []*models.StDr
3997 4018
 	if len(warehouse_out_id) > 0 {
3998 4019
 		db = db.Where("x.warehouse_out_id in(?)", warehouse_out_id)
3999 4020
 	}
4000
-	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.max_unit as count_unit,x.price,x.product_date,x.expire_date as expire_date,x.warehouse_out_order_number,x.dealer,x.manufacturer,x.is_sys,x.number,x.batch_number,x.patient_id,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type,b.min_price").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
4021
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.max_unit as count_unit,x.price,x.product_date,x.expire_date,x.warehouse_out_order_number,x.dealer,x.manufacturer,x.is_sys,x.number,x.batch_number,x.patient_id,b.dose,b.dose_unit,b.min_number,b.min_unit,b.max_unit,b.drug_name,b.drug_type,b.min_price").Joins("left join xt_base_drug as b on b.id = x.drug_id").Scan(&out).Error
4001 4022
 	return out, err
4002 4023
 }
4003 4024
 
4004
-func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid int64) (models.WarehouseOutInfo, error) {
4025
+func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid_id int64) (models.WarehouseOutInfo, error) {
4005 4026
 
4006 4027
 	info := models.WarehouseOutInfo{}
4007 4028
 	err := XTReadDB().Where("good_id = ? and warehouse_info_id= ? and status =1", goodid, warehouse_info_id).Last(&info).Error
@@ -4036,7 +4057,7 @@ func UpdateWarehousingInfo(info models.WarehousingInfo, id int64) error {
4036 4057
 }
4037 4058
 
4038 4059
 func FindFirstWarehousingInfoByGoodId(good_id int64, id int64) (info models.WarehousingInfo, err error) {
4039
-	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND status = 1 and id<>?", good_id, id).Order("ctime").First(&info).Error
4060
+	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND status = 1 and stock_count > 0", good_id).Order("ctime asc").First(&info).Error
4040 4061
 	return info, err
4041 4062
 }
4042 4063
 
@@ -4103,6 +4124,12 @@ func UpdatedStockFlow(flow models.VmStockFlow) error {
4103 4124
 	return err
4104 4125
 }
4105 4126
 
4127
+func UpdatedStockFlowOne(flow models.VmStockFlow, warehousing_id int64, patient_id int64, record_time int64, good_id int64) error {
4128
+
4129
+	err = XTWriteDB().Model(&flow).Where("warehousing_id = ? and patient_id = ? and system_time = ? and good_id = ? and status = 1", warehousing_id, patient_id, record_time, good_id).Updates(map[string]interface{}{"number": flow.Number, "license_number": flow.LicenseNumber, "count": flow.Count, "expire_date": flow.ExpireDate, "product_date": flow.ProductDate, "price": flow.Price, "manufacturer": flow.Manufacturer, "dealer": flow.Dealer}).Error
4130
+	return err
4131
+}
4132
+
4106 4133
 func GetStockFlowIsExsit(warehousing_id int64, patient_id int64, record_time int64, good_id int64) (*models.VmStockFlow, error) {
4107 4134
 
4108 4135
 	stock := models.VmStockFlow{}
@@ -4169,6 +4196,13 @@ func GetStockFlowList(limit int64, page int64, consumable_type int64, orgId int6
4169 4196
 		if consumable_type == 4 {
4170 4197
 			db = db.Where(" consumable_type = ?", consumable_type)
4171 4198
 		}
4199
+
4200
+		if consumable_type == 10 {
4201
+			db = db.Where(" consumable_type = ?", consumable_type)
4202
+		}
4203
+		if consumable_type == 11 {
4204
+			db = db.Where(" consumable_type = ?", consumable_type)
4205
+		}
4172 4206
 	}
4173 4207
 	if orgId > 0 {
4174 4208
 		db = db.Where("user_org_id = ?", orgId)
@@ -4354,6 +4388,12 @@ func GetDrugWarehouseInfo(id int64) (models.XtDrugWarehouseInfo, error) {
4354 4388
 	return info, err
4355 4389
 }
4356 4390
 
4391
+func GetDrugWarehouseInfoPrescription(drugid int64, orgid int64) (info []*models.DrugWarehouseInfo, err error) {
4392
+
4393
+	err = XTReadDB().Where("drug_id = ? and org_id =? and status = 1", drugid, orgid).Find(&info).Error
4394
+	return info, err
4395
+}
4396
+
4357 4397
 func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
4358 4398
 
4359 4399
 	info := models.XtDrugWarehouseInfo{}
@@ -4384,15 +4424,29 @@ func GetLastCancelStockInfo(id int64) (models.DrugCancelStockInfo, error) {
4384 4424
 	return info, err
4385 4425
 }
4386 4426
 
4427
+func GetLastCancelStockInfoOne(id int64, drug_id int64) (models.DrugCancelStockInfo, error) {
4428
+
4429
+	info := models.DrugCancelStockInfo{}
4430
+
4431
+	err := XTReadDB().Where("cancel_stock_id = ? and drug_id = ? and status = 1", id, drug_id).Find(&info).Error
4432
+	return info, err
4433
+}
4434
+
4387 4435
 func UpdatedDrugInfo(id int64, count int64) (err error) {
4388 4436
 
4389
-	err = writeDb.Model(&models.DrugWarehousingInfo{}).Where("id = ?", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
4437
+	err = XTWriteDB().Model(&models.XtDrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
4438
+	return err
4439
+}
4440
+
4441
+func UpdatedDrugFlow(cancelstockid int64, drug_id int64, flow models.DrugFlow) error {
4442
+
4443
+	err := XTWriteDB().Model(&models.DrugFlow{}).Where("cancel_stock_id = ? and drug_id = ? and status = 1", cancelstockid, drug_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4390 4444
 	return err
4391 4445
 }
4392 4446
 
4393 4447
 func UpdatedDrugInfoOne(id int64, count int64) (err error) {
4394 4448
 
4395
-	err = writeDb.Model(&models.XtDrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
4449
+	err = XTWriteDB().Model(&models.XtDrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
4396 4450
 	return err
4397 4451
 }
4398 4452
 
@@ -4614,6 +4668,63 @@ func GetReportStockList(startime int64, endtime int64, orgid int64, keyword stri
4614 4668
 	return adjust, total, err
4615 4669
 }
4616 4670
 
4671
+func GetStockDamagedList(orgid int64, keyword string, page int64, limit int64, startime int64, endtime int64) (adjust []*models.VmStockInventory, total int64, err error) {
4672
+	likeKey := "%" + keyword + "%"
4673
+	offset := (page - 1) * limit
4674
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.inventory_type = 4")
4675
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
4676
+	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4677
+	fmt.Println(table, tab)
4678
+
4679
+	if len(keyword) > 0 {
4680
+		db = db.Where("x.warehousing_order like ? or r.user_name like ?", likeKey, likeKey)
4681
+	}
4682
+
4683
+	if orgid > 0 {
4684
+		db = db.Where("x.user_org_id = ?", orgid)
4685
+	}
4686
+	if startime > 0 {
4687
+		db = db.Where("x.ctime >=?", startime)
4688
+	}
4689
+	if endtime > 0 {
4690
+		db = db.Where("x.ctime <=?", endtime)
4691
+	}
4692
+
4693
+	err = db.Group("x.id").Select("x.ctime,x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,t.packing_unit,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&adjust).Error
4694
+	return adjust, total, err
4695
+
4696
+}
4697
+
4698
+func GetStockDamagedCountOne(orgid int64, keyword string, inventory_type int64) (adjust []*models.VmStockInventory, err error) {
4699
+
4700
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1")
4701
+	if inventory_type == 0 {
4702
+		db = db.Where("x.inventory_type = 4")
4703
+	}
4704
+	if inventory_type > 0 {
4705
+		db = db.Where("x.inventory_type = ?", inventory_type)
4706
+	}
4707
+	if len(keyword) > 0 {
4708
+		likeKey := "%" + keyword + "%"
4709
+		db = db.Where("x.warehousing_order like ?", likeKey)
4710
+	}
4711
+	if orgid > 0 {
4712
+		db = db.Where("x.user_org_id = ?", orgid)
4713
+	}
4714
+	err = db.Group("x.good_id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,sum(x.count) as count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number").Scan(&adjust).Error
4715
+	return adjust, err
4716
+}
4717
+
4718
+func GetStockDamagedCount(orgid int64) (adjust []*models.VmStockInventory, err error) {
4719
+
4720
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and inventory_type = 4 ")
4721
+	if orgid > 0 {
4722
+		db = db.Where("x.user_org_id = ?", orgid)
4723
+	}
4724
+	err = db.Group("x.good_id").Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,sum(x.count) as count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number").Scan(&adjust).Error
4725
+	return adjust, err
4726
+}
4727
+
4617 4728
 func UpdateCheckDamage(ids []string, reportPrice models.XtStockReportPrice) error {
4618 4729
 
4619 4730
 	err := XTWriteDB().Model(&reportPrice).Where("id in(?) and status = 1", ids).Updates(map[string]interface{}{"checker": reportPrice.Checker, "checker_time": reportPrice.CheckerTime, "checker_status": reportPrice.CheckerStatus}).Error
@@ -4752,17 +4863,17 @@ func GetInventoryDetailList(keyword string, limit int64, page int64, orgid int64
4752 4863
 
4753 4864
 	likeKey := "%" + keyword + "%"
4754 4865
 	offset := (page - 1) * limit
4755
-	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1")
4866
+	db := XTReadDB().Table("xt_stock_inventory as x").Where("x.status = 1 and x.type = 10")
4756 4867
 	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
4757 4868
 	tab := UserReadDB().Table("sgj_user_admin_role as r").Where("r.status = 1")
4758 4869
 	fmt.Println(table, tab)
4759 4870
 	if len(keyword) > 0 {
4760
-		db = db.Where("x.warehousing_order = ? or r.user_name like ?", keyword, likeKey)
4871
+		db = db.Where("x.good_name like ?", likeKey)
4761 4872
 	}
4762 4873
 	if orgid > 0 {
4763 4874
 		db = db.Where("x.user_org_id = ?", orgid)
4764 4875
 	}
4765
-	err = db.Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,x.expire_date,x.product_date,t.packing_unit").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
4876
+	err = db.Select("x.id,x.good_name,x.specification_name,x.warehousing_unit,x.count,x.buy_price,x.packing_price,x.new_price,x.manufacturer,x.dealer,x.remark,x.good_id,x.warehousing_order,x.license_number,x.start_time,x.creater,x.checker,x.checker_status,x.checker_time,x.total,x.number,x.expire_date,x.product_date,t.packing_unit,x.last_stock_count,x.type,x.inventory_type,x.stock_count").Joins("left join sgj_users.sgj_user_admin_role as r on r.id = x.creater").Joins("left join xt_good_information as t on t.id =x.good_id").Count(&total).Offset(offset).Limit(limit).Scan(&list).Error
4766 4877
 	return list, total, err
4767 4878
 }
4768 4879
 
@@ -4845,3 +4956,135 @@ func ModifyDrugWarehouseInfo(info *models.DrugWarehouseInfo, id int64) error {
4845 4956
 	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_max_number": info.StockMaxNumber, "stock_min_number": info.StockMinNumber}).Error
4846 4957
 	return err
4847 4958
 }
4959
+
4960
+func GetGoodInventoryWarehouseList(id int64) (info []*models.WarehousingInfo, err error) {
4961
+
4962
+	err = XTReadDB().Model(&info).Where("good_id = ? and status = 1", id).Preload("GoodInfo", "status = 1").Find(&info).Error
4963
+	return info, err
4964
+}
4965
+
4966
+func UpdatedWarehousingInfo(info models.WarehousingInfo, id int64) error {
4967
+	err := XTWriteDB().Model(&info).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"stock_count": info.StockCount}).Error
4968
+	return err
4969
+}
4970
+
4971
+func GetDamageDetailByGoodId(good_id int64, keyword string, inventory_type int64) (list []*models.XtStockInventory, err error) {
4972
+
4973
+	db := XTReadDB().Model(&list).Where(" status = 1")
4974
+	if good_id > 0 {
4975
+		db = db.Where("good_id = ?", good_id)
4976
+	}
4977
+	if len(keyword) > 0 {
4978
+		likeKey := "%" + keyword + "%"
4979
+		db = db.Where("warehousing_order like ?", likeKey)
4980
+	}
4981
+	if inventory_type > 0 {
4982
+		db = db.Where("inventory_type = ?", inventory_type)
4983
+	}
4984
+	if inventory_type == 0 {
4985
+		db = db.Where("inventory_type = 4")
4986
+	}
4987
+	err = db.Find(&list).Error
4988
+
4989
+	return list, err
4990
+}
4991
+
4992
+func GetCancelStockId(cancelstock_id int64, drug_id int64) (*models.DrugFlow, error) {
4993
+	flow := models.DrugFlow{}
4994
+	err := XTReadDB().Where("cancel_stock_id = ? and drug_id = ?", cancelstock_id, drug_id).Find(&flow).Error
4995
+	if err == gorm.ErrRecordNotFound {
4996
+		return nil, err
4997
+	}
4998
+	if err != nil {
4999
+		return nil, err
5000
+	}
5001
+	return &flow, nil
5002
+}
5003
+
5004
+func GetTotalDrugCancelInfo(batchNumber_id int64, drug_id int64, id int64) (info []*models.DrugCancelStockInfo, err error) {
5005
+
5006
+	err = XTReadDB().Where("batch_number_id = ? and drug_id = ? and status = 1 and id<>?", batchNumber_id, drug_id, id).Find(&info).Error
5007
+	return info, err
5008
+}
5009
+
5010
+func GetLastDrugWarehouseInfo(drugid int64) (models.XtDrugWarehouseInfo, error) {
5011
+	info := models.XtDrugWarehouseInfo{}
5012
+	err := XTReadDB().Where("drug_id = ? and status =1", drugid).Last(&info).Error
5013
+	return info, err
5014
+}
5015
+
5016
+func GetLastGoodWarehouseInfo(goodid int64) (models.WarehousingInfo, error) {
5017
+
5018
+	info := models.WarehousingInfo{}
5019
+	err := XTReadDB().Where("good_id =? and status = 1", goodid).Find(&info).Error
5020
+	return info, err
5021
+}
5022
+
5023
+func GetGoodStockFlowInfo(warehouseid int64, goodid int64) (*models.VmStockFlow, error) {
5024
+
5025
+	flow := models.VmStockFlow{}
5026
+	err := XTReadDB().Where("warehousing_detail_id = ? and good_id = ? and status = 1", warehouseid, goodid).Find(&flow).Error
5027
+	if err == gorm.ErrRecordNotFound {
5028
+		return nil, err
5029
+	}
5030
+	if err != nil {
5031
+		return nil, err
5032
+	}
5033
+	return &flow, nil
5034
+}
5035
+
5036
+func GetLastInfoMationById(id int64) (models.GoodInfo, error) {
5037
+	info := models.GoodInfo{}
5038
+	err := XTReadDB().Where("id =? and status = 1", id).Find(&info).Error
5039
+	return info, err
5040
+}
5041
+
5042
+func UpdateGoodInfoMation(goodid int64, info models.GoodInfo) error {
5043
+
5044
+	err := XTWriteDB().Model(&info).Where("id =? and status = 1", goodid).Updates(map[string]interface{}{"total": info.Total}).Error
5045
+	return err
5046
+}
5047
+
5048
+func UpdateWarehouseInfoByGoodId(info models.WarehousingInfo, id int64) error {
5049
+
5050
+	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount}).Error
5051
+	return err
5052
+}
5053
+
5054
+func UpdateWarehouseInfoByGoodIdOne(info models.WarehousingInfo, id int64) error {
5055
+
5056
+	err := XTWriteDB().Model(&info).Where("id =? and status = 1", id).Updates(map[string]interface{}{"warehousing_count": info.WarehousingCount, "stock_count": info.StockCount, "price": info.Price, "number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "license_number": info.LicenseNumber, "manufacturer": info.Manufacturer, "dealer": info.Dealer, "remark": info.Remark}).Error
5057
+	return err
5058
+}
5059
+
5060
+func UpdatedStockFlowByGoodId(warehousing_id int64, good_id int64, flow models.VmStockFlow) error {
5061
+
5062
+	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
5063
+	return err
5064
+}
5065
+
5066
+func GetInventoryExportList(orgid int64) (info []*models.PatientWarehouseInfo, err error) {
5067
+
5068
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
5069
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
5070
+	fmt.Println(table)
5071
+	if orgid > 0 {
5072
+		db = db.Where("x.org_id = ?", orgid)
5073
+	}
5074
+	err = db.Select("x.id,x.good_id,x.number,x.number,x.product_date,x.expiry_date,x.warehousing_unit,x.dealer,x.manufacturer,t.good_name,t.specification_name,t.packing_unit,t.remark").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id,x.number").Scan(&info).Error
5075
+	return info, err
5076
+}
5077
+
5078
+func GetDrugWarehouseingInfo(id int64) (models.XtDrugWarehouseInfo, error) {
5079
+
5080
+	info := models.XtDrugWarehouseInfo{}
5081
+	err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
5082
+	return info, err
5083
+}
5084
+
5085
+func UpdateDrugWarehouseingInfoSix(id int64, info models.XtDrugWarehouseInfo) error {
5086
+
5087
+	warehouseInfo := models.XtDrugWarehouseInfo{}
5088
+	err := XTWriteDB().Model(&warehouseInfo).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"number": info.Number, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "price": info.Price, "total_price": info.TotalPrice, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit}).Error
5089
+	return err
5090
+}

File diff suppressed because it is too large
+ 869 - 536
service/warhouse_service.go