Browse Source

11月8日库存管理

XMLWAN 3 years ago
parent
commit
ffe238cc04
31 changed files with 2466 additions and 644 deletions
  1. 3 9
      conf/app.conf
  2. 6 63
      controllers/base_api_controller.go
  3. 3 3
      controllers/data_api_controller.go
  4. 59 13
      controllers/dialysis_api_controller.go
  5. 17 3
      controllers/dialysis_record_api_controller.go
  6. 294 58
      controllers/doctors_api_controller.go
  7. 19 10
      controllers/gobal_config_api_controller.go
  8. 499 33
      controllers/his_api_controller.go
  9. 106 115
      controllers/mobile_api_controllers/check_weight_api_controller.go
  10. 92 66
      controllers/mobile_api_controllers/dialysis_api_controller.go
  11. 17 11
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  12. 117 23
      controllers/mobile_api_controllers/patient_api_controller.go
  13. 21 0
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  14. 31 0
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  15. 168 8
      controllers/patient_api_controller.go
  16. 32 7
      controllers/schedule_api_controller.go
  17. 2 1
      controllers/stock_in_api_controller.go
  18. 0 1
      models/good_models.go
  19. 0 25
      models/his_charge_models.go
  20. 0 47
      models/his_models.go
  21. 134 17
      models/patient_models.go
  22. 0 19
      models/stock_models.go
  23. 15 4
      service/dialysis_service.go
  24. 4 4
      service/gobal_config_service.go
  25. 22 0
      service/manage_center_service.go
  26. 101 47
      service/mobile_dialysis_service.go
  27. 591 10
      service/patient_service.go
  28. 43 0
      service/patientmanage_service.go
  29. 35 18
      service/stock_service.go
  30. 1 1
      service/user_service.go
  31. 34 28
      service/warhouse_service.go

+ 3 - 9
conf/app.conf View File

@@ -1,5 +1,5 @@
1 1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3 3
 runmode = dev
4 4
 
5 5
 #
@@ -7,7 +7,7 @@ copyrequestbody = true
7 7
 sessionon = true
8 8
 #sessiongcmaxlifetime = 64800
9 9
 
10
-tokencookiemaxlifetime = 604800
10
+tokencookiemaxlifetime = 7200
11 11
 enablexsrf = false
12 12
 xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
13 13
 xsrfexpire = 3600
@@ -219,12 +219,6 @@ writesgjpatientmysqlpass = 1Q2W3e4r!@#$
219 219
 writesgjpatientmysqlname = sgj_patient
220 220
 
221 221
 
222
-redishost = kuyi6666.redis.rds.aliyuncs.com
223
-readmysqlhost2 = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
224
-readmysqlport2 = 3306
225
-readmysqluser2 = root
226
-readmysqlpass2 = 1Q2W3e4r!@#$
227
-readmysqlname2 = sgj_xt
228 222
 
229 223
 
230 224
 
@@ -232,7 +226,7 @@ readmysqlname2 = sgj_xt
232 226
 
233 227
 #redishost = 120.77.235.13
234 228
 #redishost = 112.74.16.180
235
-redishost = localhost
229
+redishost = kuyi6666.redis.rds.aliyuncs.com
236 230
 redisport = 6379
237 231
 redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
238 232
 redisdb = 7

+ 6 - 63
controllers/base_api_controller.go View File

@@ -3,7 +3,7 @@ package controllers
3 3
 import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/service"
6
-	_ "fmt"
6
+	"fmt"
7 7
 	"strconv"
8 8
 	"strings"
9 9
 )
@@ -69,9 +69,6 @@ type BaseAuthAPIController struct {
69 69
 func (this *BaseAuthAPIController) Prepare() {
70 70
 	this.BaseAPIController.Prepare()
71 71
 	if this.GetAdminUserInfo() == nil {
72
-		var userAdmin models.AdminUser
73
-		userAdmin.Id = 1448
74
-		userAdmin.Mobile = "13416402574"
75 72
 		//var userAdmin models.AdminUser
76 73
 		//userAdmin.Id = 1448
77 74
 		//userAdmin.Mobile = "13318599895"
@@ -102,32 +99,6 @@ func (this *BaseAuthAPIController) Prepare() {
102 99
 
103 100
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
104 101
 		this.StopRun()
105
-		userAdmin.Id = 597
106
-		userAdmin.Mobile = "13416402574"
107
-		userAdmin.IsSuperAdmin = false
108
-		userAdmin.Status = 1
109
-		userAdmin.CreateTime = 1530786071
110
-		userAdmin.ModifyTime = 1530786071
111
-		var subscibe models.ServeSubscibe
112
-		subscibe.ID = 1
113
-		subscibe.OrgId = 10016
114
-		subscibe.PeriodStart = 1538035409
115
-		subscibe.PeriodEnd = 1569571409
116
-		subscibe.State = 1
117
-		subscibe.Status = 1
118
-		subscibe.CreatedTime = 1538035409
119
-		subscibe.UpdatedTime = 1538035409
120
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
121
-		subscibes[4] = &subscibe
122
-		var adminUserInfo service.AdminUserInfo
123
-		adminUserInfo.CurrentOrgId = 10016
124
-		adminUserInfo.CurrentAppId = 4
125
-		adminUserInfo.AdminUser = &userAdmin
126
-		adminUserInfo.Subscibes = subscibes
127
-		this.SetSession("admin_user_info", &adminUserInfo)
128
-
129
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
130
-		//this.StopRun()
131 102
 
132 103
 	}
133 104
 
@@ -147,7 +118,7 @@ func (this *BaseAuthAPIController) Prepare() {
147 118
 			} else {
148 119
 				roles = strings.Split(role.RoleIds, ",")
149 120
 			}
150
-			// fmt.Println(roles)
121
+			fmt.Println(roles)
151 122
 
152 123
 			//获取该用户下所有角色的权限总集
153 124
 			var userRolePurviews string
@@ -163,7 +134,7 @@ func (this *BaseAuthAPIController) Prepare() {
163 134
 			}
164 135
 			//该用户所拥有角色的权限的总集
165 136
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
166
-			// fmt.Println(userRolePurviewsArr)
137
+			fmt.Println("userRolePurviewsArr", userRolePurviewsArr)
167 138
 			//系统所记录的权限列表
168 139
 			allPermission, _ := service.GetAllFunctionPurview()
169 140
 
@@ -194,6 +165,7 @@ func (this *BaseAuthAPIController) Prepare() {
194 165
 						this.StopRun()
195 166
 					}
196 167
 				}
168
+
197 169
 			}
198 170
 		}
199 171
 	}
@@ -212,7 +184,7 @@ func (this *BaseAuthAPIController) Prepare() {
212 184
 			} else {
213 185
 				roles = strings.Split(role.RoleIds, ",")
214 186
 			}
215
-			// fmt.Println(roles)
187
+			fmt.Println(roles)
216 188
 
217 189
 			//获取该用户下所有角色的权限总集
218 190
 			var userRolePurviews string
@@ -228,7 +200,7 @@ func (this *BaseAuthAPIController) Prepare() {
228 200
 			}
229 201
 			//该用户所拥有角色的权限的总集
230 202
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
231
-			// fmt.Println(userRolePurviewsArr)
203
+			fmt.Println(userRolePurviewsArr)
232 204
 			//系统所记录的权限列表
233 205
 			allPermission, _ := service.GetAllFunctionPurview()
234 206
 
@@ -344,35 +316,6 @@ type BaseServeAPIController struct {
344 316
 func (this *BaseServeAPIController) Prepare() {
345 317
 	this.BaseAPIController.Prepare()
346 318
 	if this.GetAdminUserInfo() == nil {
347
-		var userAdmin models.AdminUser
348
-		userAdmin.Id = 1448
349
-		userAdmin.Mobile = "13416402574"
350
-
351
-		userAdmin.Id = 597
352
-		userAdmin.Mobile = "13416402574"
353
-		userAdmin.IsSuperAdmin = false
354
-		userAdmin.Status = 1
355
-		userAdmin.CreateTime = 1530786071
356
-		userAdmin.ModifyTime = 1530786071
357
-		var subscibe models.ServeSubscibe
358
-		subscibe.ID = 1
359
-		subscibe.OrgId = 10016
360
-		subscibe.PeriodStart = 1538035409
361
-		subscibe.PeriodEnd = 1569571409
362
-		subscibe.State = 1
363
-		subscibe.Status = 1
364
-		subscibe.CreatedTime = 1538035409
365
-		subscibe.UpdatedTime = 1538035409
366
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
367
-		subscibes[4] = &subscibe
368
-		var adminUserInfo service.AdminUserInfo
369
-		adminUserInfo.CurrentOrgId = 10016
370
-		adminUserInfo.CurrentAppId = 4
371
-		adminUserInfo.AdminUser = &userAdmin
372
-		adminUserInfo.Subscibes = subscibes
373
-		this.SetSession("admin_user_info", &adminUserInfo)
374
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
375
-		//this.StopRun()
376 319
 		//var userAdmin models.AdminUser
377 320
 		//userAdmin.Id = 1448
378 321
 		//userAdmin.Mobile = "13318599895"

+ 3 - 3
controllers/data_api_controller.go View File

@@ -114,7 +114,7 @@ func (c *DataApiController) CreateConfig() {
114 114
 	} else {
115 115
 		dataconfig.Order = 0
116 116
 	}
117
-	fmt.Println("dataconfig-------------", dataconfig)
117
+
118 118
 	err = service.CreateConfig(&dataconfig)
119 119
 	if err != nil {
120 120
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
@@ -225,7 +225,7 @@ func (c *DataApiController) UpdateChildConfig() {
225 225
 	dataconfig.Remark = string(dataBody["remark"].(string))
226 226
 	dataconfig.Order = int64(dataBody["orders"].(float64))
227 227
 	dataconfig.FieldType = int64(dataBody["field_type"].(float64))
228
-	fmt.Println("dataconfitg------", dataconfig.Order)
228
+
229 229
 	//if dataBody["orders"] != nil {
230 230
 	//	dataconfig.Order = int64(dataBody["orders"].(float64))
231 231
 	//	fmt.Println("dataconfig",dataconfig.Order)
@@ -400,7 +400,7 @@ func configFormData(dataconfig *models.Dataconfig, data []byte) (code int) {
400 400
 	}
401 401
 	dataconfig.Module = module
402 402
 
403
-	if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" || module == "special_treatment" || module == "template_summary" || module == "template_plan" {
403
+	if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" || module == "special_treatment" || module == "template_summary" || module == "template_plan" || module == "admitting_diagnosis" || module == "discharge_diagnosis" || module == "diagnosis_admission" || module == "treatment" || module == "illness_discharge" || module == "discharge_advice" {
404 404
 		if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
405 405
 			utils.ErrorLog("title")
406 406
 			code = enums.ErrorCodeParamWrong

+ 59 - 13
controllers/dialysis_api_controller.go View File

@@ -387,7 +387,7 @@ func (c *DialysisApiController) PostPrescription() {
387 387
 		redis := service.RedisClient()
388 388
 		//清空key 值
389 389
 		redis.Set(key, "", time.Second)
390
-		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
390
+		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
391 391
 		redis.Set(keyTwo, "", time.Second)
392 392
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
393 393
 		redis.Set(keyThree, "", time.Second)
@@ -452,7 +452,7 @@ func (c *DialysisApiController) PostPrescription() {
452 452
 		//清空key 值
453 453
 		redis.Set(key, "", time.Second)
454 454
 
455
-		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
455
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
456 456
 		redis.Set(keyOne, "", time.Second)
457 457
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
458 458
 		redis.Set(keyThree, "", time.Second)
@@ -875,7 +875,7 @@ func (c *DialysisApiController) PostSoulution() {
875 875
 	//清空key 值
876 876
 	redis.Set(keyOne, "", time.Second)
877 877
 
878
-	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
878
+	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
879 879
 	redis.Set(keyTwo, "", time.Second)
880 880
 
881 881
 	keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
@@ -1288,7 +1288,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1288 1288
 		redis := service.RedisClient()
1289 1289
 		//清空key 值
1290 1290
 		redis.Set(key, "", time.Second)
1291
-		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_after_dislysis_list_all"
1291
+		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1292 1292
 		redis.Set(keyThree, "", time.Second)
1293 1293
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1294 1294
 		redis.Set(keyTwo, "", time.Second)
@@ -1311,7 +1311,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1311 1311
 		redis := service.RedisClient()
1312 1312
 		//清空key 值
1313 1313
 		redis.Set(key, "", time.Second)
1314
-		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_after_dislysis_list_all"
1314
+		keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1315 1315
 		redis.Set(keyThree, "", time.Second)
1316 1316
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1317 1317
 		redis.Set(keyTwo, "", time.Second)
@@ -1377,8 +1377,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1377 1377
 	puncture_method := c.GetString("puncture_method")
1378 1378
 
1379 1379
 	dialysis_count := c.GetString("dialysis_count")
1380
-	//dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1381
-	dialysis_count := c.GetString("dialysis_count")
1380
+
1382 1381
 	emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
1383 1382
 	emergency_treatment_other := c.GetString("emergency_treatment_other")
1384 1383
 	ductus_arantii := c.GetString("ductus_arantii")
@@ -1403,7 +1402,6 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1403 1402
 	puncture_needle := c.GetString("puncture_needle")
1404 1403
 	//humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1405 1404
 
1406
-	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1407 1405
 	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1408 1406
 	phinholing := c.GetString("pinholing")
1409 1407
 
@@ -1510,7 +1508,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1510 1508
 		//清空key 值
1511 1509
 		redis.Set(key, "", time.Second)
1512 1510
 
1513
-		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_befores_list_all"
1511
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1514 1512
 		redis.Set(keyOne, "", time.Second)
1515 1513
 
1516 1514
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
@@ -1736,7 +1734,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1736 1734
 		//清空key 值
1737 1735
 		redis.Set(key, "", time.Second)
1738 1736
 
1739
-		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_befores_list_all"
1737
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1740 1738
 		redis.Set(keyOne, "", time.Second)
1741 1739
 		defer redis.Close()
1742 1740
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
@@ -1896,7 +1894,7 @@ func (c *DialysisApiController) GetDialysisWatch() {
1896 1894
 		numberList, _ := service.GetAllDeviceNumberByList(adminUserInfo.CurrentOrgId)
1897 1895
 
1898 1896
 		//获取所有分区
1899
-		//zoneList, _ := service.GetAllZoneByList(adminUserInfo.CurrentOrgId)
1897
+		//	zoneList, _ := service.GetAllZoneByList(adminUserInfo.CurrentOrgId)
1900 1898
 		//获取透析处方
1901 1899
 		prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
1902 1900
 		//获取透前评估
@@ -2295,6 +2293,15 @@ func (this *DialysisApiController) DelMonitor() {
2295 2293
 	//}
2296 2294
 
2297 2295
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
2296
+	key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
2297
+	redis := service.RedisClient()
2298
+	//清空key 值
2299
+	redis.Set(key, "", time.Second)
2300
+
2301
+	keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_record_list_all"
2302
+	redis.Set(keyOne, "", time.Second)
2303
+	defer redis.Close()
2304
+
2298 2305
 	if err != nil {
2299 2306
 		this.ErrorLog("删除透析监测记录失败:%v", err)
2300 2307
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
@@ -2403,6 +2410,13 @@ func (c *DialysisApiController) CreateMonitor() {
2403 2410
 	}
2404 2411
 
2405 2412
 	err := service.CreateMonitor(&monitorRecord)
2413
+	redis := service.RedisClient()
2414
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_record_list_all"
2415
+
2416
+	redis.Set(key, "", time.Second)
2417
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_records"
2418
+	redis.Set(keyOne, "", time.Second)
2419
+	redis.Close()
2406 2420
 	if err != nil {
2407 2421
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2408 2422
 		return
@@ -3257,9 +3271,14 @@ func (c *DialysisApiController) CreateRemindDoctorAdvice() {
3257 3271
 
3258 3272
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
3259 3273
 	redis := service.RedisClient()
3260
-	defer redis.Close()
3261
-	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
3274
+	formatAdviceDate := theTime.Format("2006-01-02")
3275
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
3262 3276
 	redis.Set(key, "", time.Second)
3277
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
3278
+	redis.Set(keyOne, "", time.Second)
3279
+	keyFour := "scheduals_" + formatAdviceDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
3280
+	redis.Set(keyFour, "", time.Second)
3281
+	defer redis.Close()
3263 3282
 	if err != nil {
3264 3283
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3265 3284
 		return
@@ -3434,7 +3453,20 @@ func (c *DialysisApiController) UploadDryWeight() {
3434 3453
 			UserId:        adminUserInfo.AdminUser.Id,
3435 3454
 		}
3436 3455
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3456
+		loc, _ := time.LoadLocation("Local")
3457
+		nowTime := time.Now()
3458
+		nowDay := nowTime.Format("2006-01-02")
3459
+		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
3460
+		redis := service.RedisClient()
3461
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
3462
+		redis.Set(keyOne, "", time.Second)
3437 3463
 
3464
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3465
+		fmt.Println("敢提哦那个key23232332323223232332232323", key)
3466
+		redis.Set(key, "", time.Second)
3467
+		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
3468
+		redis.Set(keyTwo, "", time.Second)
3469
+		redis.Close()
3438 3470
 		if createErr == nil {
3439 3471
 			c.ServeSuccessJSON(map[string]interface{}{
3440 3472
 				"msg":    "提交成功",
@@ -3469,6 +3501,20 @@ func (c *DialysisApiController) UploadDryWeight() {
3469 3501
 		fmt.Println(value)
3470 3502
 
3471 3503
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3504
+		loc, _ := time.LoadLocation("Local")
3505
+		nowTime := time.Now()
3506
+		nowDay := nowTime.Format("2006-01-02")
3507
+		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
3508
+		redis := service.RedisClient()
3509
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
3510
+		redis.Set(keyOne, "", time.Second)
3511
+
3512
+		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3513
+		redis.Set(key, "", time.Second)
3514
+		fmt.Println("敢提哦那个key23232332323223232332232323", key)
3515
+		keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
3516
+		redis.Set(keyTwo, "", time.Second)
3517
+		redis.Close()
3472 3518
 		if createErr == nil {
3473 3519
 			c.ServeSuccessJSON(map[string]interface{}{
3474 3520
 				"msg":    "提交成功",

+ 17 - 3
controllers/dialysis_record_api_controller.go View File

@@ -593,10 +593,13 @@ func (this *DialysisRecordAPIController) EditMonitor() {
593 593
 		createErr := service.CreateMonitor(&monitor)
594 594
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
595 595
 		redis := service.RedisClient()
596
-		defer redis.Close()
597 596
 		//清空key 值
598 597
 		redis.Set(key, "", time.Second)
599 598
 
599
+		keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitorParam.MonitoringDate, 10) + ":monitor_record_list_all"
600
+		redis.Set(keyOne, "", time.Second)
601
+		defer redis.Close()
602
+
600 603
 		if createErr != nil {
601 604
 			this.ErrorLog("创建监测记录失败:%v", createErr)
602 605
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -889,7 +892,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
889 892
 	//清空key 值
890 893
 	redis.Set(key, "", time.Second)
891 894
 
892
-	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
895
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_orders_list_all"
893 896
 	redis.Set(keyOne, "", time.Second)
894 897
 
895 898
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
@@ -979,6 +982,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
979 982
 		// 如果当天有插入数据,则不再往透析纪录里插入数据
980 983
 		if newdialysisRecord.ID > 0 {
981 984
 			err := service.CreateMonitor(&record)
985
+
982 986
 			if err != nil {
983 987
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
984 988
 				return
@@ -1242,7 +1246,7 @@ func (this *DialysisRecordAPIController) FinishDialysis() {
1242 1246
 	//清空key 值
1243 1247
 	redis.Set(key, "", time.Second)
1244 1248
 
1245
-	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
1249
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_orders_list_all"
1246 1250
 	redis.Set(keyOne, "", time.Second)
1247 1251
 
1248 1252
 	if updateErr != nil {
@@ -1411,6 +1415,10 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1411 1415
 	}
1412 1416
 
1413 1417
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
1418
+	redis := service.RedisClient()
1419
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(startDate.Unix(), 10) + ":dialysis_orders_list_all"
1420
+	redis.Set(key, "", time.Second)
1421
+	redis.Close()
1414 1422
 	if updateErr != nil {
1415 1423
 		this.ErrorLog("修改上机失败:%v", updateErr)
1416 1424
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1427,6 +1435,12 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1427 1435
 			hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1428 1436
 			minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
1429 1437
 			updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecord.PatientId, tempDialysisRecord.UserOrgId, tempDialysisRecord.DialysisDate, hour, minute)
1438
+			redis := service.RedisClient()
1439
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":assessment_after_dislysis_list_all"
1440
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(tempDialysisRecord.DialysisDate, 10) + ":dialysis_orders_list_all"
1441
+			redis.Set(key, "", time.Second)
1442
+			redis.Set(keyThree, "", time.Second)
1443
+			redis.Close()
1430 1444
 			if updateAssessmentErr != nil {
1431 1445
 				utils.ErrorLog("%v", updateAssessmentErr)
1432 1446
 			}

+ 294 - 58
controllers/doctors_api_controller.go View File

@@ -53,6 +53,11 @@ func DoctorApiRegistRouters() {
53 53
 	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
54 54
 	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
55 55
 	beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
56
+	beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Get:HospitalSummary")
57
+	beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
58
+	beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
59
+	beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Get:UpdateHospitalSummary")
60
+	beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
56 61
 }
57 62
 
58 63
 func (c *DoctorsApiController) ScheduleAdvices() {
@@ -85,56 +90,53 @@ func (c *DoctorsApiController) ScheduleAdvices() {
85 90
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
86 91
 
87 92
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
88
-	scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
89
-
90
-	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
91 93
 
92 94
 	for _, item := range project {
93 95
 		index := 0
94 96
 		for _, subItem := range item.HisPrescriptionTeamProject {
95 97
 
96
-	//获取所有的患者
97
-	patients, _ := service.GetAllPatientListByListTwo(orgID)
98
+			//获取所有的患者
99
+			patients, _ := service.GetAllPatientListByListTwo(orgID)
98 100
 
99
-	//获取所有床位
100
-	numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
101
+			//获取所有床位
102
+			numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
101 103
 
102
-	//获取透析处方
103
-	prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
104
+			//获取透析处方
105
+			prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
104 106
 
105
-	//获取上机
106
-	dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
107
-	for key, item := range project {
108
-		for _, patient := range patients {
109
-			if item.PatientId == patient.ID {
110
-				project[key].SchedualPatient = patient
111
-				break
112
-			}
113
-		}
114
-		// 获取床位信息
115
-		for _, it := range numberList {
116
-			if item.BedId == it.ID {
117
-				project[key].DeviceNumber = it
118
-				break
119
-			}
120
-		}
107
+			//获取上机
108
+			dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
109
+			for key, item := range project {
110
+				for _, patient := range patients {
111
+					if item.PatientId == patient.ID {
112
+						project[key].SchedualPatient = patient
113
+						break
114
+					}
115
+				}
116
+				// 获取床位信息
117
+				for _, it := range numberList {
118
+					if item.BedId == it.ID {
119
+						project[key].DeviceNumber = it
120
+						break
121
+					}
122
+				}
121 123
 
122
-		// 获取处方
123
-		for _, it := range prescriptions {
124
-			if item.PatientId == it.PatientId {
125
-				project[key].Prescription = it
126
-				break
127
-			}
128
-		}
124
+				// 获取处方
125
+				for _, it := range prescriptions {
126
+					if item.PatientId == it.PatientId {
127
+						project[key].Prescription = it
128
+						break
129
+					}
130
+				}
129 131
 
130
-		//获取上机
131
-		for _, it := range dialysisOrders {
132
-			if item.PatientId == it.PatientId {
133
-				project[key].DialysisOrder = it
134
-				break
132
+				//获取上机
133
+				for _, it := range dialysisOrders {
134
+					if item.PatientId == it.PatientId {
135
+						project[key].DialysisOrder = it
136
+						break
137
+					}
138
+				}
135 139
 			}
136
-		}
137
-	}
138 140
 			if subItem.HisProject.CostClassify != 3 {
139 141
 				subItem.IsCheckTeam = 2
140 142
 				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
@@ -232,28 +234,24 @@ func (c *DoctorsApiController) UpdatedDryWeightData() {
232 234
 	adminUserInfo := c.GetAdminUserInfo()
233 235
 	orgid := adminUserInfo.CurrentOrgId
234 236
 	userid := adminUserInfo.AdminUser.Id
235
-	fmt.Println("userid", userid)
237
+
236 238
 	dry_weight, _ := c.GetFloat("dry_weight")
237
-	fmt.Println("dry_weight", dry_weight)
239
+
238 240
 	doctors, _ := c.GetInt64("doctors")
239
-	fmt.Println("doctors", doctors)
241
+
240 242
 	remarks := c.GetString("remarks")
241
-	fmt.Println("remarks", remarks)
243
+
242 244
 	patientid, _ := c.GetInt64("patient_id")
243
-	fmt.Println("patientid", patientid)
245
+
244 246
 	//透前数据
245 247
 	dryweight, _ := c.GetFloat("dryweight")
246
-	fmt.Println("dryweight", dryweight)
248
+
247 249
 	var weight = dryweight - dry_weight
248 250
 	weights := fmt.Sprintf("%.1f", weight)
249
-	//weights := strconv.FormatFloat(sprintf, 'E', -1, 64)
250 251
 
251
-	fmt.Println("weight", weights)
252
-	fmt.Println("weight", weight)
253 252
 	var sum string
254
-	dryWeight, errcode := service.QueryDryWeight(orgid, patientid)
255
-	fmt.Println("errcode", errcode)
256
-	fmt.Println("dryWeight", dryWeight)
253
+	_, errcode := service.QueryDryWeight(orgid, patientid)
254
+
257 255
 	if errcode == gorm.ErrRecordNotFound {
258 256
 		sum = "/"
259 257
 		patientDryweight := models.SgjPatientDryweight{
@@ -269,6 +267,27 @@ func (c *DoctorsApiController) UpdatedDryWeightData() {
269 267
 		}
270 268
 
271 269
 		err := service.CreatePatientWeight(&patientDryweight)
270
+
271
+		loc, _ := time.LoadLocation("Local")
272
+		nowTime := time.Now()
273
+		nowDay := nowTime.Format("2006-01-02")
274
+		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
275
+		fmt.Println("是错2323223322323232323", dayTime.Unix())
276
+		redis := service.RedisClient()
277
+		keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
278
+		redis.Set(keyTwo, "", time.Second)
279
+
280
+		prescription := models.PredialysisEvaluation{
281
+			DryWeight:      dry_weight,
282
+			AssessmentDate: dayTime.Unix(),
283
+		}
284
+		errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
285
+		fmt.Println(errors)
286
+		keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
287
+		redis.Set(keyThree, "", time.Second)
288
+		keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
289
+		redis.Set(keyFive, "", time.Second)
290
+		redis.Close()
272 291
 		fmt.Println("err", err)
273 292
 		c.ServeSuccessJSON(map[string]interface{}{
274 293
 			"patientDryweight": patientDryweight,
@@ -303,19 +322,34 @@ func (c *DoctorsApiController) UpdatedDryWeightData() {
303 322
 	}
304 323
 
305 324
 	err := service.CreatePatientWeight(&patientDryweight)
306
-	//sgjPatientDryweight, _ := service.GetLastData(orgid)
325
+
307 326
 	recordDateStr := time.Now().Format("2006-01-02")
308 327
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
309 328
 	fmt.Scan("parseDateErr", parseDateErr)
310 329
 	nowtime := recordDate.Unix()
311 330
 	fmt.Println("nowtime", nowtime)
312
-	//prescription := models.PredialysisEvaluation{
313
-	//	DryWeight: dryweight,
314
-	//}
315
-	//errors := service.UpdateDialysisPrescription( sgjPatientDryweight.PatientId, sgjPatientDryweight.UserOrgId, sgjPatientDryweight.DryWeight, prescription)
316
-	//fmt.Println("error",errors)
331
+	loc, _ := time.LoadLocation("Local")
332
+	nowTime := time.Now()
333
+	nowDay := nowTime.Format("2006-01-02")
334
+	dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
335
+	fmt.Println("是错2323223322323232323", dayTime.Unix())
336
+	redis := service.RedisClient()
337
+
338
+	keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
339
+	redis.Set(keyTwo, "", time.Second)
340
+
341
+	prescription := models.PredialysisEvaluation{
342
+		DryWeight:      dry_weight,
343
+		AssessmentDate: dayTime.Unix(),
344
+	}
345
+	errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
346
+	key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
347
+	redis.Set(key, "", time.Second)
348
+	keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
349
+	redis.Set(keySix, "", time.Second)
350
+	fmt.Println("error", errors)
317 351
 	fmt.Println("err", err)
318
-	fmt.Println("patientdryweight", patientDryweight)
352
+	redis.Close()
319 353
 	c.ServeSuccessJSON(map[string]interface{}{
320 354
 		"patientDryweight": patientDryweight,
321 355
 	})
@@ -1173,3 +1207,205 @@ func (this *DoctorsApiController) DeleteSummary() {
1173 1207
 	this.ServeSuccessJSON(returnData)
1174 1208
 	return
1175 1209
 }
1210
+
1211
+func (this *DoctorsApiController) HospitalSummary() {
1212
+
1213
+	timeLayout := "2006-01-02"
1214
+	loc, _ := time.LoadLocation("Local")
1215
+	admission_time := this.GetString("admission_time")
1216
+	admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
1217
+	admissiontime := admissionTimes.Unix()
1218
+
1219
+	admitting_diagnosis := this.GetString("admitting_diagnosis")
1220
+	admitting_diagnosis_id := this.GetString("admitting_diagnosis_id")
1221
+
1222
+	connecticut := this.GetString("connecticut")
1223
+	dean, _ := this.GetInt64("dean")
1224
+	discharge_diagnosis := this.GetString("discharge_diagnosis")
1225
+
1226
+	discharge_diagnosis_id := this.GetString("discharge_diagnosis_id")
1227
+	diagnosis_admission := this.GetString("diagnosis_admission")
1228
+	diagnosis_admission_id := this.GetString("diagnosis_admission_id")
1229
+	discharge_advice_id := this.GetString("discharge_advice_id")
1230
+	discharge_advice := this.GetString("discharge_advice")
1231
+
1232
+	discharge_time := this.GetString("discharge_time")
1233
+	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
1234
+	dischargetime := dischargeTimes.Unix()
1235
+	doctor, _ := this.GetInt64("doctor")
1236
+	illness_discharge_id := this.GetString("illness_discharge_id")
1237
+	illness_discharge := this.GetString("illness_discharge")
1238
+	nuclear_magnetic_resonance := this.GetString("nuclear_magnetic_resonance")
1239
+	pathology := this.GetString("pathology")
1240
+	record_date := this.GetString("record_date")
1241
+	recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1242
+	recordtime := recordDates.Unix()
1243
+	sick_personnel := this.GetString("sick_personnel")
1244
+	title := this.GetString("title")
1245
+	treatment_id := this.GetString("treatment_id")
1246
+	treatment := this.GetString("treatment")
1247
+	ultrasound := this.GetString("ultrasound")
1248
+	xray := this.GetString("xray")
1249
+	patient_id, _ := this.GetInt64("patient_id")
1250
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1251
+	summary := models.XtHospitalSummary{
1252
+		PatientId:                patient_id,
1253
+		AdmissionTime:            admissiontime,
1254
+		DischargeTime:            dischargetime,
1255
+		SickPersonnel:            sick_personnel,
1256
+		Xray:                     xray,
1257
+		Connecticut:              connecticut,
1258
+		NuclearMagneticResonance: nuclear_magnetic_resonance,
1259
+		Ultrasound:               ultrasound,
1260
+		Pathology:                pathology,
1261
+		AdmittingDiagnosisId:     admitting_diagnosis_id,
1262
+		AdmittingDiagnosis:       admitting_diagnosis,
1263
+		DischargeDiagnosis:       discharge_diagnosis,
1264
+		DiagnosisAdmissionId:     diagnosis_admission_id,
1265
+		DiagnosisAdmission:       diagnosis_admission,
1266
+		TreatmentId:              treatment_id,
1267
+		Treatment:                treatment,
1268
+		IllnessDischargeId:       illness_discharge_id,
1269
+		IllnessDischarge:         illness_discharge,
1270
+		DischargeAdviceId:        discharge_advice_id,
1271
+		DischargeAdvice:          discharge_advice,
1272
+		UserOrgId:                orgId,
1273
+		Status:                   1,
1274
+		Ctime:                    time.Now().Unix(),
1275
+		Mtime:                    0,
1276
+		RecordTime:               recordtime,
1277
+		Title:                    title,
1278
+		Doctor:                   doctor,
1279
+		RecordDate:               recordtime,
1280
+		DeanId:                   dean,
1281
+		DischargeDiagnosisId:     discharge_diagnosis_id,
1282
+	}
1283
+	service.CreateHisSummary(&summary)
1284
+	this.ServeSuccessJSON(map[string]interface{}{
1285
+		"list": summary,
1286
+	})
1287
+	return
1288
+}
1289
+
1290
+func (this *DoctorsApiController) GetHospitalSummaryList() {
1291
+
1292
+	timeLayout := "2006-01-02"
1293
+	loc, _ := time.LoadLocation("Local")
1294
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1295
+	patient_id, _ := this.GetInt64("patient_id")
1296
+	start_time := this.GetString("start_time")
1297
+	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1298
+	startime := dischargeTimes.Unix()
1299
+	end_time := this.GetString("end_time")
1300
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
1301
+	endtime := endTimes.Unix()
1302
+	list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
1303
+	if err == nil {
1304
+		this.ServeSuccessJSON(map[string]interface{}{
1305
+			"list": list,
1306
+		})
1307
+		return
1308
+	}
1309
+}
1310
+
1311
+func (this *DoctorsApiController) GetHospitalSummaryDetail() {
1312
+
1313
+	id, _ := this.GetInt64("id")
1314
+	detail, err := service.GetHospitalSummaryDetail(id)
1315
+	if err == nil {
1316
+		this.ServeSuccessJSON(map[string]interface{}{
1317
+			"detail": detail,
1318
+		})
1319
+		return
1320
+	}
1321
+}
1322
+
1323
+func (this *DoctorsApiController) UpdateHospitalSummary() {
1324
+
1325
+	timeLayout := "2006-01-02"
1326
+	loc, _ := time.LoadLocation("Local")
1327
+	admission_time := this.GetString("admission_time")
1328
+	admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
1329
+	admissiontime := admissionTimes.Unix()
1330
+
1331
+	id, _ := this.GetInt64("id")
1332
+	admitting_diagnosis := this.GetString("admitting_diagnosis")
1333
+	admitting_diagnosis_id := this.GetString("admitting_diagnosis_id")
1334
+
1335
+	connecticut := this.GetString("connecticut")
1336
+	dean, _ := this.GetInt64("dean")
1337
+	discharge_diagnosis := this.GetString("discharge_diagnosis")
1338
+
1339
+	discharge_diagnosis_id := this.GetString("discharge_diagnosis_id")
1340
+	diagnosis_admission := this.GetString("diagnosis_admission")
1341
+	diagnosis_admission_id := this.GetString("diagnosis_admission_id")
1342
+	discharge_advice_id := this.GetString("discharge_advice_id")
1343
+	discharge_advice := this.GetString("discharge_advice")
1344
+
1345
+	discharge_time := this.GetString("discharge_time")
1346
+	dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
1347
+	dischargetime := dischargeTimes.Unix()
1348
+	doctor, _ := this.GetInt64("doctor")
1349
+	illness_discharge_id := this.GetString("illness_discharge_id")
1350
+	illness_discharge := this.GetString("illness_discharge")
1351
+	nuclear_magnetic_resonance := this.GetString("nuclear_magnetic_resonance")
1352
+	pathology := this.GetString("pathology")
1353
+	record_date := this.GetString("record_date")
1354
+	recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1355
+	recordtime := recordDates.Unix()
1356
+	sick_personnel := this.GetString("sick_personnel")
1357
+	title := this.GetString("title")
1358
+	treatment_id := this.GetString("treatment_id")
1359
+	treatment := this.GetString("treatment")
1360
+	ultrasound := this.GetString("ultrasound")
1361
+	xray := this.GetString("xray")
1362
+	patient_id, _ := this.GetInt64("patient_id")
1363
+
1364
+	summary := models.XtHospitalSummary{
1365
+		PatientId:                patient_id,
1366
+		AdmissionTime:            admissiontime,
1367
+		DischargeTime:            dischargetime,
1368
+		SickPersonnel:            sick_personnel,
1369
+		Xray:                     xray,
1370
+		Connecticut:              connecticut,
1371
+		NuclearMagneticResonance: nuclear_magnetic_resonance,
1372
+		Ultrasound:               ultrasound,
1373
+		Pathology:                pathology,
1374
+		AdmittingDiagnosisId:     admitting_diagnosis_id,
1375
+		AdmittingDiagnosis:       admitting_diagnosis,
1376
+		DischargeDiagnosis:       discharge_diagnosis,
1377
+		DiagnosisAdmissionId:     diagnosis_admission_id,
1378
+		DiagnosisAdmission:       diagnosis_admission,
1379
+		TreatmentId:              treatment_id,
1380
+		Treatment:                treatment,
1381
+		IllnessDischargeId:       illness_discharge_id,
1382
+		IllnessDischarge:         illness_discharge,
1383
+		DischargeAdviceId:        discharge_advice_id,
1384
+		DischargeAdvice:          discharge_advice,
1385
+		Mtime:                    time.Now().Unix(),
1386
+		RecordTime:               recordtime,
1387
+		Title:                    title,
1388
+		Doctor:                   doctor,
1389
+		RecordDate:               recordtime,
1390
+		DeanId:                   dean,
1391
+		DischargeDiagnosisId:     discharge_diagnosis_id,
1392
+	}
1393
+	err := service.UpdateHospital(id, summary)
1394
+	if err == nil {
1395
+		this.ServeSuccessJSON(map[string]interface{}{
1396
+			"detail": summary,
1397
+		})
1398
+		return
1399
+	}
1400
+}
1401
+
1402
+func (this *DoctorsApiController) DeleteHospitalSummary() {
1403
+
1404
+	id, _ := this.GetInt64("id")
1405
+	err := service.DeleteHospitalSummary(id)
1406
+	fmt.Println(err)
1407
+	returnData := make(map[string]interface{}, 0)
1408
+	returnData["msg"] = "ok"
1409
+	this.ServeSuccessJSON(returnData)
1410
+	return
1411
+}

+ 19 - 10
controllers/gobal_config_api_controller.go View File

@@ -1632,14 +1632,17 @@ func (c *GobalConfigApiController) GetDrugInDetail() {
1632 1632
 	limit, _ := c.GetInt64("limit")
1633 1633
 
1634 1634
 	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1635
-
1635
+	var drugType = "药品类型"
1636
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1637
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1636 1638
 	if err != nil {
1637 1639
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1638 1640
 		return
1639 1641
 	}
1640 1642
 	c.ServeSuccessJSON(map[string]interface{}{
1641
-		"detail": detail,
1642
-		"total":  total,
1643
+		"detail":         detail,
1644
+		"total":          total,
1645
+		"drugTypeParent": drugTypeList,
1643 1646
 	})
1644 1647
 }
1645 1648
 
@@ -1719,15 +1722,18 @@ func (c *GobalConfigApiController) GetDrugOutDetail() {
1719 1722
 	keyword := c.GetString("keyword")
1720 1723
 	limit, _ := c.GetInt64("limit")
1721 1724
 	page, _ := c.GetInt64("page")
1722
-
1723 1725
 	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1726
+	var drugType = "药品类型"
1727
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1728
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1724 1729
 	if err != nil {
1725 1730
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1726 1731
 		return
1727 1732
 	}
1728 1733
 	c.ServeSuccessJSON(map[string]interface{}{
1729
-		"order": order,
1730
-		"total": total,
1734
+		"order":        order,
1735
+		"total":        total,
1736
+		"drugTypeList": drugTypeList,
1731 1737
 	})
1732 1738
 }
1733 1739
 
@@ -1765,15 +1771,18 @@ func (c *GobalConfigApiController) GetDrugCancelDetail() {
1765 1771
 	page, _ := c.GetInt64("page")
1766 1772
 	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1767 1773
 	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
1768
-
1774
+	var drugType = "药品类型"
1775
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
1776
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, adminInfo.CurrentOrgId)
1769 1777
 	if err != nil {
1770 1778
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1771 1779
 		return
1772 1780
 	}
1773 1781
 	c.ServeSuccessJSON(map[string]interface{}{
1774
-		"order":      order,
1775
-		"total":      total,
1776
-		"orderPrint": orderPrint,
1782
+		"order":        order,
1783
+		"total":        total,
1784
+		"orderPrint":   orderPrint,
1785
+		"drugTypeList": drugTypeList,
1777 1786
 	})
1778 1787
 }
1779 1788
 

+ 499 - 33
controllers/his_api_controller.go View File

@@ -582,24 +582,8 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
582 582
 		}
583 583
 	}
584 584
 
585
-
586 585
 	manufacturers, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
587 586
 
588
-	_, config := service.FindHisStockPriceRecordByOrgId(adminInfo.CurrentOrgId)
589
-	if config.ID > 0 && config.IsOpen == 1 {
590
-		for _, item := range drugs {
591
-			var index = 0
592
-			for _, subItem := range item.OtherDrugWarehouseInfo {
593
-				if index == 0 {
594
-					if subItem.StockMaxNumber*item.MinNumber+subItem.StockMinNumber > 0 {
595
-						index = index + 1
596
-						item.MinPrice = subItem.Price
597
-					}
598
-				}
599
-			}
600
-		}
601
-	}
602
-
603 587
 	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
604 588
 	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
605 589
 	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
@@ -670,7 +654,7 @@ func (c *HisApiController) CreateHisPrescription() {
670 654
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
671 655
 
672 656
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
673
-	fmt.Println("drugStockConfig94394343344334344343434334", drugStockConfig)
657
+
674 658
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
675 659
 
676 660
 	if drugStockConfig.IsOpen == 1 {
@@ -828,7 +812,15 @@ func (c *HisApiController) CreateHisPrescription() {
828 812
 			PType:              p_type,
829 813
 		}
830 814
 		service.SavePatientPrescriptionInfo(hpInfo)
831
-
815
+		redis := service.RedisClient()
816
+		key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
817
+		fmt.Println("key111111111111111111", key)
818
+		redis.Set(key, "", time.Second)
819
+		keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
820
+		redis.Set(keyOne, "", time.Second)
821
+		keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
822
+		redis.Set(keySeven, "", time.Second)
823
+		redis.Close()
832 824
 	} else {
833 825
 		hpInfo = models.HisPrescriptionInfo{
834 826
 
@@ -854,6 +846,15 @@ func (c *HisApiController) CreateHisPrescription() {
854 846
 			HisPatientId:       info.HisPatientId,
855 847
 		}
856 848
 		service.SavePatientPrescriptionInfo(hpInfo)
849
+		redis := service.RedisClient()
850
+		key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
851
+		redis.Set(key, "", time.Second)
852
+		fmt.Println("key22222222222222222", key)
853
+		keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
854
+		redis.Set(keyOne, "", time.Second)
855
+		keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
856
+		redis.Set(keySeven, "", time.Second)
857
+		redis.Close()
857 858
 	}
858 859
 
859 860
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
@@ -938,7 +939,15 @@ func (c *HisApiController) CreateHisPrescription() {
938 939
 					}
939 940
 					tempPrescription = prescription
940 941
 					service.SaveHisPrescription(tempPrescription)
941
-
942
+					redis := service.RedisClient()
943
+					key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
944
+					redis.Set(key, "", time.Second)
945
+					fmt.Println("key3333333333333", key)
946
+					keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
947
+					redis.Set(keyOne, "", time.Second)
948
+					keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
949
+					redis.Set(keySeven, "", time.Second)
950
+					redis.Close()
942 951
 				} else {
943 952
 					tempPrescription.ID = id
944 953
 					tempPrescription.Type = types
@@ -949,6 +958,15 @@ func (c *HisApiController) CreateHisPrescription() {
949 958
 					tempPrescription.PreTime = pTime
950 959
 					tempPrescription.MedType = med_type
951 960
 					service.SaveHisPrescription(tempPrescription)
961
+					redis := service.RedisClient()
962
+					key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
963
+					fmt.Println("key444444444444444", key)
964
+					redis.Set(key, "", time.Second)
965
+					keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
966
+					redis.Set(keyOne, "", time.Second)
967
+					keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
968
+					redis.Set(keySeven, "", time.Second)
969
+					redis.Close()
952 970
 				}
953 971
 				//service.SaveHisPrescription(prescription)
954 972
 				//更改患者挂号状态
@@ -988,10 +1006,15 @@ func (c *HisApiController) CreateHisPrescription() {
988 1006
 
989 1007
 							s.StartTime = pTime
990 1008
 							service.CreateHisDoctorAdvice(&s)
991
-							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
992 1009
 							redis := service.RedisClient()
1010
+							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
993 1011
 							redis.Set(key, "", time.Second)
994
-							defer redis.Close()
1012
+							fmt.Println("key55555555555555", key)
1013
+							keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
1014
+							fmt.Println("keyOne", keyOne)
1015
+							redis.Set(keyOne, "", time.Second)
1016
+							keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
1017
+							redis.Set(keySeven, "", time.Second)
995 1018
 							var randNum int
996 1019
 							randNum = rand.Intn(10000) + 1000
997 1020
 							timestamp := time.Now().Unix()
@@ -999,8 +1022,14 @@ func (c *HisApiController) CreateHisPrescription() {
999 1022
 							timeFormat := tempTime.Format("20060102150405")
1000 1023
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
1001 1024
 							service.CreateHisDoctorAdvice(&s)
1002
-							keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
1003
-							redis.Set(keyOne, "", time.Second)
1025
+							keySix := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
1026
+							redis.Set(keySix, "", time.Second)
1027
+							fmt.Println("key55555555555555", keySix)
1028
+							keyFive := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
1029
+							redis.Set(keyFive, "", time.Second)
1030
+							keyEight := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
1031
+							redis.Set(keyEight, "", time.Second)
1032
+							defer redis.Close()
1004 1033
 						}
1005 1034
 					}
1006 1035
 				}
@@ -1322,6 +1351,16 @@ func (c *HisApiController) EditHisPrescription() {
1322 1351
 								return
1323 1352
 							}
1324 1353
 							service.CreateHisDoctorAdvice(&s)
1354
+							redis := service.RedisClient()
1355
+							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
1356
+							redis.Set(key, "", time.Second)
1357
+							fmt.Println("key55555555555555", key)
1358
+							keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
1359
+							fmt.Println("keyOne", keyOne)
1360
+							redis.Set(keyOne, "", time.Second)
1361
+							keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.CurrentOrgId, 10)
1362
+							redis.Set(keySeven, "", time.Second)
1363
+							redis.Close()
1325 1364
 
1326 1365
 						}
1327 1366
 					}
@@ -1427,6 +1466,10 @@ func (c *HisApiController) DeletePrescription() {
1427 1466
 			if len(advices) > 0 {
1428 1467
 				for _, item := range advices {
1429 1468
 					drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, item.DrugId)
1469
+					redis := service.RedisClient()
1470
+					keyFive := strconv.FormatInt(item.UserOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
1471
+					redis.Set(keyFive, "", time.Second)
1472
+					redis.Close()
1430 1473
 					if item.PrescribingNumberUnit == drug.MinUnit {
1431 1474
 						drug.Total = drug.Total + item.PrescribingNumber
1432 1475
 						service.UpdateBaseDrugLib(&drug)
@@ -1453,21 +1496,229 @@ func (c *HisApiController) DeletePrescription() {
1453 1496
 func (c *HisApiController) DeleteDoctorAdvice() {
1454 1497
 	id, _ := c.GetInt64("id")
1455 1498
 	advice, _ := service.GetHisDoctorAdvicesById(id)
1499
+
1456 1500
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1501
+
1457 1502
 	err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
1503
+	redis := service.RedisClient()
1504
+	keyFive := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1505
+	redis.Set(keyFive, "", time.Second)
1506
+	redis.Close()
1458 1507
 	if err == nil {
1459 1508
 		if drugStockConfig.IsOpen == 1 {
1460
-			drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, advice.DrugId)
1461
-			if advice.PrescribingNumberUnit == drug.MinUnit {
1462
-				drug.Total = drug.Total + advice.PrescribingNumber
1463
-				service.UpdateBaseDrugLib(&drug)
1464
-			} else {
1465
-				if advice.PrescribingNumberUnit == drug.MaxUnit {
1466
-					advice.PrescribingNumber = advice.PrescribingNumber * float64(drug.MinNumber)
1467
-					drug.Total = drug.Total + advice.PrescribingNumber
1468
-					service.UpdateBaseDrugLib(&drug)
1509
+			//判断该医嘱是否执行了
1510
+			if advice.ExecutionState == 1 {
1511
+				//查询该病人该药品是否有库存记录
1512
+				info, errcode := service.GetDrugAutoWarehouseOut(advice.PatientId, advice.AdviceDate, advice.DrugId)
1513
+				if errcode == gorm.ErrRecordNotFound {
1514
+
1515
+				} else {
1516
+					//退库
1517
+					drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, advice.DrugId)
1518
+					if advice.PrescribingNumberUnit == drug.MinUnit {
1519
+
1520
+						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
1521
+						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
1522
+
1523
+						//退库
1524
+						warehouseInfo := models.DrugWarehouseInfo{
1525
+							StockMinNumber: prescribingNumber,
1526
+						}
1527
+
1528
+						service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
1529
+
1530
+						adminUserInfo := c.GetAdminUserInfo()
1531
+						operation_time := time.Now().Unix()
1532
+						creater := adminUserInfo.AdminUser.Id
1533
+
1534
+						ctime := time.Now().Unix()
1535
+						timeStr := time.Now().Format("2006-01-02")
1536
+						timeArr := strings.Split(timeStr, "-")
1537
+						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
1538
+						total = total + 1
1539
+						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1540
+
1541
+						cancelStock := models.DrugCancelStock{
1542
+							OrderNumber:  orderNumber,
1543
+							OperaTime:    operation_time,
1544
+							OrgId:        adminUserInfo.CurrentOrgId,
1545
+							Creater:      creater,
1546
+							Ctime:        ctime,
1547
+							Status:       1,
1548
+							ReturnTime:   advice.AdviceDate,
1549
+							Dealer:       info.Dealer,
1550
+							Manufacturer: info.Manufacturer,
1551
+							Type:         1,
1552
+						}
1553
+						service.AddSigleDrugCancelStock(&cancelStock)
1554
+
1555
+						manufactureName, _ := service.GetManufactureById(info.Manufacturer)
1556
+						dealer, _ := service.GetDealerById(info.Dealer)
1557
+						cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
1558
+						cancelStockInfo := models.DrugCancelStockInfo{
1559
+							OrderNumber:      cancelInfo.OrderNumber,
1560
+							CancelStockId:    cancelInfo.ID,
1561
+							DrugId:           info.DrugId,
1562
+							Count:            info.Count,
1563
+							Status:           1,
1564
+							Ctime:            ctime,
1565
+							OrgId:            adminUserInfo.CurrentOrgId,
1566
+							Type:             1,
1567
+							Manufacturer:     manufactureName.ManufacturerName,
1568
+							Dealer:           dealer.DealerName,
1569
+							Total:            0,
1570
+							RetailPrice:      info.RetailPrice,
1571
+							RetailTotalPrice: info.RetailTotalPrice,
1572
+							Price:            info.Price,
1573
+							RegisterAccount:  "",
1574
+							Remark:           info.Remark,
1575
+							BatchNumber:      info.BatchNumber,
1576
+							MaxUnit:          info.CountUnit,
1577
+							ProductDate:      info.ProductDate,
1578
+							ExpiryDate:       info.ExpiryDate,
1579
+							BatchNumberId:    info.WarehouseInfoId,
1580
+						}
1581
+
1582
+						flow := models.DrugFlow{
1583
+							WarehousingId:           0,
1584
+							DrugId:                  info.DrugId,
1585
+							Number:                  "",
1586
+							BatchNumber:             info.BatchNumber,
1587
+							Count:                   info.Count,
1588
+							UserOrgId:               adminUserInfo.CurrentOrgId,
1589
+							PatientId:               0,
1590
+							SystemTime:              ctime,
1591
+							ConsumableType:          4,
1592
+							IsSys:                   0,
1593
+							WarehousingOrder:        "",
1594
+							WarehouseOutId:          0,
1595
+							WarehouseOutOrderNumber: "",
1596
+							IsEdit:                  0,
1597
+							CancelStockId:           cancelStock.ID,
1598
+							CancelOrderNumber:       cancelStock.OrderNumber,
1599
+							Manufacturer:            info.Manufacturer,
1600
+							Dealer:                  info.Dealer,
1601
+							Creator:                 adminUserInfo.AdminUser.Id,
1602
+							UpdateCreator:           0,
1603
+							Status:                  1,
1604
+							Ctime:                   time.Now().Unix(),
1605
+							Mtime:                   0,
1606
+							Price:                   info.Price,
1607
+							WarehousingDetailId:     0,
1608
+							WarehouseOutDetailId:    0,
1609
+							CancelOutDetailId:       0,
1610
+							ExpireDate:              info.ExpiryDate,
1611
+							ProductDate:             info.ProductDate,
1612
+							MaxUnit:                 info.CountUnit,
1613
+							MinUnit:                 "",
1614
+						}
1615
+						service.CreatedCancelStock(cancelStockInfo)
1616
+						service.CreateDrugFlowOne(flow)
1617
+					} else {
1618
+
1619
+						floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
1620
+
1621
+						prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
1622
+
1623
+						fmt.Println("PrescribingNumber", prescribingNumber)
1624
+						if advice.PrescribingNumberUnit == drug.MaxUnit {
1625
+							warehouseInfo := models.DrugWarehouseInfo{
1626
+								StockMinNumber: prescribingNumber,
1627
+							}
1628
+							service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
1629
+
1630
+						}
1631
+						adminUserInfo := c.GetAdminUserInfo()
1632
+						operation_time := time.Now().Unix()
1633
+						creater := adminUserInfo.AdminUser.Id
1634
+
1635
+						ctime := time.Now().Unix()
1636
+						timeStr := time.Now().Format("2006-01-02")
1637
+						timeArr := strings.Split(timeStr, "-")
1638
+						total, _ := service.FindAllDrugCancelStockTotal(adminUserInfo.CurrentOrgId)
1639
+						total = total + 1
1640
+						orderNumber := "CKTKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
1641
+
1642
+						cancelStock := models.DrugCancelStock{
1643
+							OrderNumber:  orderNumber,
1644
+							OperaTime:    operation_time,
1645
+							OrgId:        adminUserInfo.CurrentOrgId,
1646
+							Creater:      creater,
1647
+							Ctime:        ctime,
1648
+							Status:       1,
1649
+							ReturnTime:   advice.AdviceDate,
1650
+							Dealer:       info.Dealer,
1651
+							Manufacturer: info.Manufacturer,
1652
+							Type:         1,
1653
+						}
1654
+						service.AddSigleDrugCancelStock(&cancelStock)
1655
+
1656
+						manufactureName, _ := service.GetManufactureById(info.Manufacturer)
1657
+						dealer, _ := service.GetDealerById(info.Dealer)
1658
+						cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
1659
+						cancelStockInfo := models.DrugCancelStockInfo{
1660
+							OrderNumber:      cancelInfo.OrderNumber,
1661
+							CancelStockId:    cancelInfo.ID,
1662
+							DrugId:           info.DrugId,
1663
+							Count:            info.Count,
1664
+							Status:           1,
1665
+							Ctime:            ctime,
1666
+							OrgId:            adminUserInfo.CurrentOrgId,
1667
+							Type:             1,
1668
+							Manufacturer:     manufactureName.ManufacturerName,
1669
+							Dealer:           dealer.DealerName,
1670
+							Total:            0,
1671
+							RetailPrice:      info.RetailPrice,
1672
+							RetailTotalPrice: info.RetailTotalPrice,
1673
+							Price:            info.Price,
1674
+							RegisterAccount:  "",
1675
+							Remark:           info.Remark,
1676
+							BatchNumber:      info.BatchNumber,
1677
+							MaxUnit:          info.CountUnit,
1678
+							ProductDate:      info.ProductDate,
1679
+							ExpiryDate:       info.ExpiryDate,
1680
+							BatchNumberId:    info.WarehouseInfoId,
1681
+						}
1682
+
1683
+						flow := models.DrugFlow{
1684
+							WarehousingId:           0,
1685
+							DrugId:                  info.DrugId,
1686
+							Number:                  "",
1687
+							BatchNumber:             info.BatchNumber,
1688
+							Count:                   info.Count,
1689
+							UserOrgId:               adminUserInfo.CurrentOrgId,
1690
+							PatientId:               0,
1691
+							SystemTime:              ctime,
1692
+							ConsumableType:          4,
1693
+							IsSys:                   0,
1694
+							WarehousingOrder:        "",
1695
+							WarehouseOutId:          0,
1696
+							WarehouseOutOrderNumber: "",
1697
+							IsEdit:                  0,
1698
+							CancelStockId:           cancelStock.ID,
1699
+							CancelOrderNumber:       cancelStock.OrderNumber,
1700
+							Manufacturer:            info.Manufacturer,
1701
+							Dealer:                  info.Dealer,
1702
+							Creator:                 adminUserInfo.AdminUser.Id,
1703
+							UpdateCreator:           0,
1704
+							Status:                  1,
1705
+							Ctime:                   time.Now().Unix(),
1706
+							Mtime:                   0,
1707
+							Price:                   info.Price,
1708
+							WarehousingDetailId:     0,
1709
+							WarehouseOutDetailId:    0,
1710
+							CancelOutDetailId:       0,
1711
+							ExpireDate:              info.ExpiryDate,
1712
+							ProductDate:             info.ProductDate,
1713
+							MaxUnit:                 info.CountUnit,
1714
+							MinUnit:                 "",
1715
+						}
1716
+						service.CreatedCancelStock(cancelStockInfo)
1717
+						service.CreateDrugFlowOne(flow)
1718
+					}
1469 1719
 				}
1470 1720
 			}
1721
+
1471 1722
 		}
1472 1723
 
1473 1724
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -1500,7 +1751,6 @@ func (c *HisApiController) DeleteProject() {
1500 1751
 		if stockConfig.IsOpen == 1 {
1501 1752
 			if project.Type == 3 {
1502 1753
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
1503
-
1504 1754
 				f_count, _ := strconv.ParseFloat(project.Count, 64)
1505 1755
 				good.Total = good.Total + f_count
1506 1756
 				service.UpdateGoodInfo(&good)
@@ -5568,3 +5818,219 @@ func RemoveRepeatedTeam(arr []*models.HisOrderInfoTwo) (newArr []*models.HisOrde
5568 5818
 	}
5569 5819
 	return
5570 5820
 }
5821
+
5822
+//修改处方退库操作 参数传修改之前的处方数据
5823
+func DeleteDrugWarehosueInfo(advice models.HisDoctorAdviceInfo) (err error) {
5824
+
5825
+	if advice.ExecutionState == 1 {
5826
+		//查询该病人该药品是否有库存记录
5827
+		info, errcode := service.GetDrugAutoWarehouseOut(advice.PatientId, advice.AdviceDate, advice.DrugId)
5828
+		if errcode == gorm.ErrRecordNotFound {
5829
+
5830
+		} else {
5831
+			//退库
5832
+			drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
5833
+			if advice.PrescribingNumberUnit == drug.MinUnit {
5834
+
5835
+				floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
5836
+				prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
5837
+
5838
+				//退库
5839
+				warehouseInfo := models.DrugWarehouseInfo{
5840
+					StockMinNumber: prescribingNumber,
5841
+				}
5842
+
5843
+				service.UpdateDrugWarehouse(info.WarehouseInfoId, warehouseInfo)
5844
+
5845
+				operation_time := time.Now().Unix()
5846
+				creater := advice.AdviceDoctor
5847
+
5848
+				ctime := time.Now().Unix()
5849
+				timeStr := time.Now().Format("2006-01-02")
5850
+				timeArr := strings.Split(timeStr, "-")
5851
+				total, _ := service.FindAllDrugCancelStockTotal(advice.UserOrgId)
5852
+				total = total + 1
5853
+				orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
5854
+
5855
+				cancelStock := models.DrugCancelStock{
5856
+					OrderNumber:  orderNumber,
5857
+					OperaTime:    operation_time,
5858
+					OrgId:        advice.UserOrgId,
5859
+					Creater:      creater,
5860
+					Ctime:        ctime,
5861
+					Status:       1,
5862
+					ReturnTime:   advice.AdviceDate,
5863
+					Dealer:       info.Dealer,
5864
+					Manufacturer: info.Manufacturer,
5865
+					Type:         1,
5866
+				}
5867
+				service.AddSigleDrugCancelStock(&cancelStock)
5868
+
5869
+				manufactureName, _ := service.GetManufactureById(info.Manufacturer)
5870
+				dealer, _ := service.GetDealerById(info.Dealer)
5871
+				cancelInfo, _ := service.GetLastDrugCancelStockById(advice.UserOrgId)
5872
+				cancelStockInfo := models.DrugCancelStockInfo{
5873
+					OrderNumber:      cancelInfo.OrderNumber,
5874
+					CancelStockId:    cancelInfo.ID,
5875
+					DrugId:           info.DrugId,
5876
+					Count:            info.Count,
5877
+					Status:           1,
5878
+					Ctime:            ctime,
5879
+					OrgId:            advice.UserOrgId,
5880
+					Type:             1,
5881
+					Manufacturer:     manufactureName.ManufacturerName,
5882
+					Dealer:           dealer.DealerName,
5883
+					Total:            0,
5884
+					RetailPrice:      info.RetailPrice,
5885
+					RetailTotalPrice: info.RetailTotalPrice,
5886
+					Price:            info.Price,
5887
+					RegisterAccount:  "",
5888
+					Remark:           info.Remark,
5889
+					BatchNumber:      info.BatchNumber,
5890
+					MaxUnit:          info.CountUnit,
5891
+					ProductDate:      info.ProductDate,
5892
+					ExpiryDate:       info.ExpiryDate,
5893
+					BatchNumberId:    info.WarehouseInfoId,
5894
+				}
5895
+
5896
+				flow := models.DrugFlow{
5897
+					WarehousingId:           0,
5898
+					DrugId:                  info.DrugId,
5899
+					Number:                  "",
5900
+					BatchNumber:             info.BatchNumber,
5901
+					Count:                   info.Count,
5902
+					UserOrgId:               advice.UserOrgId,
5903
+					PatientId:               0,
5904
+					SystemTime:              ctime,
5905
+					ConsumableType:          4,
5906
+					IsSys:                   0,
5907
+					WarehousingOrder:        "",
5908
+					WarehouseOutId:          0,
5909
+					WarehouseOutOrderNumber: "",
5910
+					IsEdit:                  0,
5911
+					CancelStockId:           cancelStock.ID,
5912
+					CancelOrderNumber:       cancelStock.OrderNumber,
5913
+					Manufacturer:            info.Manufacturer,
5914
+					Dealer:                  info.Dealer,
5915
+					Creator:                 advice.UserOrgId,
5916
+					UpdateCreator:           0,
5917
+					Status:                  1,
5918
+					Ctime:                   time.Now().Unix(),
5919
+					Mtime:                   0,
5920
+					Price:                   info.Price,
5921
+					WarehousingDetailId:     0,
5922
+					WarehouseOutDetailId:    0,
5923
+					CancelOutDetailId:       0,
5924
+					ExpireDate:              info.ExpiryDate,
5925
+					ProductDate:             info.ProductDate,
5926
+					MaxUnit:                 info.CountUnit,
5927
+					MinUnit:                 "",
5928
+				}
5929
+				service.CreatedCancelStock(cancelStockInfo)
5930
+				service.CreateDrugFlowOne(flow)
5931
+			} else {
5932
+
5933
+				floatPrescrip := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 32)
5934
+
5935
+				prescribingNumber, _ := strconv.ParseInt(floatPrescrip, 10, 64)
5936
+
5937
+				fmt.Println("PrescribingNumber", prescribingNumber)
5938
+				if advice.PrescribingNumberUnit == drug.MaxUnit {
5939
+					warehouseInfo := models.DrugWarehouseInfo{
5940
+						StockMinNumber: prescribingNumber,
5941
+					}
5942
+					service.UpdateDrugWarehouseOne(info.WarehouseInfoId, warehouseInfo)
5943
+
5944
+				}
5945
+
5946
+				operation_time := time.Now().Unix()
5947
+				creater := advice.AdviceDoctor
5948
+
5949
+				ctime := time.Now().Unix()
5950
+				timeStr := time.Now().Format("2006-01-02")
5951
+				timeArr := strings.Split(timeStr, "-")
5952
+				total, _ := service.FindAllDrugCancelStockTotal(advice.UserOrgId)
5953
+				total = total + 1
5954
+				orderNumber := "CKTKD" + strconv.FormatInt(advice.UserOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
5955
+
5956
+				cancelStock := models.DrugCancelStock{
5957
+					OrderNumber:  orderNumber,
5958
+					OperaTime:    operation_time,
5959
+					OrgId:        advice.UserOrgId,
5960
+					Creater:      creater,
5961
+					Ctime:        ctime,
5962
+					Status:       1,
5963
+					ReturnTime:   advice.AdviceDate,
5964
+					Dealer:       info.Dealer,
5965
+					Manufacturer: info.Manufacturer,
5966
+					Type:         1,
5967
+				}
5968
+				service.AddSigleDrugCancelStock(&cancelStock)
5969
+
5970
+				manufactureName, _ := service.GetManufactureById(info.Manufacturer)
5971
+				dealer, _ := service.GetDealerById(info.Dealer)
5972
+				cancelInfo, _ := service.GetLastDrugCancelStockById(advice.UserOrgId)
5973
+				cancelStockInfo := models.DrugCancelStockInfo{
5974
+					OrderNumber:      cancelInfo.OrderNumber,
5975
+					CancelStockId:    cancelInfo.ID,
5976
+					DrugId:           info.DrugId,
5977
+					Count:            info.Count,
5978
+					Status:           1,
5979
+					Ctime:            ctime,
5980
+					OrgId:            advice.UserOrgId,
5981
+					Type:             1,
5982
+					Manufacturer:     manufactureName.ManufacturerName,
5983
+					Dealer:           dealer.DealerName,
5984
+					Total:            0,
5985
+					RetailPrice:      info.RetailPrice,
5986
+					RetailTotalPrice: info.RetailTotalPrice,
5987
+					Price:            info.Price,
5988
+					RegisterAccount:  "",
5989
+					Remark:           info.Remark,
5990
+					BatchNumber:      info.BatchNumber,
5991
+					MaxUnit:          info.CountUnit,
5992
+					ProductDate:      info.ProductDate,
5993
+					ExpiryDate:       info.ExpiryDate,
5994
+					BatchNumberId:    info.WarehouseInfoId,
5995
+				}
5996
+
5997
+				flow := models.DrugFlow{
5998
+					WarehousingId:           0,
5999
+					DrugId:                  info.DrugId,
6000
+					Number:                  "",
6001
+					BatchNumber:             info.BatchNumber,
6002
+					Count:                   info.Count,
6003
+					UserOrgId:               advice.UserOrgId,
6004
+					PatientId:               0,
6005
+					SystemTime:              ctime,
6006
+					ConsumableType:          4,
6007
+					IsSys:                   0,
6008
+					WarehousingOrder:        "",
6009
+					WarehouseOutId:          0,
6010
+					WarehouseOutOrderNumber: "",
6011
+					IsEdit:                  0,
6012
+					CancelStockId:           cancelStock.ID,
6013
+					CancelOrderNumber:       cancelStock.OrderNumber,
6014
+					Manufacturer:            info.Manufacturer,
6015
+					Dealer:                  info.Dealer,
6016
+					Creator:                 advice.AdviceDoctor,
6017
+					UpdateCreator:           0,
6018
+					Status:                  1,
6019
+					Ctime:                   time.Now().Unix(),
6020
+					Mtime:                   0,
6021
+					Price:                   info.Price,
6022
+					WarehousingDetailId:     0,
6023
+					WarehouseOutDetailId:    0,
6024
+					CancelOutDetailId:       0,
6025
+					ExpireDate:              info.ExpiryDate,
6026
+					ProductDate:             info.ProductDate,
6027
+					MaxUnit:                 info.CountUnit,
6028
+					MinUnit:                 "",
6029
+				}
6030
+				service.CreatedCancelStock(cancelStockInfo)
6031
+				service.CreateDrugFlowOne(flow)
6032
+			}
6033
+		}
6034
+	}
6035
+	return err
6036
+}

+ 106 - 115
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -64,110 +64,8 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
64 64
 	theAssessmentDateTime := theStartTime.Unix()
65 65
 
66 66
 	if dialysistype == 1 {
67
-		// 保存透前相关数据
68
-		// 获取透析处方
69
-		//dialysisPrescribe, getDialysisPrescribeErr := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
70
-		//if getDialysisPrescribeErr != nil {
71
-		//	c.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
72
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
73
-		//	return
74
-		//}
75
-		//
76
-		//// 获取透析模版
77
-		//dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
78
-		//if getDialysisSolutionErr != nil {
79
-		//	c.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
80
-		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
81
-		//	return
82
-		//}
83
-
84
-		// 插入透析处方
85
-		//if dialysisPrescribe == nil && dialysisSolution != nil {
86
-		//	var newprescribe models.DialysisPrescription
87
-		//	newprescribe.UserOrgId = dialysisSolution.UserOrgId
88
-		//	newprescribe.PatientId = dialysisSolution.PatientId
89
-		//	newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
90
-		//	newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
91
-		//	newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
92
-		//	newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
93
-		//	newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
94
-		//	newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
95
-		//	newprescribe.ModeId = dialysisSolution.ModeId
96
-		//	newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
97
-		//	newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
98
-		//	newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
99
-		//	newprescribe.BloodFilter = dialysisSolution.BloodFilter
100
-		//	newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
101
-		//	newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
102
-		//	newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
103
-		//	newprescribe.Glucose = dialysisSolution.Glucose
104
-		//	newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
105
-		//	newprescribe.Kalium = dialysisSolution.Kalium
106
-		//	newprescribe.Sodium = dialysisSolution.Sodium
107
-		//	newprescribe.Calcium = dialysisSolution.Calcium
108
-		//	newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
109
-		//	newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
110
-		//	newprescribe.Conductivity = dialysisSolution.Conductivity
111
-		//	newprescribe.BodyFluid = dialysisSolution.BodyFluid
112
-		//	newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
113
-		//	newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
114
-		//	newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
115
-		//	newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
116
-		//	newprescribe.BloodAccess = dialysisSolution.BloodAccess
117
-		//	newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
118
-		//	newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
119
-		//	newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
120
-		//	newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
121
-		//	newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
122
-		//	newprescribe.Dialyzer = dialysisSolution.Dialyzer
123
-		//	newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
124
-		//	newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
125
-		//	newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
126
-		//	newprescribe.TargetKtv = dialysisSolution.TargetKtv
127
-		//
128
-		//	newprescribe.CreatedTime = time.Now().Unix()
129
-		//	newprescribe.UpdatedTime = time.Now().Unix()
130
-		//	newprescribe.RecordDate = theAssessmentDateTime
131
-		//	// newprescribe.DewaterAmount = dewater_amount
132
-		//	// newprescribe.TargetUltrafiltration = dewater_amount
133
-		//	newprescribe.Status = 1
134
-		//
135
-		//	err := service.AddSigleRecord(&newprescribe)
136
-		//	if err != nil {
137
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
138
-		//	}
139
-		//}
140
-
141
-		//if dialysisPrescribe == nil && dialysisSolution == nil {
142
-		//	var newprescribe models.DialysisPrescription
143
-		//	newprescribe.UserOrgId = adminUserInfo.Org.Id
144
-		//	newprescribe.PatientId = id
145
-		//	newprescribe.CreatedTime = time.Now().Unix()
146
-		//	newprescribe.UpdatedTime = time.Now().Unix()
147
-		//	newprescribe.RecordDate = theAssessmentDateTime
148
-		//	// newprescribe.DewaterAmount = dewater_amount
149
-		//	// newprescribe.TargetUltrafiltration = dewater_amount
150
-		//	newprescribe.Status = 1
151
-		//
152
-		//	err := service.AddSigleRecord(&newprescribe)
153
-		//	if err != nil {
154
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
155
-		//	}
156
-		//}
157
-
158
-		//if dialysisPrescribe != nil {
159
-		//	dialysisPrescribe.UpdatedTime = time.Now().Unix()
160
-		//	dialysisPrescribe.RecordDate = theAssessmentDateTime
161
-		//	// dialysisPrescribe.DewaterAmount = dewater_amount
162
-		//	// dialysisPrescribe.TargetUltrafiltration = dewater_amount
163
-		//	dialysisPrescribe.Status = 1
164
-		//	updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
165
-		//	if updateErr != nil {
166
-		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
167
-		//	}
168
-		//}
169 67
 
170
-		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
68
+		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
171 69
 		if getPEErr != nil {
172 70
 			c.ErrorLog("获取透前评估失败:%v", getPEErr)
173 71
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -187,9 +85,10 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
187 85
 			evaluation.PatientId = id
188 86
 			evaluation.UserOrgId = adminUserInfo.Org.Id
189 87
 			// 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
190
-			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
88
+			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
191 89
 			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
192
-			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
90
+			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
91
+
193 92
 			if getAADErr != nil {
194 93
 				c.ErrorLog("获取透后评估失败:%v", getAADErr)
195 94
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -228,6 +127,18 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
228 127
 		evaluation.AssessmentTime = time.Now().Unix()
229 128
 
230 129
 		err := service.UpadatePredialysisEvaluation(&evaluation)
130
+
131
+		assessdateDateStart := thisTime.Format("2006-01-02")
132
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
133
+		redis := service.RedisClient()
134
+		defer redis.Close()
135
+		//清空key 值
136
+		redis.Set(key, "", time.Second)
137
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
138
+		redis.Set(keyOne, "", time.Second)
139
+		keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
140
+		redis.Set(keyTwo, "", time.Second)
141
+		redis.Close()
231 142
 		if err != nil {
232 143
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
233 144
 			return
@@ -242,7 +153,7 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
242 153
 	} else {
243 154
 
244 155
 		// 保存透后相关数据
245
-		assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
156
+		assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
246 157
 
247 158
 		if getAADErr != nil {
248 159
 			c.ErrorLog("获取透后评估失败:%v", getAADErr)
@@ -277,6 +188,16 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
277 188
 		}
278 189
 
279 190
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
191
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
192
+		redis := service.RedisClient()
193
+		//清空key 值
194
+		redis.Set(key, "", time.Second)
195
+		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis_list_all"
196
+		redis.Set(keyThree, "", time.Second)
197
+		assessdateDateStart := thisTime.Format("2006-01-02")
198
+		keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
199
+		redis.Set(keyTwo, "", time.Second)
200
+		defer redis.Close()
280 201
 		if err == nil {
281 202
 			c.ServeSuccessJSON(map[string]interface{}{
282 203
 				"assessmentAfterDislysis": afterevaluation,
@@ -365,13 +286,12 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
365 286
 		//if weightfirst.DryWeight > weighing_before {
366 287
 		//	return
367 288
 		//}
368
-
369 289
 		dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
370 290
 		if schedual != nil {
371 291
 			// 获取透析模版
372
-			dialysisSolution, _ = service.MobileGetDialysisSolutionByModeId(adminUserInfo.Org.Id, id, schedual.ModeId)
373
-			system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeId(adminUserInfo.Org.Id, schedual.ModeId)
374
-			lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.Org.Id, id, schedual.ModeId)
292
+			dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
293
+			system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, schedual.ModeId)
294
+			lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
375 295
 			mode_id = schedual.ModeId
376 296
 		} else {
377 297
 			// 获取透析模版
@@ -438,8 +358,18 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
438 358
 			newprescribe.DewaterAmount = dewater_amount
439 359
 			newprescribe.TargetUltrafiltration = dewater_amount
440 360
 			newprescribe.Status = 1
441
-
361
+			//插入透析处方
442 362
 			err := service.AddSigleRecord(&newprescribe)
363
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
364
+			redis := service.RedisClient()
365
+			//清空key 值
366
+			redis.Set(key, "", time.Second)
367
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
368
+			redis.Set(keyTwo, "", time.Second)
369
+			scheduleDateStartOne := thisTime.Format("2006-01-02")
370
+			keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
371
+			redis.Set(keyThree, "", time.Second)
372
+			defer redis.Close()
443 373
 			if err != nil {
444 374
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
445 375
 			}
@@ -497,6 +427,16 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
497 427
 				newprescribe.Status = 1
498 428
 
499 429
 				err := service.AddSigleRecord(&newprescribe)
430
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
431
+				redis := service.RedisClient()
432
+				//清空key 值
433
+				redis.Set(key, "", time.Second)
434
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
435
+				redis.Set(keyTwo, "", time.Second)
436
+				scheduleDateStartOne := thisTime.Format("2006-01-02")
437
+				keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
438
+				redis.Set(keyThree, "", time.Second)
439
+				defer redis.Close()
500 440
 				if err != nil {
501 441
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
502 442
 				}
@@ -554,6 +494,16 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
554 494
 				fmt.Println(newprescribe.TargetUltrafiltration)
555 495
 
556 496
 				err := service.AddSigleRecord(&newprescribe)
497
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
498
+				redis := service.RedisClient()
499
+				//清空key 值
500
+				redis.Set(key, "", time.Second)
501
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
502
+				redis.Set(keyTwo, "", time.Second)
503
+				scheduleDateStartOne := thisTime.Format("2006-01-02")
504
+				keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
505
+				redis.Set(keyThree, "", time.Second)
506
+				defer redis.Close()
557 507
 				if err != nil {
558 508
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
559 509
 				}
@@ -571,6 +521,16 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
571 521
 				newprescribe.Status = 1
572 522
 
573 523
 				err := service.AddSigleRecord(&newprescribe)
524
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
525
+				redis := service.RedisClient()
526
+				//清空key 值
527
+				redis.Set(key, "", time.Second)
528
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
529
+				redis.Set(keyTwo, "", time.Second)
530
+				scheduleDateStartOne := thisTime.Format("2006-01-02")
531
+				keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
532
+				redis.Set(keyThree, "", time.Second)
533
+				defer redis.Close()
574 534
 				if err != nil {
575 535
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
576 536
 				}
@@ -583,13 +543,24 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
583 543
 			dialysisPrescribe.DewaterAmount = dewater_amount
584 544
 			dialysisPrescribe.TargetUltrafiltration = dewater_amount
585 545
 			dialysisPrescribe.Status = 1
546
+
586 547
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
548
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
549
+			redis := service.RedisClient()
550
+			//清空key 值
551
+			redis.Set(key, "", time.Second)
552
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
553
+			redis.Set(keyTwo, "", time.Second)
554
+			scheduleDateStartOne := thisTime.Format("2006-01-02")
555
+			keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
556
+			redis.Set(keyThree, "", time.Second)
557
+			defer redis.Close()
587 558
 			if updateErr != nil {
588 559
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
589 560
 			}
590 561
 		}
591 562
 
592
-		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
563
+		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
593 564
 		if getPEErr != nil {
594 565
 			c.ErrorLog("获取透前评估失败:%v", getPEErr)
595 566
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -609,9 +580,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
609 580
 			evaluation.PatientId = id
610 581
 			evaluation.UserOrgId = adminUserInfo.Org.Id
611 582
 			// 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
612
-			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
583
+			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
613 584
 			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
614
-			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
585
+			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
615 586
 			if getAADErr != nil {
616 587
 				c.ErrorLog("获取透后评估失败:%v", getAADErr)
617 588
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -667,6 +638,16 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
667 638
 		evaluation.AssessmentTime = time.Now().Unix()
668 639
 
669 640
 		err := service.UpadatePredialysisEvaluation(&evaluation)
641
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
642
+		redis := service.RedisClient()
643
+		//清空key 值
644
+		redis.Set(key, "", time.Second)
645
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
646
+		redis.Set(keyOne, "", time.Second)
647
+		assessdateDateStart := thisTime.Format("2006-01-02")
648
+		keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
649
+		redis.Set(keyTwo, "", time.Second)
650
+		redis.Close()
670 651
 		if err != nil {
671 652
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
672 653
 			return
@@ -681,7 +662,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
681 662
 	} else {
682 663
 
683 664
 		// 保存透后相关数据
684
-		assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
665
+		assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
685 666
 		if getAADErr != nil {
686 667
 			c.ErrorLog("获取透后评估失败:%v", getAADErr)
687 668
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -720,6 +701,16 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
720 701
 		// }
721 702
 
722 703
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
704
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
705
+		redis := service.RedisClient()
706
+		//清空key 值
707
+		redis.Set(key, "", time.Second)
708
+		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis_list_all"
709
+		redis.Set(keyThree, "", time.Second)
710
+		assessdateDateStart := thisTime.Format("2006-01-02")
711
+		keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
712
+		redis.Set(keyTwo, "", time.Second)
713
+		redis.Close()
723 714
 		if err == nil {
724 715
 			c.ServeSuccessJSON(map[string]interface{}{
725 716
 				"assessmentAfterDislysis": afterevaluation,

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

@@ -326,7 +326,7 @@ func (this *DialysisAPIController) DialysisRecord() {
326 326
 	adminInfo := this.GetMobileAdminUserInfo()
327 327
 
328 328
 	ch := make(chan struct{})
329
-	count := 25 // count 表示活动的协程个数
329
+	count := 24 // count 表示活动的协程个数
330 330
 	var patient models.Patients
331 331
 	var receiverTreatmentAccess *models.ReceiveTreatmentAsses
332 332
 	var predialysisEvaluation *models.PredialysisEvaluation
@@ -348,7 +348,7 @@ func (this *DialysisAPIController) DialysisRecord() {
348 348
 	var stockType []*models.GoodsTypeOne
349 349
 	var prepare []*models.XtDialysisBeforePrepare
350 350
 	var lastAssessment models.XtPatientVascularAccess
351
-	var prescribeOne *models.DialysisPrescription
351
+
352 352
 	var lastDryWeightDislysis *models.SgjPatientDryweight
353 353
 	var gobalConfig models.GobalConfig
354 354
 	var operators []*models.SgjUserAdminRoles
@@ -469,12 +469,6 @@ func (this *DialysisAPIController) DialysisRecord() {
469 469
 		ch <- struct{}{}
470 470
 	}()
471 471
 
472
-	go func() {
473
-		// 先走redis,没有走数据库
474
-		prescribeOne, _ = service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
475
-		ch <- struct{}{}
476
-	}()
477
-
478 472
 	go func() {
479 473
 		// 先走redis,没有走数据库
480 474
 		lastDryWeightDislysis, _ = service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
@@ -501,11 +495,14 @@ func (this *DialysisAPIController) DialysisRecord() {
501 495
 			close(ch)
502 496
 		}
503 497
 	}
498
+
499
+	prescribeOne, _ := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
500
+
504 501
 	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
505 502
 
506
-	_, is_project_open_config := service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
503
+	_, is_project_open_config = service.FindXTHisProjectByOrgId(adminInfo.Org.Id)
507 504
 
508
-	projects, _ := service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
505
+	projects, _ = service.GetHisPrescriptionProjects(adminInfo.Org.Id, patientID, date.Unix())
509 506
 	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
510 507
 
511 508
 	var team_projects []*models.HisPrescriptionProject
@@ -524,14 +521,11 @@ func (this *DialysisAPIController) DialysisRecord() {
524 521
 		}
525 522
 	}
526 523
 
527
-	stockType, _ := service.GetStockType(adminInfo.Org.Id)
528
-
529
-	prepare, _ := service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
524
+	stockType, _ = service.GetStockType(adminInfo.Org.Id)
530 525
 
531
-	//获取最后一次血管通路
532
-	lastAssessment, parseDateErr := service.GetLastPassWayAssessment(adminInfo.Org.Id, patientID)
526
+	prepare, _ = service.GetDialyStockOut(adminInfo.Org.Id, date.Unix(), patientID)
533 527
 
534
-	prescribeOne, parseDateErr := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
528
+	prescribeOne, _ = service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
535 529
 	var his_advices []*models.HisDoctorAdviceInfo
536 530
 	if is_open_config.IsOpen == 1 {
537 531
 		// 先走redis,没有走数据库
@@ -658,7 +652,7 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
658 652
 		redis := service.RedisClient()
659 653
 		//清空key 值
660 654
 		redis.Set(key, "", time.Second)
661
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
655
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
662 656
 		redis.Set(keyOne, "", time.Second)
663 657
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
664 658
 		redis.Set(keyThree, "", time.Second)
@@ -688,7 +682,7 @@ func (c *DialysisAPIController) PostAtreatmentInfo() {
688 682
 		redis := service.RedisClient()
689 683
 		//清空key 值
690 684
 		redis.Set(key, "", time.Second)
691
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
685
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
692 686
 		redis.Set(keyOne, "", time.Second)
693 687
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
694 688
 		redis.Set(keyThree, "", time.Second)
@@ -1141,12 +1135,15 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1141 1135
 		}
1142 1136
 
1143 1137
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1144
-		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1145 1138
 		redis := service.RedisClient()
1139
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1140
+		redis.Set(keyTwo, "", time.Second)
1141
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1142
+
1146 1143
 		//清空key 值
1147 1144
 		redis.Set(key, "", time.Second)
1148 1145
 
1149
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
1146
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1150 1147
 		redis.Set(keyOne, "", time.Second)
1151 1148
 		defer redis.Close()
1152 1149
 		if err == nil {
@@ -1168,17 +1165,20 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1168 1165
 
1169 1166
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1170 1167
 		assessmentAfterDislysis.ID = assessmentAfter.ID
1171
-		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1168
+
1169
+		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1172 1170
 		redis := service.RedisClient()
1171
+		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1172
+
1173
+		redis.Set(keyTwo, "", time.Second)
1174
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1175
+
1173 1176
 		//清空key 值
1174 1177
 		redis.Set(key, "", time.Second)
1175 1178
 
1176
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
1179
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1177 1180
 		redis.Set(keyOne, "", time.Second)
1178
-		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1179
-
1180 1181
 		if err == nil {
1181
-			fmt.Println("hhhhhhhhhhh0000000000", err)
1182 1182
 			c.ServeSuccessJSON(map[string]interface{}{
1183 1183
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1184 1184
 			})
@@ -1475,9 +1475,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1475 1475
 
1476 1476
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1477 1477
 	if dialysisPrescription.ID == 0 { //新增
1478
-		//if mode_id > 0 {
1479
-		//	//service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1480
-		//}
1478
+
1481 1479
 		if appRole.UserType == 2 || appRole.UserType == 1 {
1482 1480
 			prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
1483 1481
 		}
@@ -1488,7 +1486,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1488 1486
 		//获取key,清空redis
1489 1487
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1490 1488
 		redis := service.RedisClient()
1491
-		defer redis.Close()
1489
+
1492 1490
 		//清空key 值
1493 1491
 		redis.Set(key, "", time.Second)
1494 1492
 
@@ -1500,7 +1498,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1500 1498
 		//清空key 值
1501 1499
 		redis.Set(keyTwo, "", time.Second)
1502 1500
 
1503
-		keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
1501
+		keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
1504 1502
 		redis.Set(keySix, "", time.Second)
1505 1503
 
1506 1504
 		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
@@ -1509,6 +1507,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1509 1507
 		if err == nil {
1510 1508
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1511 1509
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_by_mode"
1510
+
1512 1511
 			//清空key 值
1513 1512
 			redis.Set(keyThree, "", time.Second)
1514 1513
 
@@ -1518,6 +1517,9 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1518 1517
 			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
1519 1518
 			redis.Set(keyFive, "", time.Second)
1520 1519
 
1520
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
1521
+			redis.Set(keySix, "", time.Second)
1522
+
1521 1523
 			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1522 1524
 			redis.Set(keySeven, "", time.Second)
1523 1525
 
@@ -1527,7 +1529,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1527 1529
 			if updateErr != nil {
1528 1530
 				utils.ErrorLog("%v", updateErr)
1529 1531
 			}
1530
-
1532
+			defer redis.Close()
1531 1533
 			c.ServeSuccessJSON(map[string]interface{}{
1532 1534
 				"prescription": prescription,
1533 1535
 			})
@@ -1572,7 +1574,7 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1572 1574
 		//获取key,清空redis
1573 1575
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
1574 1576
 		redis := service.RedisClient()
1575
-		defer redis.Close()
1577
+
1576 1578
 		//清空key 值
1577 1579
 		redis.Set(key, "", time.Second)
1578 1580
 
@@ -1580,16 +1582,19 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1580 1582
 		//清空key 值
1581 1583
 		redis.Set(keyOne, "", time.Second)
1582 1584
 
1583
-		keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
1585
+		keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
1584 1586
 		redis.Set(keySix, "", time.Second)
1585 1587
 
1586 1588
 		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1587 1589
 		redis.Set(keySeven, "", time.Second)
1590
+
1588 1591
 		if err == nil {
1589 1592
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1590 1593
 			keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1594
+
1591 1595
 			//清空key 值
1592 1596
 			redis.Set(keyOne, "", time.Second)
1597
+			defer redis.Close()
1593 1598
 			if updateErr != nil {
1594 1599
 				utils.ErrorLog("%v", updateErr)
1595 1600
 			}
@@ -1662,7 +1667,7 @@ func (c *DialysisAPIController) Finish() {
1662 1667
 	}
1663 1668
 
1664 1669
 	// 获取当前的最后一条透析纪录
1665
-	endmonitorRecords, getMonitorRecordsErr := service.MobileGetLastMonitorRecord(adminUserInfo.Org.Id, id, recordDate.Unix())
1670
+	endmonitorRecords, getMonitorRecordsErr := service.MobileGetLastMonitorRecordOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1666 1671
 	if getMonitorRecordsErr != nil {
1667 1672
 		c.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
1668 1673
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -1693,7 +1698,7 @@ func (c *DialysisAPIController) Finish() {
1693 1698
 		tempassessmentAfterDislysis.PatientId = id
1694 1699
 		tempassessmentAfterDislysis.UserOrgId = adminUserInfo.Org.Id
1695 1700
 	}
1696
-	fmt.Println("上机状态233323232232332322332233232323223", dialysisOrder.Stage)
1701
+
1697 1702
 	if dialysisOrder.Stage == 1 {
1698 1703
 		temp_time := (float64(endDate.Unix()) - float64(dialysisOrder.StartTime)) / 3600
1699 1704
 		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
@@ -1702,8 +1707,7 @@ func (c *DialysisAPIController) Finish() {
1702 1707
 		c, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
1703 1708
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1704 1709
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", c*60), 10, 64)
1705
-		fmt.Println("323332322332323223232323232323232323", hour)
1706
-		fmt.Println(minute)
1710
+
1707 1711
 		tempassessmentAfterDislysis.ActualTreatmentHour = hour
1708 1712
 		tempassessmentAfterDislysis.ActualTreatmentMinute = minute
1709 1713
 	}
@@ -1727,9 +1731,9 @@ func (c *DialysisAPIController) Finish() {
1727 1731
 		tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
1728 1732
 
1729 1733
 	}
1730
-	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 {
1731
-	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 {
1732
-		evaluation, _ := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, recordDate.Unix())
1734
+
1735
+	if adminUserInfo.Org.Id == 10101 || adminUserInfo.Org.Id == 9671 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 4 || adminUserInfo.Org.Id == 10215 || adminUserInfo.Org.Id == 10233 || adminUserInfo.Org.Id == 10223 || adminUserInfo.Org.Id == 10243 {
1736
+		evaluation, _ := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, recordDate.Unix())
1733 1737
 		if evaluation.SystolicBloodPressure == 0 {
1734 1738
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1735 1739
 			pre := models.PredialysisEvaluation{
@@ -1738,9 +1742,11 @@ func (c *DialysisAPIController) Finish() {
1738 1742
 			fmt.Println("prew", pre)
1739 1743
 			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1740 1744
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
1745
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1741 1746
 
1742 1747
 			redis := service.RedisClient()
1743 1748
 			redis.Set(key, "", time.Second)
1749
+			redis.Set(keyOne, "", time.Second)
1744 1750
 			defer redis.Close()
1745 1751
 			fmt.Println(getNurseErr)
1746 1752
 		}
@@ -1755,7 +1761,7 @@ func (c *DialysisAPIController) Finish() {
1755 1761
 			redis := service.RedisClient()
1756 1762
 			redis.Set(key, "", time.Second)
1757 1763
 
1758
-			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
1764
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1759 1765
 			redis.Set(keyOne, "", time.Second)
1760 1766
 			defer redis.Close()
1761 1767
 			fmt.Println(getNurseErr)
@@ -1770,7 +1776,7 @@ func (c *DialysisAPIController) Finish() {
1770 1776
 
1771 1777
 			redis := service.RedisClient()
1772 1778
 			redis.Set(key, "", time.Second)
1773
-			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
1779
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
1774 1780
 			redis.Set(keyOne, "", time.Second)
1775 1781
 			defer redis.Close()
1776 1782
 			fmt.Println(getNurseErr)
@@ -1871,7 +1877,7 @@ func (c *DialysisAPIController) Finish() {
1871 1877
 
1872 1878
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1873 1879
 	redis := service.RedisClient()
1874
-	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
1880
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
1875 1881
 	redis.Set(keyOne, "", time.Second)
1876 1882
 
1877 1883
 	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_last"
@@ -1901,7 +1907,7 @@ func (c *DialysisAPIController) Finish() {
1901 1907
 		//清空key 值
1902 1908
 		redis.Set(key, "", time.Second)
1903 1909
 
1904
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
1910
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_orders_list_all"
1905 1911
 		redis.Set(keyOne, "", time.Second)
1906 1912
 		//结束时候透析次数加1
1907 1913
 		service.UpdateSolutionByPatientId(id)
@@ -2153,10 +2159,9 @@ func (this *DialysisAPIController) StartDialysis() {
2153 2159
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2154 2160
 
2155 2161
 		redis := service.RedisClient()
2156
-		defer redis.Close()
2157 2162
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2158 2163
 		redis.Set(key, "", time.Second)
2159
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
2164
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_orders_list_all"
2160 2165
 		//清空key 值
2161 2166
 		redis.Set(keyOne, "", time.Second)
2162 2167
 
@@ -2183,7 +2188,7 @@ func (this *DialysisAPIController) StartDialysis() {
2183 2188
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2184 2189
 	//后期预增脱水量
2185 2190
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2186
-	fmt.Println(evaluation)
2191
+
2187 2192
 	if prescription.ID > 0 {
2188 2193
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2189 2194
 
@@ -2261,11 +2266,13 @@ func (this *DialysisAPIController) StartDialysis() {
2261 2266
 	if newdialysisRecord.ID > 0 {
2262 2267
 		err := service.CreateMonitor(&record)
2263 2268
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2269
+
2264 2270
 		redis := service.RedisClient()
2265
-		defer redis.Close()
2266 2271
 		//清空key 值
2267 2272
 		redis.Set(key, "", time.Second)
2268
-
2273
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_record_list_all"
2274
+		redis.Set(keyOne, "", time.Second)
2275
+		defer redis.Close()
2269 2276
 		if err != nil {
2270 2277
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2271 2278
 			return
@@ -2626,7 +2633,7 @@ func (c *DialysisAPIController) PostSolution() {
2626 2633
 	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
2627 2634
 	redis.Set(keyTwo, "", time.Second)
2628 2635
 
2629
-	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
2636
+	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
2630 2637
 	redis.Set(keyThree, "", time.Second)
2631 2638
 
2632 2639
 	keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
@@ -2991,13 +2998,13 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
2991 2998
 
2992 2999
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
2993 3000
 	redis.Set(key, "", time.Second)
2994
-	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
2995
-	fmt.Println("keyOne23332233223322332322332", keyOne)
3001
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_orders_list_all"
3002
+
2996 3003
 	//清空key 值
2997 3004
 	redis.Set(keyOne, "", time.Second)
2998 3005
 	scheduleDateStartOne := startDate.Format("2006-01-02")
2999 3006
 	keyTwo := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
3000
-	fmt.Println("keyTwo2332323232233223232323", keyTwo)
3007
+
3001 3008
 	redis.Set(keyTwo, "", time.Second)
3002 3009
 
3003 3010
 	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":doctor_advices"
@@ -3014,7 +3021,6 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
3014 3021
 	keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":device_list_all"
3015 3022
 	redis.Set(keySeven, "", time.Second)
3016 3023
 
3017
-	defer redis.Close()
3018 3024
 	if updateErr != nil {
3019 3025
 		this.ErrorLog("修改上机失败:%v", updateErr)
3020 3026
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -3031,6 +3037,18 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
3031 3037
 			hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
3032 3038
 			minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
3033 3039
 			updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecord.PatientId, tempDialysisRecord.UserOrgId, tempDialysisRecord.DialysisDate, hour, minute)
3040
+			redis := service.RedisClient()
3041
+			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":assessment_after_dislysis_list_all"
3042
+			redis.Set(key, "", time.Second)
3043
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecord.PatientId, 10) + ":" + strconv.FormatInt(record_date, 10) + ":assessment_after_dislysis"
3044
+			redis.Set(keyOne, "", time.Second)
3045
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_orders_list_all"
3046
+			//清空key 值
3047
+			redis.Set(keySix, "", time.Second)
3048
+
3049
+			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":monitor_records"
3050
+			redis.Set(keySeven, "", time.Second)
3051
+			redis.Close()
3034 3052
 			if updateAssessmentErr != nil {
3035 3053
 				utils.ErrorLog("%v", updateAssessmentErr)
3036 3054
 			}
@@ -3097,9 +3115,12 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
3097 3115
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
3098 3116
 	//清空key 值
3099 3117
 	redis.Set(key, "", time.Second)
3100
-	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
3118
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_orders_list_all"
3101 3119
 	//清空key 值
3102 3120
 	redis.Set(keyOne, "", time.Second)
3121
+
3122
+	keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":monitor_records"
3123
+	redis.Set(keySeven, "", time.Second)
3103 3124
 	redis.Close()
3104 3125
 	if updateErr != nil {
3105 3126
 		c.ErrorLog("修改下机失败:%v", updateErr)
@@ -3123,11 +3144,14 @@ func (c *DialysisAPIController) ModifyFinishDialysisOrder() {
3123 3144
 		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":assessment_after_dislysis_last"
3124 3145
 		redis.Set(keyTwo, "", time.Second)
3125 3146
 
3126
-		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
3147
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":assessment_after_dislysis_list_all"
3127 3148
 
3128 3149
 		redis.Set(key, "", time.Second)
3129
-		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
3150
+		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_orders_list_all"
3130 3151
 		redis.Set(keyThree, "", time.Second)
3152
+
3153
+		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":monitor_records"
3154
+		redis.Set(keySeven, "", time.Second)
3131 3155
 		defer redis.Close()
3132 3156
 		if updateAssessmentErr != nil {
3133 3157
 			utils.ErrorLog("%v", updateAssessmentErr)
@@ -3222,10 +3246,11 @@ func (c *DialysisAPIController) GetLongAdvice() {
3222 3246
 		}
3223 3247
 		if err == nil {
3224 3248
 			c.ServeSuccessJSON(map[string]interface{}{
3225
-				"status":         "2",
3226
-				"advices":        advices,
3227
-				"advices_two":    RemoveRepeatedElement(advice_three),
3228
-				"is_open_remind": config.IsOpenRemind,
3249
+				"status":          "2",
3250
+				"advices":         advices,
3251
+				"advices_two":     RemoveRepeatedElement(advice_three),
3252
+				"is_open_remind":  config.IsOpenRemind,
3253
+				"his_config_open": hisConfig.IsOpen,
3229 3254
 			})
3230 3255
 		}
3231 3256
 	}
@@ -3535,7 +3560,7 @@ func (c *DialysisAPIController) CreateRemindDoctorAdvice() {
3535 3560
 		//清空key 值
3536 3561
 		redis.Set(key, "", time.Second)
3537 3562
 
3538
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3563
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
3539 3564
 		redis.Set(keyOne, "", time.Second)
3540 3565
 
3541 3566
 		keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
@@ -3629,12 +3654,13 @@ func (c *DialysisAPIController) UploadDryWeight() {
3629 3654
 
3630 3655
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3631 3656
 		redis := service.RedisClient()
3632
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
3633
-		redis.Set(keyOne, "", time.Second)
3634 3657
 		loc, _ := time.LoadLocation("Local")
3635 3658
 		nowTime := time.Now()
3636 3659
 		nowDay := nowTime.Format("2006-01-02")
3637 3660
 		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
3661
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
3662
+		redis.Set(keyOne, "", time.Second)
3663
+
3638 3664
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3639 3665
 		redis.Set(key, "", time.Second)
3640 3666
 		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
@@ -3845,8 +3871,8 @@ func (c *DialysisAPIController) CreateConsumables() {
3845 3871
 
3846 3872
 		//查询是否有库存
3847 3873
 		for _, item := range dialysisBefor {
3848
-			warehouse, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId)
3849
-			fmt.Println("库存数量00000000000000000000", warehouse.StockCount, err)
3874
+			_, err := service.FindFirstWarehousingInfoByStock(item.GoodId, item.GoodTypeId)
3875
+
3850 3876
 			if err == gorm.ErrRecordNotFound {
3851 3877
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3852 3878
 				c.ServeSuccessJSON(map[string]interface{}{

+ 17 - 11
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -172,7 +172,7 @@ func (this *DialysisAPIController) AddMonitorRecord() {
172 172
 	redis := service.RedisClient()
173 173
 	//清空key 值
174 174
 	redis.Set(key, "", time.Second)
175
-	keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
175
+	keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_record_list_all"
176 176
 	redis.Set(keyOne, "", time.Second)
177 177
 	defer redis.Close()
178 178
 	if err != nil {
@@ -336,7 +336,7 @@ func (this *DialysisAPIController) EditMonitorRecord() {
336 336
 	redis := service.RedisClient()
337 337
 	//清空key 值
338 338
 	redis.Set(key, "", time.Second)
339
-	keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
339
+	keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_record_list_all"
340 340
 	redis.Set(keyOne, "", time.Second)
341 341
 
342 342
 	defer redis.Close()
@@ -380,7 +380,7 @@ func (this *DialysisAPIController) DeleteMonitor() {
380 380
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
381 381
 	orgid := this.GetMobileAdminUserInfo().Org.Id
382 382
 	redis := service.RedisClient()
383
-	key := strconv.FormatInt(orgid, 10) + ":" + ":monitor_record_list_all"
383
+	key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_record_list_all"
384 384
 	redis.Set(key, "", time.Second)
385 385
 	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
386 386
 	redis.Set(keyOne, "", time.Second)
@@ -501,27 +501,29 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
501 501
 			}
502 502
 			createErr := service.CreateSchedule(newSchedule)
503 503
 			redis := service.RedisClient()
504
-
504
+			timeStr := time.Now().Format("2006-01-02")
505
+			key := "scheduals_" + timeStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
506
+			redis.Set(key, "", time.Second)
505 507
 			//处方
506
-			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
508
+			keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":prescriptions_list_all"
507 509
 			redis.Set(keyOne, "", time.Second)
508 510
 
509 511
 			//医嘱
510
-			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
512
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":advice_list_all"
511 513
 			redis.Set(keyTwo, "", time.Second)
512 514
 
513
-			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
515
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":assessment_befores_list_all"
514 516
 			redis.Set(keySix, "", time.Second)
515
-			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
517
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
516 518
 			redis.Set(keyThree, "", time.Second)
517 519
 
518
-			keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
520
+			keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":monitor_record_list_all"
519 521
 			redis.Set(keyFour, "", time.Second)
520 522
 
521
-			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
523
+			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":treatment_summarys_list_all"
522 524
 			redis.Set(keyFive, "", time.Second)
523 525
 
524
-			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
526
+			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":dialysis_orders_list_all"
525 527
 			redis.Set(keySeven, "", time.Second)
526 528
 			redis.Close()
527 529
 			if createErr != nil {
@@ -561,6 +563,10 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
561 563
 					daySchedule.UpdatedTime = time.Now().Unix()
562 564
 					err := service.UpdateSchedule(&daySchedule)
563 565
 					redis := service.RedisClient()
566
+
567
+					timeStr := time.Now().Format("2006-01-02")
568
+					key := "scheduals_" + timeStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
569
+					redis.Set(key, "", time.Second)
564 570
 					//处方
565 571
 					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
566 572
 					redis.Set(keyOne, "", time.Second)

+ 117 - 23
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -244,7 +244,7 @@ func (c *PatientApiController) CreateDoctorAdvice() {
244 244
 	redis := service.RedisClient()
245 245
 	defer redis.Close()
246 246
 	redis.Set(key, "", time.Second)
247
-	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
247
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
248 248
 	redis.Set(keyOne, "", time.Second)
249 249
 	if err != nil {
250 250
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
@@ -327,7 +327,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
327 327
 
328 328
 				defer redis.Close()
329 329
 				redis.Set(key, "", time.Second)
330
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
330
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
331 331
 				redis.Set(keyOne, "", time.Second)
332 332
 			}
333 333
 		} else if len(adviceSlice) > 1 {
@@ -339,7 +339,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
339 339
 
340 340
 				defer redis.Close()
341 341
 				redis.Set(key, "", time.Second)
342
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
342
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
343 343
 				redis.Set(keyOne, "", time.Second)
344 344
 				isChangeGroup = false
345 345
 
@@ -352,7 +352,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
352 352
 
353 353
 				defer redis.Close()
354 354
 				redis.Set(key, "", time.Second)
355
-				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
355
+				keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
356 356
 				redis.Set(keyOne, "", time.Second)
357 357
 				isChangeGroup = true
358 358
 
@@ -363,7 +363,7 @@ func (c *PatientApiController) EditDoctorAdvice() {
363 363
 		err = service.UpdateDoctorAdvice(&advice)
364 364
 		redis := service.RedisClient()
365 365
 		defer redis.Close()
366
-		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
366
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
367 367
 		redis.Set(key, "", time.Second)
368 368
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
369 369
 		redis.Set(keyOne, "", time.Second)
@@ -627,7 +627,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
627 627
 			redis := service.RedisClient()
628 628
 			//清空key 值
629 629
 			redis.Set(key, "", time.Second)
630
-			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
630
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
631 631
 			redis.Set(keyTwo, "", time.Second)
632 632
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
633 633
 			redis.Set(keyThree, "", time.Second)
@@ -638,13 +638,16 @@ func (c *PatientApiController) ExecDoctorAdvice() {
638 638
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
639 639
 			fmt.Println("keyFour323223323232323232", keyFour)
640 640
 			redis.Set(keyFour, "", time.Second)
641
+			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
642
+			redis.Set(keyFive, "", time.Second)
643
+
641 644
 			defer redis.Close()
642 645
 		} else {
643 646
 
644 647
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
645 648
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
646 649
 			redis := service.RedisClient()
647
-			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
650
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
648 651
 			redis.Set(keyTwo, "", time.Second)
649 652
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
650 653
 			redis.Set(keyThree, "", time.Second)
@@ -654,6 +657,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
654 657
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
655 658
 			fmt.Println("keyFour323223323232323232", keyFour)
656 659
 			redis.Set(keyFour, "", time.Second)
660
+			keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
661
+			redis.Set(keySix, "", time.Second)
657 662
 			defer redis.Close()
658 663
 			//清空key 值
659 664
 			redis.Set(key, "", time.Second)
@@ -936,6 +941,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
936 941
 		timeLayout2 := "2006-01-02 15:04:05"
937 942
 		loc, _ := time.LoadLocation("Local")
938 943
 		theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
944
+
939 945
 		if errs != nil {
940 946
 			utils.ErrorLog(errs.Error())
941 947
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -969,12 +975,17 @@ func (c *PatientApiController) ExecDoctorAdvice() {
969 975
 			redis := service.RedisClient()
970 976
 			//清空key 值
971 977
 			redis.Set(key, "", time.Second)
972
-			keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + ":advice_list_all"
978
+			keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
973 979
 			redis.Set(keyTwo, "", time.Second)
974 980
 			keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
975 981
 			redis.Set(keyThree, "", time.Second)
976
-			keyFour := "scheduals_" + execution_time + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
982
+			recordDate := theTime.Format("2006-01-02")
983
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
984
+
977 985
 			redis.Set(keyFour, "", time.Second)
986
+			keyFive := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
987
+			redis.Set(keyFive, "", time.Second)
988
+
978 989
 			defer redis.Close()
979 990
 		}
980 991
 
@@ -1129,10 +1140,28 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1129 1140
 	}
1130 1141
 	var err error
1131 1142
 	if groupno > 0 {
1143
+
1132 1144
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1145
+		redis := service.RedisClient()
1146
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1147
+		fmt.Println("keyThh322323232323232323223", key)
1148
+		redis.Set(key, "", time.Second)
1149
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1150
+		redis.Set(keyOne, "", time.Second)
1151
+
1152
+		defer redis.Close()
1133 1153
 
1134 1154
 	} else {
1135 1155
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
1156
+		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1157
+		redis := service.RedisClient()
1158
+		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1159
+		fmt.Println("keyTwohh322323232323232323223", key)
1160
+		redis.Set(key, "", time.Second)
1161
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1162
+		redis.Set(keyOne, "", time.Second)
1163
+
1164
+		defer redis.Close()
1136 1165
 	}
1137 1166
 
1138 1167
 	//判断是否开启his
@@ -1144,14 +1173,38 @@ func (c *PatientApiController) ModifyExecDoctorAdvice() {
1144 1173
 			UpdatedTime:   time.Now().Unix(),
1145 1174
 		}
1146 1175
 		fmt.Println("ids2323232232323", ids)
1176
+		var advicehis models.HisDoctorAdviceInfo
1147 1177
 		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1178
+		his_advices, _ := service.FindHisDoctorAdviceByIdOne(adminUserInfo.Org.Id, ids)
1179
+		for _, item := range his_advices {
1180
+			if item.ExecutionState == 1 {
1181
+				advicehis = item
1182
+			}
1183
+		}
1184
+		redis := service.RedisClient()
1185
+		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicehis.PatientId, 10) + ":" + strconv.FormatInt(advicehis.AdviceDate, 10) + ":his_doctor_advice"
1186
+		redis.Set(keyThree, "", time.Second)
1187
+		recordDate := theTime.Format("2006-01-02")
1188
+		keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1148 1189
 
1190
+		redis.Set(keyFour, "", time.Second)
1191
+		keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicehis.AdviceDate, 10) + ":his_advices_list_all"
1192
+		redis.Set(keyFive, "", time.Second)
1193
+		defer redis.Close()
1149 1194
 		project := models.HisPrescriptionProject{
1150 1195
 			ExecutionTime: theTime.Unix(),
1151 1196
 			Mtime:         time.Now().Unix(),
1152 1197
 		}
1153 1198
 		service.ModifyHisPrescriptionProject(&project, ids)
1154 1199
 
1200
+		keyEnd := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicesinfo.PatientId, 10) + ":" + strconv.FormatInt(advicesinfo.AdviceDate, 10) + ":his_doctor_advice"
1201
+		redis.Set(keyEnd, "", time.Second)
1202
+		keyFours := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1203
+
1204
+		redis.Set(keyFours, "", time.Second)
1205
+		keyFives := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicesinfo.AdviceDate, 10) + ":his_advices_list_all"
1206
+		redis.Set(keyFives, "", time.Second)
1207
+		defer redis.Close()
1155 1208
 	}
1156 1209
 	if err != nil {
1157 1210
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
@@ -1242,9 +1295,19 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1242 1295
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1243 1296
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1244 1297
 			redis := service.RedisClient()
1245
-			defer redis.Close()
1246 1298
 			//清空key 值
1247 1299
 			redis.Set(key, "", time.Second)
1300
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1301
+			redis.Set(keyTwo, "", time.Second)
1302
+			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
1303
+			redis.Set(keyThree, "", time.Second)
1304
+			recordDate := theTime.Format("2006-01-02")
1305
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1306
+
1307
+			redis.Set(keyFour, "", time.Second)
1308
+			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1309
+			redis.Set(keyFive, "", time.Second)
1310
+			defer redis.Close()
1248 1311
 		} else {
1249 1312
 
1250 1313
 			if len(ids[0]) <= 0 {
@@ -1256,7 +1319,21 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1256 1319
 				//loc, _ := time.LoadLocation("Local")
1257 1320
 				//theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
1258 1321
 				err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
1259
-
1322
+				key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1323
+				redis := service.RedisClient()
1324
+				//清空key 值
1325
+				redis.Set(key, "", time.Second)
1326
+				keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1327
+				redis.Set(keyTwo, "", time.Second)
1328
+				keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
1329
+				redis.Set(keyThree, "", time.Second)
1330
+				recordDate := theTime.Format("2006-01-02")
1331
+				keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1332
+
1333
+				redis.Set(keyFour, "", time.Second)
1334
+				keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1335
+				redis.Set(keyFive, "", time.Second)
1336
+				defer redis.Close()
1260 1337
 			}
1261 1338
 		}
1262 1339
 
@@ -1292,11 +1369,23 @@ func (c *PatientApiController) CheckDoctorAdvice() {
1292 1369
 			item.CheckTime = time.Now().Unix()
1293 1370
 			item.CheckState = 1
1294 1371
 			err = service.SaveHisDoctorAdvice(item)
1295
-			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1296 1372
 			redis := service.RedisClient()
1297
-			defer redis.Close()
1373
+			key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
1298 1374
 			//清空key 值
1299 1375
 			redis.Set(key, "", time.Second)
1376
+			keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
1377
+			redis.Set(keyTwo, "", time.Second)
1378
+			keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
1379
+			redis.Set(keyThree, "", time.Second)
1380
+			theTime := time.Now()
1381
+
1382
+			recordDate := theTime.Format("2006-01-02")
1383
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
1384
+
1385
+			redis.Set(keyFour, "", time.Second)
1386
+			keyFive := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
1387
+			redis.Set(keyFive, "", time.Second)
1388
+			defer redis.Close()
1300 1389
 		}
1301 1390
 		if err == nil {
1302 1391
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -1637,7 +1726,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
1637 1726
 	defer redis.Close()
1638 1727
 	//清空key 值
1639 1728
 	redis.Set(key, "", time.Second)
1640
-	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
1729
+	keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
1641 1730
 	redis.Set(keyOne, "", time.Second)
1642 1731
 	keyTwo := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1643 1732
 	redis.Set(keyTwo, "", time.Second)
@@ -2047,7 +2136,10 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2047 2136
 		blood_access_part_id := dataBody["blood_access_part_id"].(string)
2048 2137
 		evaluation.BloodAccessPartId = blood_access_part_id
2049 2138
 	}
2050
-
2139
+	//if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "float64" {
2140
+	//	blood_access_part_id := int64(dataBody["blood_access_part_id"].(float64))
2141
+	//	evaluation.BloodAccessPartId = blood_access_part_id
2142
+	//}
2051 2143
 	if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
2052 2144
 		blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
2053 2145
 		evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
@@ -2066,6 +2158,9 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2066 2158
 		is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
2067 2159
 		evaluation.IsHemorrhage = is_hemorrhage
2068 2160
 
2161
+		//if dataBody["is_hemorrhage"] != nil && reflect.TypeOf(dataBody["is_hemorrhage"]).String() == "float64" {
2162
+		//	is_hemorrhage := int64(dataBody["is_hemorrhage"].(float64))
2163
+		//	fmt.Println("is_hemorrhage2222222222222222",is_hemorrhage)
2069 2164
 		if is_hemorrhage != 1 && is_hemorrhage != 2 {
2070 2165
 			is_hemorrhage = 0
2071 2166
 		}
@@ -2181,8 +2276,6 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2181 2276
 
2182 2277
 		humor_excessive_symptom, _ := dataBody["humor_excessive_symptom"].(string)
2183 2278
 
2184
-	if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "string" {
2185
-		humor_excessive_symptom := dataBody["humor_excessive_symptom"].(string)
2186 2279
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2187 2280
 	}
2188 2281
 
@@ -2621,7 +2714,7 @@ func (c *PatientApiController) GetPatientMonitor() {
2621 2714
 			//获取透前评估
2622 2715
 			assessmentBefores, _ := service.GetAllAssessmentBeforesByListOne(orgID, theStartTime)
2623 2716
 			//获取上机
2624
-			dialysisOrders, _ := service.GetAllDialysisOrdersByListOne(orgID, theStartTime)
2717
+			dialysisOrders, _ := service.GetAllDialysisOrdersByListSix(orgID, theStartTime)
2625 2718
 			//获取透后
2626 2719
 			AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListOne(orgID, theStartTime)
2627 2720
 
@@ -3164,7 +3257,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
3164 3257
 		redis := service.RedisClient()
3165 3258
 		//清空key 值
3166 3259
 		redis.Set(key, "", time.Second)
3167
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3260
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
3168 3261
 		redis.Set(keyOne, "", time.Second)
3169 3262
 
3170 3263
 		defer redis.Close()
@@ -3237,7 +3330,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
3237 3330
 		redis := service.RedisClient()
3238 3331
 		//清空key 值
3239 3332
 		redis.Set(key, "", time.Second)
3240
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3333
+		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
3241 3334
 		redis.Set(keyOne, "", time.Second)
3242 3335
 		fmt.Println("key`2232333332233223233232", key)
3243 3336
 		defer redis.Close()
@@ -3376,7 +3469,7 @@ func (c *PatientApiController) DelDoctorAdvice() {
3376 3469
 
3377 3470
 		redis.Set(key, "", time.Second)
3378 3471
 
3379
-		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3472
+		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
3380 3473
 		redis.Set(keyTwo, "", time.Second)
3381 3474
 		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3382 3475
 		redis.Set(keyThree, "", time.Second)
@@ -3440,7 +3533,8 @@ func (c *PatientApiController) DelDoctorAdvice() {
3440 3533
 
3441 3534
 			redis.Set(key, "", time.Second)
3442 3535
 
3443
-			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3536
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
3537
+
3444 3538
 			redis.Set(keyTwo, "", time.Second)
3445 3539
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3446 3540
 			redis.Set(keyThree, "", time.Second)
@@ -3451,7 +3545,7 @@ func (c *PatientApiController) DelDoctorAdvice() {
3451 3545
 
3452 3546
 			redis.Set(key, "", time.Second)
3453 3547
 			fmt.Println("key2332323223323232323232323", key)
3454
-			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
3548
+			keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
3455 3549
 			fmt.Println("key2332323223323232323232323", keyTwo)
3456 3550
 			redis.Set(keyTwo, "", time.Second)
3457 3551
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"

+ 21 - 0
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -273,6 +273,7 @@ func (c *MobileHisApiController) DeletePrescription() {
273 273
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
274 274
 
275 275
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
276
+
276 277
 	if err == nil {
277 278
 		if len(projects) > 0 {
278 279
 			for _, item := range projects {
@@ -303,6 +304,10 @@ func (c *MobileHisApiController) DeletePrescription() {
303 304
 					if item.PrescribingNumberUnit == drug.MinUnit {
304 305
 						drug.Total = drug.Total + item.PrescribingNumber
305 306
 						service.UpdateBaseDrugLib(&drug)
307
+						redis := service.RedisClient()
308
+						keyFive := strconv.FormatInt(item.UserOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
309
+						redis.Set(keyFive, "", time.Second)
310
+						defer redis.Close()
306 311
 					} else {
307 312
 						if item.PrescribingNumberUnit == drug.MaxUnit {
308 313
 							item.PrescribingNumber = item.PrescribingNumber * float64(drug.MinNumber)
@@ -721,6 +726,15 @@ func (c *MobileHisApiController) CreateHisPrescription() {
721 726
 								return
722 727
 							}
723 728
 							service.CreateHisDoctorAdvice(&s)
729
+							redis := service.RedisClient()
730
+							key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
731
+							fmt.Println("key111111111111111111", key)
732
+							redis.Set(key, "", time.Second)
733
+							keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
734
+							redis.Set(keyOne, "", time.Second)
735
+							keySeven := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
736
+							redis.Set(keySeven, "", time.Second)
737
+							redis.Close()
724 738
 							var randNum int
725 739
 							randNum = rand.Intn(10000) + 1000
726 740
 							timestamp := time.Now().Unix()
@@ -729,6 +743,13 @@ func (c *MobileHisApiController) CreateHisPrescription() {
729 743
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
730 744
 							service.CreateHisDoctorAdvice(&s)
731 745
 
746
+							redis.Set(key, "", time.Second)
747
+							keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
748
+							redis.Set(keyTwo, "", time.Second)
749
+							keyThree := "scheduals_" + record_date + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
750
+							redis.Set(keyThree, "", time.Second)
751
+							redis.Close()
752
+
732 753
 						}
733 754
 					}
734 755
 				}

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

@@ -310,6 +310,37 @@ func (this *StaffScheduleApiController) DeleteSchedule() {
310 310
 	id, _ := this.GetInt64("id")
311 311
 	fmt.Println("id", id)
312 312
 	err := service.DeleteSchedule(id)
313
+	org_id := this.GetMobileAdminUserInfo().Org.Id
314
+	schedule, _ := service.GetSchedule(org_id, id)
315
+	if schedule == nil {
316
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
317
+		return
318
+	}
319
+	redis := service.RedisClient()
320
+
321
+	//处方
322
+	keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
323
+	redis.Set(keyOne, "", time.Second)
324
+
325
+	//医嘱
326
+	keyTwo := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
327
+	redis.Set(keyTwo, "", time.Second)
328
+
329
+	keySix := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
330
+	redis.Set(keySix, "", time.Second)
331
+	keyThree := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
332
+	redis.Set(keyThree, "", time.Second)
333
+
334
+	keyFour := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
335
+	redis.Set(keyFour, "", time.Second)
336
+
337
+	keyFive := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
338
+	redis.Set(keyFive, "", time.Second)
339
+
340
+	keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
341
+	redis.Set(keySeven, "", time.Second)
342
+	fmt.Println(err)
343
+	defer redis.Close()
313 344
 	fmt.Println(err)
314 345
 	returnData := make(map[string]interface{}, 0)
315 346
 	returnData["msg"] = "ok"

+ 168 - 8
controllers/patient_api_controller.go View File

@@ -1418,7 +1418,7 @@ func (c *PatientApiController) CreateGroupAdvice() {
1418 1418
 	redis := service.RedisClient()
1419 1419
 	defer redis.Close()
1420 1420
 	redis.Set(key, "", time.Second)
1421
-	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
1421
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
1422 1422
 	redis.Set(keyOne, "", time.Second)
1423 1423
 	if err != nil {
1424 1424
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
@@ -1506,7 +1506,7 @@ func (c *PatientApiController) CreateDoctorAdvice() {
1506 1506
 	redis := service.RedisClient()
1507 1507
 	defer redis.Close()
1508 1508
 	redis.Set(key, "", time.Second)
1509
-	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
1509
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1510 1510
 	redis.Set(keyOne, "", time.Second)
1511 1511
 	if err != nil {
1512 1512
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
@@ -1650,8 +1650,46 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1650 1650
 		}
1651 1651
 		if advice.ParentId > 0 {
1652 1652
 			err = service.ExceDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
1653
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1654
+			redis := service.RedisClient()
1655
+			//清空key 值
1656
+			redis.Set(key, "", time.Second)
1657
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1658
+			redis.Set(keyTwo, "", time.Second)
1659
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
1660
+			redis.Set(keyThree, "", time.Second)
1661
+
1662
+			theTimes := theTime.Format("2006-01-02")
1663
+
1664
+			fmt.Println("theTIME", theTime)
1665
+			keyFour := "scheduals_" + theTimes + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1666
+
1667
+			redis.Set(keyFour, "", time.Second)
1668
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1669
+			redis.Set(keyFive, "", time.Second)
1670
+
1671
+			defer redis.Close()
1653 1672
 		} else {
1654 1673
 			err = service.ExceDoctorAdviceById(&exceAdvice, id, patient)
1674
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1675
+			redis := service.RedisClient()
1676
+			//清空key 值
1677
+			redis.Set(key, "", time.Second)
1678
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1679
+			redis.Set(keyTwo, "", time.Second)
1680
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
1681
+			redis.Set(keyThree, "", time.Second)
1682
+
1683
+			theTimes := theTime.Format("2006-01-02")
1684
+
1685
+			fmt.Println("theTIME", theTime)
1686
+			keyFour := "scheduals_" + theTimes + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1687
+
1688
+			redis.Set(keyFour, "", time.Second)
1689
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1690
+			redis.Set(keyFive, "", time.Second)
1691
+
1692
+			defer redis.Close()
1655 1693
 		}
1656 1694
 
1657 1695
 		if err != nil {
@@ -1669,19 +1707,19 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1669 1707
 
1670 1708
 		//药品管理信息
1671 1709
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
1672
-		fmt.Println("999999992322322323232", drugStockConfig.IsOpen)
1710
+
1673 1711
 		//自备药信息
1674 1712
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
1675
-		fmt.Println("drugStockConfig2323232332232332", drugStockConfig.IsOpen)
1713
+
1676 1714
 		if drugStockConfig.IsOpen == 1 {
1677 1715
 			var total int64
1678 1716
 			var prescribing_number_total int64
1679 1717
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1680 1718
 			for _, item := range advices {
1681
-				fmt.Println("imte00000000000000", item.PrescribingNumber)
1719
+
1682 1720
 				//查询该药品是否有库存
1683 1721
 				list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
1684
-				fmt.Println("list23232323232232323232323232", list)
1722
+
1685 1723
 				//查询改药品信息
1686 1724
 				medical, _ := service.GetBaseDrugMedical(item.DrugId)
1687 1725
 				//判断单位是否相等
@@ -1832,8 +1870,46 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1832 1870
 		}
1833 1871
 		if advice.ParentId > 0 {
1834 1872
 			err = service.ExceHidDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
1873
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1874
+			redis := service.RedisClient()
1875
+			//清空key 值
1876
+			redis.Set(key, "", time.Second)
1877
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1878
+			redis.Set(keyTwo, "", time.Second)
1879
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
1880
+			redis.Set(keyThree, "", time.Second)
1881
+
1882
+			theTimes := theTime.Format("2006-01-02")
1883
+
1884
+			fmt.Println("theTIME", theTime)
1885
+			keyFour := "scheduals_" + theTimes + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1886
+			fmt.Println("keyFour323223323232323232", keyFour)
1887
+			redis.Set(keyFour, "", time.Second)
1888
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1889
+			redis.Set(keyFive, "", time.Second)
1890
+
1891
+			defer redis.Close()
1835 1892
 		} else {
1836 1893
 			err = service.ExceHidDoctorAdviceById(&exceAdvice, id, patient)
1894
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1895
+			redis := service.RedisClient()
1896
+			//清空key 值
1897
+			redis.Set(key, "", time.Second)
1898
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
1899
+			redis.Set(keyTwo, "", time.Second)
1900
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
1901
+			redis.Set(keyThree, "", time.Second)
1902
+
1903
+			theTimes := theTime.Format("2006-01-02")
1904
+
1905
+			fmt.Println("theTIME", theTime)
1906
+			keyFour := "scheduals_" + theTimes + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1907
+			fmt.Println("keyFour323223323232323232", keyFour)
1908
+			redis.Set(keyFour, "", time.Second)
1909
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
1910
+			redis.Set(keyFive, "", time.Second)
1911
+
1912
+			defer redis.Close()
1837 1913
 		}
1838 1914
 
1839 1915
 		if err != nil {
@@ -2035,8 +2111,36 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2035 2111
 		var err error
2036 2112
 		if advice.ParentId > 0 {
2037 2113
 			err = service.CheckDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2114
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2115
+			redis := service.RedisClient()
2116
+			//清空key 值
2117
+			redis.Set(key, "", time.Second)
2118
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2119
+			redis.Set(keyTwo, "", time.Second)
2120
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
2121
+			redis.Set(keyThree, "", time.Second)
2122
+			recordDate := theTime.Format("2006-01-02")
2123
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2124
+
2125
+			redis.Set(keyFour, "", time.Second)
2126
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
2127
+			redis.Set(keyFive, "", time.Second)
2038 2128
 		} else {
2039 2129
 			err = service.CheckDoctorAdviceById(&exceAdvice, id, patient)
2130
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2131
+			redis := service.RedisClient()
2132
+			//清空key 值
2133
+			redis.Set(key, "", time.Second)
2134
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2135
+			redis.Set(keyTwo, "", time.Second)
2136
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
2137
+			redis.Set(keyThree, "", time.Second)
2138
+			recordDate := theTime.Format("2006-01-02")
2139
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2140
+
2141
+			redis.Set(keyFour, "", time.Second)
2142
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
2143
+			redis.Set(keyFive, "", time.Second)
2040 2144
 		}
2041 2145
 
2042 2146
 		if err != nil {
@@ -2094,8 +2198,36 @@ func (c *PatientApiController) CheckDoctorAdvice() {
2094 2198
 		var err error
2095 2199
 		if advice.ParentId > 0 {
2096 2200
 			err = service.CheckHisDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
2201
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2202
+			redis := service.RedisClient()
2203
+			//清空key 值
2204
+			redis.Set(key, "", time.Second)
2205
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2206
+			redis.Set(keyTwo, "", time.Second)
2207
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
2208
+			redis.Set(keyThree, "", time.Second)
2209
+			recordDate := theTime.Format("2006-01-02")
2210
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2211
+
2212
+			redis.Set(keyFour, "", time.Second)
2213
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
2214
+			redis.Set(keyFive, "", time.Second)
2097 2215
 		} else {
2098 2216
 			err = service.CheckHisDoctorAdviceById(&exceAdvice, id, patient)
2217
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2218
+			redis := service.RedisClient()
2219
+			//清空key 值
2220
+			redis.Set(key, "", time.Second)
2221
+			keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2222
+			redis.Set(keyTwo, "", time.Second)
2223
+			keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
2224
+			redis.Set(keyThree, "", time.Second)
2225
+			recordDate := theTime.Format("2006-01-02")
2226
+			keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
2227
+
2228
+			redis.Set(keyFour, "", time.Second)
2229
+			keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
2230
+			redis.Set(keyFive, "", time.Second)
2099 2231
 		}
2100 2232
 
2101 2233
 		if err != nil {
@@ -2170,11 +2302,15 @@ func (c *PatientApiController) UpdateDoctorAdvice() {
2170 2302
 
2171 2303
 	err := service.UpdateDoctorAdvice(&advice)
2172 2304
 	redis := service.RedisClient()
2173
-	defer redis.Close()
2174
-	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
2305
+
2306
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2307
+
2175 2308
 	redis.Set(key, "", time.Second)
2309
+	fmt.Println("key2332233232322332", key)
2176 2310
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2177 2311
 	redis.Set(keyOne, "", time.Second)
2312
+	fmt.Println("key3333333333333333", keyOne)
2313
+	defer redis.Close()
2178 2314
 	if err != nil {
2179 2315
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
2180 2316
 		return
@@ -2377,6 +2513,10 @@ func (c *PatientApiController) DeleteDoctorAdvice() {
2377 2513
 	advice.Modifier = adminUserInfo.AdminUser.Id
2378 2514
 
2379 2515
 	err := service.DeleteDoctorAdvice(&advice)
2516
+	redis := service.RedisClient()
2517
+	key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2518
+	redis.Set(key, "", time.Second)
2519
+	redis.Close()
2380 2520
 	if err != nil {
2381 2521
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2382 2522
 		return
@@ -2416,6 +2556,13 @@ func (c *PatientApiController) DeleteGroupAdvice() {
2416 2556
 	//}
2417 2557
 
2418 2558
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
2559
+	key := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2560
+	redis := service.RedisClient()
2561
+
2562
+	redis.Set(key, "", time.Second)
2563
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
2564
+	redis.Set(keyOne, "", time.Second)
2565
+	defer redis.Close()
2419 2566
 	if err != nil {
2420 2567
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2421 2568
 		return
@@ -4495,6 +4642,19 @@ func (c *PatientApiController) SaveEditAdvices() {
4495 4642
 		StartTime: theTime.Unix(),
4496 4643
 	}
4497 4644
 	err := service.UpdateDoctorEditAdvice(advice, orgid, groupno, date, patient_id)
4645
+	key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(date, 10) + ":doctor_advices"
4646
+	redis := service.RedisClient()
4647
+
4648
+	redis.Set(key, "", time.Second)
4649
+	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(date, 10) + ":advice_list_all"
4650
+	redis.Set(keyOne, "", time.Second)
4651
+
4652
+	scheduleTime := theTime.Format("2006-01-02")
4653
+	keyFour := "scheduals_" + scheduleTime + "_" + strconv.FormatInt(orgid, 10)
4654
+	fmt.Println("keyFour323223323232323232", keyFour)
4655
+	redis.Set(keyFour, "", time.Second)
4656
+
4657
+	defer redis.Close()
4498 4658
 	if err != nil {
4499 4659
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4500 4660
 		return

+ 32 - 7
controllers/schedule_api_controller.go View File

@@ -372,25 +372,25 @@ func (c *ScheduleApiController) CreateSchedule() {
372 372
 
373 373
 	redis.Set(key, "", time.Second)
374 374
 	//处方
375
-	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
375
+	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
376 376
 	redis.Set(keyOne, "", time.Second)
377 377
 
378 378
 	//医嘱
379
-	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":advice_list_all"
379
+	keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
380 380
 	redis.Set(keyTwo, "", time.Second)
381 381
 
382
-	keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_befores_list_all"
382
+	keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
383 383
 	redis.Set(keySix, "", time.Second)
384
-	keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":assessment_after_dislysis_list_all"
384
+	keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
385 385
 	redis.Set(keyThree, "", time.Second)
386 386
 
387
-	keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":monitor_record_list_all"
387
+	keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
388 388
 	redis.Set(keyFour, "", time.Second)
389 389
 
390
-	keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":treatment_summarys_list_all"
390
+	keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
391 391
 	redis.Set(keyFive, "", time.Second)
392 392
 
393
-	keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":dialysis_orders_list_all"
393
+	keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
394 394
 	redis.Set(keySeven, "", time.Second)
395 395
 	fmt.Println(err)
396 396
 	defer redis.Close()
@@ -436,6 +436,31 @@ func (c *ScheduleApiController) DeleteSchedule() {
436 436
 	schedule.Status = 0
437 437
 	schedule.UpdatedTime = time.Now().Unix()
438 438
 	err = service.UpdateSchedule(schedule)
439
+	redis := service.RedisClient()
440
+
441
+	//处方
442
+	keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
443
+	redis.Set(keyOne, "", time.Second)
444
+
445
+	//医嘱
446
+	keyTwo := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
447
+	redis.Set(keyTwo, "", time.Second)
448
+
449
+	keySix := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
450
+	redis.Set(keySix, "", time.Second)
451
+	keyThree := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
452
+	redis.Set(keyThree, "", time.Second)
453
+
454
+	keyFour := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
455
+	redis.Set(keyFour, "", time.Second)
456
+
457
+	keyFive := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
458
+	redis.Set(keyFive, "", time.Second)
459
+
460
+	keySeven := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
461
+	redis.Set(keySeven, "", time.Second)
462
+	fmt.Println(err)
463
+	defer redis.Close()
439 464
 	if err != nil {
440 465
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
441 466
 		return

+ 2 - 1
controllers/stock_in_api_controller.go View File

@@ -1698,8 +1698,9 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1698 1698
 	if len(upDateWarehouseOutInfos) > 0 {
1699 1699
 		for _, item := range upDateWarehouseOutInfos {
1700 1700
 			fmt.Println("item2332323232323", item.ProductDate, item.ExpiryDate)
1701
+
1701 1702
 			//1.查询该耗材该批次的最后一次出库记录
1702
-			lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId)
1703
+			lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId, item.OrgId)
1703 1704
 
1704 1705
 			// 退库的库存和该耗材该批次最后一次出库数量进行比较
1705 1706
 			//如果退库数量大于 最后一次批次的数量(要么要进行出库)

+ 0 - 1
models/good_models.go View File

@@ -81,7 +81,6 @@ type GoodInfo struct {
81 81
 	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
82 82
 	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
83 83
 	GoodSotckInfo               []*GoodSotckInfo     `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_stock_in"`
84
-	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
85 84
 }
86 85
 
87 86
 func (GoodInfo) TableName() string {

+ 0 - 25
models/his_charge_models.go View File

@@ -204,31 +204,6 @@ func (HisLabelPrintInfo) TableName() string {
204 204
 	return "his_label_print_info"
205 205
 }
206 206
 
207
-type HisLabelPrintInfo struct {
208
-	ID          int64  `gorm:"column:id" json:"id" form:"id"`
209
-	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
210
-	Number      string `gorm:"column:number" json:"number" form:"number"`
211
-	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
212
-	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
213
-	DoctorId    int64  `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
214
-	Status      int64  `gorm:"column:status" json:"status" form:"status"`
215
-	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
216
-	ProjectId   int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
217
-	IsPrint     int64  `gorm:"column:is_print" json:"is_print" form:"is_print"`
218
-	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
219
-	ItemId      int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
220
-	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
221
-	PProjectId  int64  `gorm:"column:p_project_id" json:"p_project_id" form:"p_project_id"`
222
-
223
-	FeedetlSn   string `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
224
-	DoctorName  string `gorm:"column:doctor_name" json:"doctor_name" form:"doctor_name"`
225
-	PatientName string `gorm:"column:patient_name" json:"patient_name" form:"patient_name"`
226
-}
227
-
228
-func (HisLabelPrintInfo) TableName() string {
229
-	return "his_label_print_info"
230
-}
231
-
232 207
 type HisFapiaoRecord struct {
233 208
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
234 209
 	FapiaoCode   string `gorm:"column:fapiao_code" json:"fapiao_code" form:"fapiao_code"`

+ 0 - 47
models/his_models.go View File

@@ -776,10 +776,6 @@ type HisPrescriptionProject struct {
776 776
 
777 777
 	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
778 778
 
779
-	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
780
-	DayCount      int64  `gorm:"column:day_count" json:"day_count" form:"day_count"`
781
-	WeekDay       string `gorm:"column:week_day" json:"week_day" form:"week_day"`
782
-	IsCheckTeam   int64  `gorm:"-" json:"is_check_team" form:"is_check_team"`
783 779
 	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
784 780
 	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
785 781
 	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
@@ -1066,49 +1062,6 @@ func (HisOrderInfoTwo) TableName() string {
1066 1062
 	return "his_order_info"
1067 1063
 }
1068 1064
 
1069
-type HisOrderInfoTwo struct {
1070
-	ID               int64   `gorm:"column:id" json:"id" form:"id"`
1071
-	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
1072
-	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
1073
-	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
1074
-	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
1075
-	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
1076
-	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
1077
-	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1078
-	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
1079
-	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
1080
-	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
1081
-	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
1082
-	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
1083
-	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
1084
-	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
1085
-	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
1086
-	Status           int64   `gorm:"column:status" json:"status" form:"status"`
1087
-	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
1088
-	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
1089
-	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
1090
-	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
1091
-	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
1092
-	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
1093
-	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
1094
-	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
1095
-	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
1096
-	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
1097
-	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1098
-	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
1099
-	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
1100
-	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
1101
-	Type             int64   `gorm:"column:type" json:"type" form:"type"`
1102
-	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
1103
-
1104
-	HisPrescriptionProject HisPrescriptionProject `gorm:"ForeignKey:ID;AssociationForeignKey:ProjectId" json:"project"`
1105
-	HisDoctorAdviceInfo    HisDoctorAdviceInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:AdviceId" json:"advice"`
1106
-}
1107
-
1108
-func (HisOrderInfoTwo) TableName() string {
1109
-	return "his_order_info"
1110
-}
1111
-
1112 1065
 type VMHisPatient struct {
1113 1066
 	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1114 1067
 	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`

+ 134 - 17
models/patient_models.go View File

@@ -309,14 +309,13 @@ type DialysisPrescription struct {
309 309
 	OxygenUptake               int64         `gorm:"column:oxygen_uptake" json:"oxygen_uptake" form:"oxygen_uptake"`
310 310
 	OxygenFlow                 string        `gorm:"column:oxygen_flow" json:"oxygen_flow" form:"oxygen_flow"`
311 311
 	OxygenTime                 string        `gorm:"column:oxygen_time" json:"oxygen_time" form:"oxygen_time"`
312
-
313
-	HemodialysisPipelines      string  `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
314
-	HemodialysisPipelinesCount float64 `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
315
-	PunctureNeedle             string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
316
-	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
317
-	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
318
-	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
319
-	MaxUltrafiltrationRate     float64 `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
312
+	HemodialysisPipelines      string        `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
313
+	HemodialysisPipelinesCount float64       `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
314
+	PunctureNeedle             string        `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
315
+	PunctureNeedleCount        float64       `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
316
+	Epo                        string        `gorm:"column:epo" json:"epo" form:"epo"`
317
+	EpoCount                   float64       `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
318
+	MaxUltrafiltrationRate     float64       `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
320 319
 }
321 320
 
322 321
 func (DialysisPrescription) TableName() string {
@@ -324,24 +323,104 @@ func (DialysisPrescription) TableName() string {
324 323
 }
325 324
 
326 325
 type DialysisPrescriptionList struct {
327
-	ID                         int64   `gorm:"column:id" json:"id"`
328
-	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id"`
329
-	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id"`
330
-	RecordDate                 int64   `gorm:"column:record_date" json:"record_date"`
331
-	RecordId                   int64   `gorm:"column:record_id" json:"record_id"`
332
-	Creater                    int64   `gorm:"column:creater" json:"creater"`
326
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
327
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
328
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
329
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
330
+	MachineType                string  `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
331
+	DewaterAmount              float64 `gorm:"column:dewater_amount" json:"dewater_amount" form:"dewater_amount"`
333 332
 	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
334
-	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration"`
335
-	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
333
+	PrescriptionDewatering     float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering" form:"prescription_dewatering"`
334
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
335
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
336
+	AnticoagulantStopTimeHour  int64   `gorm:"column:anticoagulant_stop_time_hour" json:"anticoagulant_stop_time_hour" form:"anticoagulant_stop_time_hour"`
337
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
338
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
339
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
340
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
341
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
342
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
343
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
344
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
345
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
346
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
347
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
348
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
349
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
350
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
351
+	VascularAccessMode         int64   `gorm:"column:vascular_access_mode" json:"vascular_access_mode" form:"vascular_access_mode"`
352
+	VascularAccess             int64   `gorm:"column:vascular_access" json:"vascular_access" form:"vascular_access"`
353
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
354
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
355
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
356
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
357
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
358
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
359
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
360
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
361
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
362
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
363
+	PrescriptionDoctor         int64   `gorm:"column:prescription_doctor" json:"prescription_doctor" form:"prescription_doctor"`
364
+	Creater                    int64   `gorm:"column:creater" json:"creater" form:"creater"`
365
+	Modifier                   int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
366
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
367
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
368
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
369
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
370
+	RecordDate                 int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
371
+	RecordId                   int64   `gorm:"column:record_id" json:"record_id" form:"record_id"`
372
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
373
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
374
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
375
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
376
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
377
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
378
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
379
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
380
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
381
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
382
+	Niprocart                  int64   `gorm:"column:niprocart" json:"niprocart" form:"niprocart"`
383
+	Jms                        int64   `gorm:"column:jms" json:"jms" form:"jms"`
384
+	FistulaNeedleSet           int64   `gorm:"column:fistula_needle_set" json:"fistula_needle_set" form:"fistula_needle_set"`
385
+	FistulaNeedleSet16         int64   `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16" form:"fistula_needle_set_16"`
386
+	Hemoperfusion              int64   `gorm:"column:hemoperfusion" json:"hemoperfusion" form:"hemoperfusion"`
387
+	DialyserSterilised         int64   `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised" form:"dialyser_sterilised"`
388
+	Filtryzer                  int64   `gorm:"column:filtryzer" json:"filtryzer" form:"filtryzer"`
389
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
390
+	Dialyzers                  int64   `gorm:"column:dialyzers" json:"dialyzers" form:"dialyzers"`
391
+	Injector                   int64   `gorm:"column:injector" json:"injector" form:"injector"`
392
+	Bloodlines                 int64   `gorm:"column:bloodlines" json:"bloodlines" form:"bloodlines"`
393
+	TubingHemodialysis         int64   `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis" form:"tubing_hemodialysis"`
394
+	Package                    int64   `gorm:"column:package" json:"package" form:"package"`
395
+	ALiquid                    int64   `gorm:"column:a_liquid" json:"a_liquid" form:"a_liquid"`
396
+	PreImpulse                 float64 `gorm:"column:pre_impulse" json:"pre_impulse" form:"pre_impulse"`
397
+	AnticoagulantStopTimeMin   int64   `gorm:"column:anticoagulant_stop_time_min" json:"anticoagulant_stop_time_min" form:"anticoagulant_stop_time_min"`
398
+	HeparinSodium              string  `gorm:"column:heparin_sodium" json:"heparin_sodium" form:"heparin_sodium"`
399
+	Nucleoprotamine            string  `gorm:"column:nucleoprotamine" json:"nucleoprotamine" form:"nucleoprotamine"`
400
+	PushTheProtamine           string  `gorm:"column:push_the_protamine" json:"push_the_protamine" form:"push_the_protamine"`
401
+	NoHeparinRemarks           string  `gorm:"column:no_heparin_remarks" json:"no_heparin_remarks" form:"no_heparin_remarks"`
402
+	Blood                      string  `gorm:"column:blood" json:"blood" form:"blood"`
336 403
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
337 404
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
338
-	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
405
+	AntioxidantCommodityName   string  `gorm:"column:antioxidant_commodity_name" json:"antioxidant_commodity_name" form:"antioxidant_commodity_name"`
406
+	DisplaceSpeed              string  `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
407
+	Illness                    int64   `gorm:"column:illness" json:"illness" form:"illness"`
408
+	Amylaceum                  string  `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
409
+	SingleTime                 string  `gorm:"column:single_time" json:"single_time" form:"single_time"`
410
+	SingleWater                string  `gorm:"column:single_water" json:"single_water" form:"single_water"`
411
+	ReplacementFlow            string  `gorm:"column:replacement_flow" json:"replacement_flow" form:"replacement_flow"`
412
+	PlasmaSeparator            string  `gorm:"column:plasma_separator" json:"plasma_separator" form:"plasma_separator"`
413
+	BilirubinAdsorptionColumn  string  `gorm:"column:bilirubin_adsorption_column" json:"bilirubin_adsorption_column" form:"bilirubin_adsorption_column"`
414
+	OxygenUptake               int64   `gorm:"column:oxygen_uptake" json:"oxygen_uptake" form:"oxygen_uptake"`
415
+	OxygenFlow                 string  `gorm:"column:oxygen_flow" json:"oxygen_flow" form:"oxygen_flow"`
416
+	OxygenTime                 string  `gorm:"column:oxygen_time" json:"oxygen_time" form:"oxygen_time"`
339 417
 	HemodialysisPipelines      string  `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
340 418
 	HemodialysisPipelinesCount float64 `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
341 419
 	PunctureNeedle             string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
342 420
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
343 421
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
344 422
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
423
+	MaxUltrafiltrationRate     string  `gorm:"column:max_ultrafiltration_rate" json:"max_ultrafiltration_rate" form:"max_ultrafiltration_rate"`
345 424
 }
346 425
 
347 426
 func (DialysisPrescriptionList) TableName() string {
@@ -1388,3 +1467,41 @@ type MsDeviceZone struct {
1388 1467
 func (MsDeviceZone) TableName() string {
1389 1468
 	return "xt_device_zone"
1390 1469
 }
1470
+
1471
+type XtHospitalSummary struct {
1472
+	ID                       int64  `gorm:"column:id" json:"id" form:"id"`
1473
+	PatientId                int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
1474
+	AdmissionTime            int64  `gorm:"column:admission_time" json:"admission_time" form:"admission_time"`
1475
+	DischargeTime            int64  `gorm:"column:discharge_time" json:"discharge_time" form:"discharge_time"`
1476
+	SickPersonnel            string `gorm:"column:sick_personnel" json:"sick_personnel" form:"sick_personnel"`
1477
+	Xray                     string `gorm:"column:xray" json:"xray" form:"xray"`
1478
+	Connecticut              string `gorm:"column:connecticut" json:"connecticut" form:"connecticut"`
1479
+	NuclearMagneticResonance string `gorm:"column:nuclear_magnetic_resonance" json:"nuclear_magnetic_resonance" form:"nuclear_magnetic_resonance"`
1480
+	Ultrasound               string `gorm:"column:ultrasound" json:"ultrasound" form:"ultrasound"`
1481
+	Pathology                string `gorm:"column:pathology" json:"pathology" form:"pathology"`
1482
+	AdmittingDiagnosisId     string `gorm:"column:admitting_diagnosis_id" json:"admitting_diagnosis_id" form:"admitting_diagnosis_id"`
1483
+	AdmittingDiagnosis       string `gorm:"column:admitting_diagnosis" json:"admitting_diagnosis" form:"admitting_diagnosis"`
1484
+	DischargeDiagnosisId     string `gorm:"column:discharge_diagnosis_id" json:"discharge_diagnosis_id" form:"discharge_diagnosis_id"`
1485
+	DischargeDiagnosis       string `gorm:"column:discharge_diagnosis" json:"discharge_diagnosis" form:"discharge_diagnosis"`
1486
+	DiagnosisAdmissionId     string `gorm:"column:diagnosis_admission_id" json:"diagnosis_admission_id" form:"diagnosis_admission_id"`
1487
+	DiagnosisAdmission       string `gorm:"column:diagnosis_admission" json:"diagnosis_admission" form:"diagnosis_admission"`
1488
+	TreatmentId              string `gorm:"column:treatment_id" json:"treatment_id" form:"treatment_id"`
1489
+	Treatment                string `gorm:"column:treatment" json:"treatment" form:"treatment"`
1490
+	IllnessDischargeId       string `gorm:"column:illness_discharge_id" json:"illness_discharge_id" form:"illness_discharge_id"`
1491
+	IllnessDischarge         string `gorm:"column:illness_discharge" json:"illness_discharge" form:"illness_discharge"`
1492
+	DischargeAdviceId        string `gorm:"column:discharge_advice_id" json:"discharge_advice_id" form:"discharge_advice_id"`
1493
+	DischargeAdvice          string `gorm:"column:discharge_advice" json:"discharge_advice" form:"discharge_advice"`
1494
+	UserOrgId                int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1495
+	Status                   int64  `gorm:"column:status" json:"status" form:"status"`
1496
+	Ctime                    int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
1497
+	Mtime                    int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
1498
+	RecordTime               int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
1499
+	Title                    string `gorm:"column:title" json:"title" form:"title"`
1500
+	Doctor                   int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
1501
+	RecordDate               int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
1502
+	DeanId                   int64  `gorm:"column:dean_id" json:"dean_id" form:"dean_id"`
1503
+}
1504
+
1505
+func (XtHospitalSummary) TableName() string {
1506
+	return "xt_hospital_summary"
1507
+}

+ 0 - 19
models/stock_models.go View File

@@ -1145,22 +1145,3 @@ type PatientWarehouseInfo struct {
1145 1145
 func (PatientWarehouseInfo) TableName() string {
1146 1146
 	return "xt_warehouse_info"
1147 1147
 }
1148
-
1149
-type PatientWarehouseInfo struct {
1150
-	ID                int64  `gorm:"column:id" json:"id" form:"id"`
1151
-	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1152
-	Number            string `gorm:"column:number" json:"number" form:"number"`
1153
-	ProductDate       int64  `gorm:"column:product_date" json:"product_date" form:"product_date"`
1154
-	ExpiryDate        int64  `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1155
-	WarehousingUnit   string `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1156
-	Dealer            int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1157
-	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1158
-	GoodName          string `gorm:"column:good_name" json:"good_name"`
1159
-	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1160
-	PackingUnit       string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1161
-	Remark            string `gorm:"column:remark" json:"remark" form:"remark"`
1162
-}
1163
-
1164
-func (PatientWarehouseInfo) TableName() string {
1165
-	return "xt_warehouse_info"
1166
-}

+ 15 - 4
service/dialysis_service.go View File

@@ -274,7 +274,12 @@ func AddSigleDoubleCheck(check *models.DoubleCheck) (err error) {
274 274
 
275 275
 //修改透析处方
276 276
 func UpDateDialysisPrescription(dialysisPrescription *models.DialysisPrescription) error {
277
+	tx := writeDb.Begin()
277 278
 	err := writeDb.Save(&dialysisPrescription).Error
279
+	if err != nil {
280
+		tx.Rollback()
281
+	}
282
+	tx.Commit()
278 283
 	return err
279 284
 }
280 285
 
@@ -1370,6 +1375,11 @@ func ModifyExceDoctorAdviceById(m *models.HisDoctorAdviceInfo, ids []string) (er
1370 1375
 	return err
1371 1376
 }
1372 1377
 
1378
+func FindHisDoctorAdviceByIdOne(orgID int64, ids []string) (advice []models.HisDoctorAdviceInfo, err error) {
1379
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("id IN (?) AND user_org_id = ? AND status = 1", ids, orgID).Find(&advice).Error
1380
+	return
1381
+}
1382
+
1373 1383
 func ModifyHisPrescriptionProject(m *models.HisPrescriptionProject, ids []string) (err error) {
1374 1384
 	ut := writeDb.Begin()
1375 1385
 	err = ut.Model(&models.HisPrescriptionProject{}).Where("status = 1   AND id IN (?) AND execution_state = 1", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
@@ -1438,7 +1448,8 @@ func GetAllPcPatientListByList(orgID int64) (patients []*MSchedualPatientVMList,
1438 1448
 func GetAllPcAdvicestByList(orgID int64, scheduleDate int64) (advices []*VMDoctorAdvice, err error) {
1439 1449
 	redis := RedisClient()
1440 1450
 	defer redis.Close()
1441
-	key := strconv.FormatInt(orgID, 10) + ":" + ":advice_list_all"
1451
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":advice_list_all"
1452
+
1442 1453
 	advice_list_str, _ := redis.Get(key).Result()
1443 1454
 
1444 1455
 	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -1478,7 +1489,7 @@ func GetAllPcAdvicestByList(orgID int64, scheduleDate int64) (advices []*VMDocto
1478 1489
 func GetAllPcDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVMList, err error) {
1479 1490
 	redis := RedisClient()
1480 1491
 	defer redis.Close()
1481
-	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
1492
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
1482 1493
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
1483 1494
 
1484 1495
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -1516,7 +1527,7 @@ func GetAllPcDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrde
1516 1527
 func GetAllPcAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*AssessmentAfterDislysis, err error) {
1517 1528
 	redis := RedisClient()
1518 1529
 	defer redis.Close()
1519
-	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
1530
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_after_dislysis_list_all"
1520 1531
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
1521 1532
 
1522 1533
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -1556,7 +1567,7 @@ func GetAllPcAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (ass
1556 1567
 func GetAllPcTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*VMTreatmentSummary, err error) {
1557 1568
 	redis := RedisClient()
1558 1569
 	defer redis.Close()
1559
-	key := strconv.FormatInt(orgID, 10) + ":" + ":treatment_summarys_list_all"
1570
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":treatment_summarys_list_all"
1560 1571
 	treatment_summarys_all, _ := redis.Get(key).Result()
1561 1572
 
1562 1573
 	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis

+ 4 - 4
service/gobal_config_service.go View File

@@ -590,7 +590,7 @@ func GetDrugStockList(page int64, limit int64, keyword string, drugcategory int6
590 590
 func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (drug []*models.VmBaseDrug, total int64, err error) {
591 591
 
592 592
 	offset := (page - 1) * limit
593
-	db := readDb2.Table("xt_base_drug").Where("status = 1")
593
+	db := XTReadDB().Table("xt_base_drug").Where("status = 1")
594 594
 	likeKey := "%" + keyword + "%"
595 595
 	if orgid > 0 {
596 596
 		db = db.Where("org_id = ?", orgid)
@@ -727,7 +727,7 @@ func GetMinCountList(startime int64, endtime int64, orgid int64) (info []*models
727 727
 }
728 728
 
729 729
 func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseInfo, err error) {
730
-	db := readDb2.Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
730
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
731 731
 
732 732
 	if startime > 0 {
733 733
 		db = db.Where("x.ctime >=?", startime)
@@ -743,7 +743,7 @@ func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*mo
743 743
 }
744 744
 
745 745
 func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugAutomaticReduceDetail, err error) {
746
-	db := readDb2.Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
746
+	db := XTReadDB().Table("xt_drug_automatic_reduce_detail as x").Where("x.status = 1")
747 747
 
748 748
 	if startime > 0 {
749 749
 		db = db.Where("x.record_time >=?", startime)
@@ -761,7 +761,7 @@ func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*m
761 761
 
762 762
 func GetCancelDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
763 763
 
764
-	db := readDb2.Table(" xt_drug_cancel_stock_info as x").Where("x.status = 1")
764
+	db := XTReadDB().Table(" xt_drug_cancel_stock_info as x").Where("x.status = 1")
765 765
 
766 766
 	if startime > 0 {
767 767
 		db = db.Where("x.ctime >=?", startime)

+ 22 - 0
service/manage_center_service.go View File

@@ -173,6 +173,28 @@ func FindBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err
173 173
 	return
174 174
 }
175 175
 
176
+func GetDrugAutoWarehouseOut(patient_id int64, advicedate int64, drugid int64) (*models.DrugWarehouseOutInfo, error) {
177
+	detail := models.DrugWarehouseOutInfo{}
178
+	err := XTReadDB().Model(&detail).Where("patient_id = ? and sys_record_time =? and drug_id = ? and status = 1", patient_id, advicedate, drugid).Find(&detail).Error
179
+	if err == gorm.ErrRecordNotFound {
180
+		return nil, err
181
+	}
182
+	if err != nil {
183
+		return nil, err
184
+	}
185
+	return &detail, nil
186
+}
187
+
188
+func UpdateDrugWarehouse(id int64, info models.DrugWarehouseInfo) error {
189
+	err := writeDb.Model(&models.DrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", info.StockMinNumber)).Error
190
+	return err
191
+}
192
+
193
+func UpdateDrugWarehouseOne(id int64, info models.DrugWarehouseInfo) error {
194
+	err := writeDb.Model(&models.DrugWarehouseInfo{}).Where("id = ?", id).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", info.StockMaxNumber)).Error
195
+	return err
196
+}
197
+
176 198
 func GetBaseDrugLibList(org_id int64, keyword string, page int64, limit int64, is_use int64, is_charge int64, is_inject int64, manufacturer int64, isRecord int64) (list []*models.BaseDrugLib, total int64, err error) {
177 199
 
178 200
 	db := readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id)

+ 101 - 47
service/mobile_dialysis_service.go View File

@@ -590,6 +590,21 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
590 590
 	}
591 591
 }
592 592
 
593
+// 透前评估
594
+func MobileGetPredialysisEvaluationOne(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
595
+	fmt.Println("recordDate", recordDate)
596
+	var record models.PredialysisEvaluation
597
+	err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date = ?", patientID, orgID, recordDate).First(&record).Error
598
+	if err != nil {
599
+		if err == gorm.ErrRecordNotFound {
600
+			return nil, nil
601
+		} else {
602
+			return nil, err
603
+		}
604
+	}
605
+	return &record, nil
606
+}
607
+
593 608
 // 透前评估
594 609
 func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
595 610
 
@@ -632,6 +647,20 @@ func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int
632 647
 	}
633 648
 }
634 649
 
650
+// 获取 maxDate 之前一次的透前评估记录
651
+func MobileGetLastTimePredialysisEvaluationOne(orgID int64, patientID int64, maxDate int64) (*models.PredialysisEvaluation, error) {
652
+	var record models.PredialysisEvaluation
653
+	err := readDb.Model(&models.PredialysisEvaluation{}).Where("patient_id = ? and user_org_id = ? and status = 1 and assessment_date < ?", patientID, orgID, maxDate).Order("assessment_date desc").First(&record).Error
654
+	if err != nil {
655
+		if err == gorm.ErrRecordNotFound {
656
+			return nil, nil
657
+		} else {
658
+			return nil, err
659
+		}
660
+	}
661
+	return &record, nil
662
+}
663
+
635 664
 // 获取 maxDate 之前一次的透前评估记录
636 665
 func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDate int64) (*models.PredialysisEvaluation, error) {
637 666
 	var record models.PredialysisEvaluation
@@ -701,9 +730,9 @@ func MobileGetDoctorAdvicesByGroups(orgID int64, patientID int64, recordDate int
701 730
 
702 731
 	// cur_date := time.Now().Format("2006-01-02")
703 732
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
704
-	fmt.Println("医嘱keyh23232323223", key)
733
+
705 734
 	doctor_advices_str, _ := redis.Get(key).Result()
706
-	fmt.Println("长度hh2332233232233232", len(doctor_advices_str))
735
+
707 736
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
708 737
 		err := readDb.Model(&models.DoctorAdvice{}).
709 738
 			Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
@@ -837,7 +866,7 @@ func MobileGetMonitorRecords(orgID int64, patientID int64, recordDate int64) ([]
837 866
 	// cur_date := time.Now().Format("2006-01-02")
838 867
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
839 868
 	monitor_records_str, _ := redis.Get(key).Result()
840
-	fmt.Println("监测23323232323233232", len(monitor_records_str))
869
+
841 870
 	if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
842 871
 		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
843 872
 		if err != nil {
@@ -881,6 +910,19 @@ func MobileGetMonitorRecordFirst(orgID int64, patientID int64, recordDate int64)
881 910
 	return &records, nil
882 911
 }
883 912
 
913
+func MobileGetLastMonitorRecordOne(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
914
+	var record models.MonitoringRecord
915
+	err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, beforeDate).Order("operate_time desc").First(&record).Error
916
+	if err != nil {
917
+		if err == gorm.ErrRecordNotFound {
918
+			return nil, nil
919
+		} else {
920
+			return nil, err
921
+		}
922
+	}
923
+	return &record, nil
924
+}
925
+
884 926
 func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
885 927
 	var record models.MonitoringRecord
886 928
 	redis := RedisClient()
@@ -1057,7 +1099,7 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
1057 1099
 		if err != nil {
1058 1100
 			if err == gorm.ErrRecordNotFound {
1059 1101
 				if record.ID <= 0 {
1060
-					fmt.Println("创建成功没有", treatment_summary_str)
1102
+
1061 1103
 					redis.Set(key, "null", time.Second*60*60*18)
1062 1104
 				}
1063 1105
 				return nil, nil
@@ -1090,7 +1132,7 @@ func MobileGetTreatmentSummary(orgID int64, patientID int64, recordDate int64) (
1090 1132
 // 透析处方
1091 1133
 func MobileGetDialysisPrescribe(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
1092 1134
 	var record models.DialysisPrescription
1093
-	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
1135
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).Find(&record).Error
1094 1136
 	if err != nil {
1095 1137
 		if err == gorm.ErrRecordNotFound {
1096 1138
 			return nil, nil
@@ -1955,7 +1997,6 @@ func MobileGetLastDryWeight(orgID int64, patientID int64) (*models.SgjPatientDry
1955 1997
 	redis := RedisClient()
1956 1998
 	defer redis.Close()
1957 1999
 
1958
-	// cur_date := time.Now().Format("2006-01-02")
1959 2000
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":last_dry_weight"
1960 2001
 	last_dry_weight_str, _ := redis.Get(key).Result()
1961 2002
 
@@ -2100,52 +2141,65 @@ func MobileGetDialysisPrescribeByModeId(orgID int64, patientID int64, recordDate
2100 2141
 
2101 2142
 func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
2102 2143
 	var record models.DialysisPrescription
2103
-	redis := RedisClient()
2104
-	defer redis.Close()
2105
-
2106
-	// cur_date := time.Now().Format("2006-01-02")
2107
-	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_prescribe_by_mode"
2108
-	dialysis_prescribe_by_mode_str, _ := redis.Get(key).Result()
2109
-
2110
-	if len(dialysis_prescribe_by_mode_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2111
-		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
2112
-		if err != nil {
2113
-			if err == gorm.ErrRecordNotFound {
2114
-				if record.ID <= 0 {
2115
-					redis.Set(key, "null", time.Second*60*60*18)
2116
-				}
2117
-				return nil, nil
2118
-			} else {
2119
-				return nil, err
2120
-			}
2121
-		} else {
2122
-
2123
-			if record.ID > 0 {
2124
-				//缓存数据
2125
-				dialysis_prescribe_by_mode_str, err := json.Marshal(record)
2126
-
2127
-				if err == nil {
2128
-					redis.Set(key, dialysis_prescribe_by_mode_str, time.Second*60*60*18)
2129
-					return nil, err
2130
-				}
2131
-			} else {
2132
-				redis.Set(key, "null", time.Second*60*60*18)
2133
-				return nil, err
2134
-			}
2135
-			return &record, nil
2136
-		}
2137
-	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2138
-		if dialysis_prescribe_by_mode_str == "null" {
2139
-			json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
2140
-			return &record, nil
2144
+	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
2145
+	if err != nil {
2146
+		if err == gorm.ErrRecordNotFound {
2147
+			return nil, nil
2141 2148
 		} else {
2142
-			json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
2143
-			return &record, nil
2149
+			return nil, err
2144 2150
 		}
2145
-
2146 2151
 	}
2152
+	return &record, nil
2147 2153
 }
2148 2154
 
2155
+//func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
2156
+//	var record models.DialysisPrescription
2157
+//	redis := RedisClient()
2158
+//	defer redis.Close()
2159
+//
2160
+//	// cur_date := time.Now().Format("2006-01-02")
2161
+//	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":dialysis_prescribe_by_mode"
2162
+//	dialysis_prescribe_by_mode_str, _ := redis.Get(key).Result()
2163
+//
2164
+//	if len(dialysis_prescribe_by_mode_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2165
+//		err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
2166
+//		if err != nil {
2167
+//			if err == gorm.ErrRecordNotFound {
2168
+//				if record.ID <= 0 {
2169
+//					redis.Set(key, "null", time.Second*60*60*18)
2170
+//				}
2171
+//				return nil, nil
2172
+//			} else {
2173
+//				return nil, err
2174
+//			}
2175
+//		} else {
2176
+//
2177
+//			if record.ID > 0 {
2178
+//				//缓存数据
2179
+//				dialysis_prescribe_by_mode_str, err := json.Marshal(record)
2180
+//
2181
+//				if err == nil {
2182
+//					redis.Set(key, dialysis_prescribe_by_mode_str, time.Second*60*60*18)
2183
+//					return nil, err
2184
+//				}
2185
+//			} else {
2186
+//				redis.Set(key, "null", time.Second*60*60*18)
2187
+//				return nil, err
2188
+//			}
2189
+//			return &record, nil
2190
+//		}
2191
+//	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2192
+//		if dialysis_prescribe_by_mode_str == "null" {
2193
+//			json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
2194
+//			return &record, nil
2195
+//		} else {
2196
+//			json.Unmarshal([]byte(dialysis_prescribe_by_mode_str), &record)
2197
+//			return &record, nil
2198
+//		}
2199
+//
2200
+//	}
2201
+//}
2202
+
2149 2203
 func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.DialysisPrescription, error) {
2150 2204
 	var record models.DialysisPrescription
2151 2205
 	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 ", patientID, orgID).Last(&record).Error

+ 591 - 10
service/patient_service.go View File

@@ -162,7 +162,7 @@ func GetAllDevicetByList(orgID int64) (devices []*models.MDeviceNumberForList, e
162 162
 func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMDoctorAdviceForList, err error) {
163 163
 	redis := RedisClient()
164 164
 	defer redis.Close()
165
-	key := strconv.FormatInt(orgID, 10) + ":" + ":advice_list_all"
165
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":advice_list_all"
166 166
 	advice_list_str, _ := redis.Get(key).Result()
167 167
 
168 168
 	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -202,9 +202,9 @@ func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMD
202 202
 func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
203 203
 	redis := RedisClient()
204 204
 	defer redis.Close()
205
-	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
205
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
206 206
 	prescriptions_list_all, _ := redis.Get(key).Result()
207
-	fmt.Println("铲毒23322332323232323", len(prescriptions_list_all))
207
+
208 208
 	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
209 209
 		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
210 210
 		if err != nil {
@@ -242,7 +242,7 @@ func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions [
242 242
 func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluationList, err error) {
243 243
 	redis := RedisClient()
244 244
 	defer redis.Close()
245
-	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_befores_list_all"
245
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_befores_list_all"
246 246
 	assessment_befores_list_all, _ := redis.Get(key).Result()
247 247
 
248 248
 	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -282,9 +282,9 @@ func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentB
282 282
 func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
283 283
 	redis := RedisClient()
284 284
 	defer redis.Close()
285
-	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
285
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
286 286
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
287
-	fmt.Println("dialysis_orders_list_all23323223232323323232332", len(dialysis_orders_list_all))
287
+
288 288
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
289 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
290 290
 
@@ -320,7 +320,7 @@ func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders
320 320
 func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*models.VMTreatmentSummaryForList, err error) {
321 321
 	redis := RedisClient()
322 322
 	defer redis.Close()
323
-	key := strconv.FormatInt(orgID, 10) + ":" + ":treatment_summarys_list_all"
323
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":treatment_summarys_list_all"
324 324
 	treatment_summarys_all, _ := redis.Get(key).Result()
325 325
 
326 326
 	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -359,7 +359,7 @@ func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSu
359 359
 func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.VMAssessmentAfterDislysis, err error) {
360 360
 	redis := RedisClient()
361 361
 	defer redis.Close()
362
-	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
362
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_after_dislysis_list_all"
363 363
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
364 364
 
365 365
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
@@ -399,9 +399,9 @@ func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (asses
399 399
 func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHisDoctorAdviceInfo, err error) {
400 400
 	redis := RedisClient()
401 401
 	defer redis.Close()
402
-	key := strconv.FormatInt(orgID, 10) + ":" + ":his_advices_list_all"
402
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":his_advices_list_all"
403 403
 	his_advices_all, _ := redis.Get(key).Result()
404
-
404
+	fmt.Println("hish233232222332232323232323", len(his_advices_all))
405 405
 	if len(his_advices_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
406 406
 		err = readDb.Model(&VMHisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).Find(&hisAdvices).Error
407 407
 		if err != nil {
@@ -1958,3 +1958,584 @@ func GetDoctorAdviceListFour(orgID int64, patientID int64, advice_type int64, st
1958 1958
 	return
1959 1959
 
1960 1960
 }
1961
+
1962
+func GetAllDeviceNumberByList(orgID int64) (number []*models.DeviceNumber, err error) {
1963
+	redis := RedisClient()
1964
+	defer redis.Close()
1965
+	key := strconv.FormatInt(orgID, 10) + ":" + ":device_number_all"
1966
+	number_info_str, _ := redis.Get(key).Result()
1967
+	if len(number_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1968
+		err = readDb.Model(&models.DeviceNumber{}).Where("org_id=? and status=1", orgID).Find(&number).Error
1969
+		if err != nil {
1970
+			if err == gorm.ErrRecordNotFound {
1971
+				return nil, nil
1972
+			} else {
1973
+				return nil, err
1974
+			}
1975
+		} else {
1976
+			if len(number) > 0 {
1977
+				//缓存数据
1978
+				device_number_json, err := json.Marshal(&number)
1979
+				if err == nil {
1980
+					redis.Set(key, device_number_json, time.Second*60*60*18)
1981
+				}
1982
+			}
1983
+			return number, nil
1984
+		}
1985
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
1986
+		json.Unmarshal([]byte(number_info_str), &number)
1987
+		return number, nil
1988
+	}
1989
+}
1990
+
1991
+func GetAllPrescriptionByListTwo(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescription, err error) {
1992
+
1993
+	redis := RedisClient()
1994
+	defer redis.Close()
1995
+	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
1996
+	prescriptions_list_all, _ := redis.Get(key).Result()
1997
+
1998
+	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1999
+		err = readDb.Model(&models.DialysisPrescription{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2000
+		if err != nil {
2001
+			if err == gorm.ErrRecordNotFound {
2002
+				return nil, nil
2003
+			} else {
2004
+				return nil, err
2005
+			}
2006
+		} else {
2007
+			if len(prescriptions) > 0 {
2008
+				//缓存数据
2009
+				prescriptions_list_all, err := json.Marshal(&prescriptions)
2010
+				if err == nil {
2011
+					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
2012
+				}
2013
+			}
2014
+			return prescriptions, nil
2015
+		}
2016
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2017
+		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
2018
+		return prescriptions, nil
2019
+	}
2020
+}
2021
+
2022
+func GetAllAssessmentBeforesByListThree(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluation, err error) {
2023
+	redis := RedisClient()
2024
+	defer redis.Close()
2025
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_befores_list_all"
2026
+	assessment_befores_list_all, _ := redis.Get(key).Result()
2027
+
2028
+	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2029
+		err = readDb.Model(&models.PredialysisEvaluation{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
2030
+		if err != nil {
2031
+			if err == gorm.ErrRecordNotFound {
2032
+				return nil, nil
2033
+			} else {
2034
+				return nil, err
2035
+			}
2036
+		} else {
2037
+			if len(assessmentBefores) > 0 {
2038
+				//缓存数据
2039
+				assessment_befores_list_all, err := json.Marshal(&assessmentBefores)
2040
+				if err == nil {
2041
+					redis.Set(key, assessment_befores_list_all, time.Second*60*60*18)
2042
+				}
2043
+			}
2044
+			return assessmentBefores, nil
2045
+		}
2046
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2047
+		json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)
2048
+		return assessmentBefores, nil
2049
+	}
2050
+}
2051
+
2052
+func GetAllDialysisOrdersByListThree(orgID int64, scheduleDate int64) (dialysisOrders []*models.MonitorDialysisOrder, err error) {
2053
+	redis := RedisClient()
2054
+	defer redis.Close()
2055
+	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
2056
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
2057
+
2058
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2059
+		err = readDb.Model(&models.MonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2060
+		if err != nil {
2061
+			if err == gorm.ErrRecordNotFound {
2062
+				return nil, nil
2063
+			} else {
2064
+				return nil, err
2065
+			}
2066
+		} else {
2067
+			if len(dialysisOrders) > 0 {
2068
+				//缓存数据
2069
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
2070
+				if err == nil {
2071
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
2072
+				}
2073
+			}
2074
+			return dialysisOrders, nil
2075
+		}
2076
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2077
+		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
2078
+		return dialysisOrders, nil
2079
+	}
2080
+}
2081
+
2082
+func GetAllAssessmentAfterDislysisByListThree(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.AssessmentAfterDislysis, err error) {
2083
+	redis := RedisClient()
2084
+	defer redis.Close()
2085
+	key := strconv.FormatInt(orgID, 10) + ":" + ":assessment_after_dislysis_list_all"
2086
+	assessment_after_dislysis__all, _ := redis.Get(key).Result()
2087
+
2088
+	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2089
+		err = readDb.Model(&models.AssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
2090
+		if err != nil {
2091
+			if err == gorm.ErrRecordNotFound {
2092
+				return nil, nil
2093
+			} else {
2094
+				return nil, err
2095
+			}
2096
+		} else {
2097
+			if len(assessmentAfterDislysis) > 0 {
2098
+				//缓存数据
2099
+				assessment_after_dislysis__all, err := json.Marshal(&assessmentAfterDislysis)
2100
+				if err == nil {
2101
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2102
+				}
2103
+			}
2104
+			return assessmentAfterDislysis, nil
2105
+		}
2106
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2107
+		json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
2108
+		return assessmentAfterDislysis, nil
2109
+	}
2110
+}
2111
+
2112
+func GetAllMonitorListThree(orgID int64, scheduleDate int64) (monitor []*models.MonitoringRecord, err error) {
2113
+
2114
+	redis := RedisClient()
2115
+	defer redis.Close()
2116
+	key := strconv.FormatInt(orgID, 10) + ":" + ":monitor_record_list_all"
2117
+	monitor_record_list_all, _ := redis.Get(key).Result()
2118
+
2119
+	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2120
+		err = readDb.Model(&models.MonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2121
+		if err != nil {
2122
+			if err == gorm.ErrRecordNotFound {
2123
+				return nil, nil
2124
+			} else {
2125
+				return nil, err
2126
+			}
2127
+		} else {
2128
+			if len(monitor) > 0 {
2129
+				//缓存数据
2130
+				assessment_after_dislysis__all, err := json.Marshal(&monitor)
2131
+				if err == nil {
2132
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2133
+				}
2134
+			}
2135
+			return monitor, nil
2136
+		}
2137
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2138
+		json.Unmarshal([]byte(monitor_record_list_all), &monitor)
2139
+		return monitor, nil
2140
+	}
2141
+}
2142
+
2143
+func GetAllPatientListByListThree(orgID int64) (patients []*models.MonitorPatients, err error) {
2144
+	redis := RedisClient()
2145
+	defer redis.Close()
2146
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2147
+	patient_info_str, _ := redis.Get(key).Result()
2148
+
2149
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2150
+		err = readDb.Model(&models.MonitorPatients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2151
+		if err != nil {
2152
+			if err == gorm.ErrRecordNotFound {
2153
+				return nil, nil
2154
+			} else {
2155
+				return nil, err
2156
+			}
2157
+		} else {
2158
+			if len(patients) > 0 {
2159
+				//缓存数据
2160
+				patient_info_json, err := json.Marshal(&patients)
2161
+				if err == nil {
2162
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2163
+				}
2164
+			}
2165
+			return patients, nil
2166
+		}
2167
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2168
+		json.Unmarshal([]byte(patient_info_str), &patients)
2169
+		return patients, nil
2170
+	}
2171
+}
2172
+
2173
+func GetAllDialysisOrdersByListTwo(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVM, err error) {
2174
+	redis := RedisClient()
2175
+	defer redis.Close()
2176
+	key := strconv.FormatInt(orgID, 10) + ":" + ":dialysis_orders_list_all"
2177
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
2178
+
2179
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2180
+		err = readDb.Model(&MDialysisOrderVM{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2181
+		if err != nil {
2182
+			if err == gorm.ErrRecordNotFound {
2183
+				return nil, nil
2184
+			} else {
2185
+				return nil, err
2186
+			}
2187
+		} else {
2188
+			if len(dialysisOrders) > 0 {
2189
+				//缓存数据
2190
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
2191
+				if err == nil {
2192
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
2193
+				}
2194
+			}
2195
+			return dialysisOrders, nil
2196
+		}
2197
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2198
+		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
2199
+		return dialysisOrders, nil
2200
+	}
2201
+}
2202
+
2203
+func GetAllZoneByList(orgID int64) (zone []*models.DeviceZone, err error) {
2204
+
2205
+	redis := RedisClient()
2206
+	defer redis.Close()
2207
+	key := strconv.FormatInt(orgID, 10) + ":" + ":device_zone_all"
2208
+	zone_info_str, _ := redis.Get(key).Result()
2209
+	if len(zone_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2210
+		err = readDb.Model(&models.DeviceZone{}).Where("org_id=? and status=1", orgID).Find(&zone).Error
2211
+		if err != nil {
2212
+			if err == gorm.ErrRecordNotFound {
2213
+				return nil, nil
2214
+			} else {
2215
+				return nil, err
2216
+			}
2217
+		} else {
2218
+			if len(zone) > 0 {
2219
+				//缓存数据
2220
+				zone_number_json, err := json.Marshal(&zone)
2221
+				if err == nil {
2222
+					redis.Set(key, zone_number_json, time.Second*60*60*18)
2223
+				}
2224
+			}
2225
+			return zone, nil
2226
+		}
2227
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2228
+		json.Unmarshal([]byte(zone_info_str), &zone)
2229
+		return zone, nil
2230
+	}
2231
+}
2232
+
2233
+func GetAllPrescriptionByList(orgID int64, scheduleDate int64) (prescriptions []*models.VMDialysisPrescription, err error) {
2234
+
2235
+	redis := RedisClient()
2236
+	defer redis.Close()
2237
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":prescriptions_list_all"
2238
+	prescriptions_list_all, _ := redis.Get(key).Result()
2239
+
2240
+	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2241
+		err = readDb.Model(&models.VMDialysisPrescription{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2242
+		if err != nil {
2243
+			if err == gorm.ErrRecordNotFound {
2244
+				return nil, nil
2245
+			} else {
2246
+				return nil, err
2247
+			}
2248
+		} else {
2249
+			if len(prescriptions) > 0 {
2250
+				//缓存数据
2251
+				prescriptions_list_all, err := json.Marshal(&prescriptions)
2252
+				if err == nil {
2253
+					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
2254
+				}
2255
+			}
2256
+			return prescriptions, nil
2257
+		}
2258
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2259
+		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
2260
+		return prescriptions, nil
2261
+	}
2262
+}
2263
+
2264
+func GetAllAssessmentBeforesByListOne(orgID int64, scheduleDate int64) (assessmentBefores []*models.VMPredialysisEvaluation, err error) {
2265
+	redis := RedisClient()
2266
+	defer redis.Close()
2267
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_befores_list_all"
2268
+	assessment_befores_list_all, _ := redis.Get(key).Result()
2269
+
2270
+	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2271
+		err = readDb.Model(&models.VMPredialysisEvaluation{}).Where("status = 1 AND user_org_id = ? AND assessment_date = ? ", orgID, scheduleDate).Find(&assessmentBefores).Error
2272
+		if err != nil {
2273
+			if err == gorm.ErrRecordNotFound {
2274
+				return nil, nil
2275
+			} else {
2276
+				return nil, err
2277
+			}
2278
+		} else {
2279
+			if len(assessmentBefores) > 0 {
2280
+				//缓存数据
2281
+				assessment_befores_list_all, err := json.Marshal(&assessmentBefores)
2282
+				if err == nil {
2283
+					redis.Set(key, assessment_befores_list_all, time.Second*60*60*18)
2284
+				}
2285
+			}
2286
+			return assessmentBefores, nil
2287
+		}
2288
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2289
+		json.Unmarshal([]byte(assessment_befores_list_all), &assessmentBefores)
2290
+		return assessmentBefores, nil
2291
+	}
2292
+}
2293
+
2294
+func GetAllDialysisOrdersByListSix(orgID int64, scheduleDate int64) (dialysisOrders []*models.VMMonitorDialysisOrder, err error) {
2295
+
2296
+	err = readDb.Model(&models.VMMonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2297
+
2298
+	return dialysisOrders, err
2299
+}
2300
+
2301
+func GetAllDialysisOrdersByListOne(orgID int64, scheduleDate int64) (dialysisOrders []*models.VMMonitorDialysisOrder, err error) {
2302
+	redis := RedisClient()
2303
+
2304
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":dialysis_orders_list_all"
2305
+	fmt.Println("key22332323232323223", key)
2306
+	dialysis_orders_list_all, _ := redis.Get(key).Result()
2307
+	defer redis.Close()
2308
+	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2309
+		err = readDb.Model(&models.VMMonitorDialysisOrder{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
2310
+		if err != nil {
2311
+			if err == gorm.ErrRecordNotFound {
2312
+				return nil, nil
2313
+			} else {
2314
+				return nil, err
2315
+			}
2316
+		} else {
2317
+			if len(dialysisOrders) > 0 {
2318
+				//缓存数据
2319
+				dialysis_orders_list_all, err := json.Marshal(&dialysisOrders)
2320
+				if err == nil {
2321
+					redis.Set(key, dialysis_orders_list_all, time.Second*60*60*18)
2322
+				}
2323
+			}
2324
+			return dialysisOrders, nil
2325
+		}
2326
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2327
+		json.Unmarshal([]byte(dialysis_orders_list_all), &dialysisOrders)
2328
+		return dialysisOrders, nil
2329
+	}
2330
+}
2331
+
2332
+func GetAllAssessmentAfterDislysisByListOne(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.VMAssessmentAfterDislysis, err error) {
2333
+	redis := RedisClient()
2334
+	defer redis.Close()
2335
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":assessment_after_dislysis_list_all"
2336
+	assessment_after_dislysis__all, _ := redis.Get(key).Result()
2337
+
2338
+	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2339
+		err = readDb.Model(&models.VMAssessmentAfterDislysis{}).Where("status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).Find(&assessmentAfterDislysis).Error
2340
+		if err != nil {
2341
+			if err == gorm.ErrRecordNotFound {
2342
+				return nil, nil
2343
+			} else {
2344
+				return nil, err
2345
+			}
2346
+		} else {
2347
+			if len(assessmentAfterDislysis) > 0 {
2348
+				//缓存数据
2349
+				assessment_after_dislysis__all, err := json.Marshal(&assessmentAfterDislysis)
2350
+				if err == nil {
2351
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2352
+				}
2353
+			}
2354
+			return assessmentAfterDislysis, nil
2355
+		}
2356
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2357
+		json.Unmarshal([]byte(assessment_after_dislysis__all), &assessmentAfterDislysis)
2358
+		return assessmentAfterDislysis, nil
2359
+	}
2360
+}
2361
+
2362
+func GetAllMonitorList(orgID int64, scheduleDate int64) (monitor []*models.VMMonitoringRecord, err error) {
2363
+
2364
+	redis := RedisClient()
2365
+	defer redis.Close()
2366
+	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_record_list_all"
2367
+	monitor_record_list_all, _ := redis.Get(key).Result()
2368
+	fmt.Println("monitor_recorde_list", len(monitor_record_list_all))
2369
+	if len(monitor_record_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2370
+		err = readDb.Model(&models.VMMonitoringRecord{}).Where("status = 1  AND user_org_id = ? AND  monitoring_date= ?", orgID, scheduleDate).Find(&monitor).Error
2371
+		if err != nil {
2372
+			if err == gorm.ErrRecordNotFound {
2373
+				return nil, nil
2374
+			} else {
2375
+				return nil, err
2376
+			}
2377
+		} else {
2378
+			if len(monitor) > 0 {
2379
+				//缓存数据
2380
+				assessment_after_dislysis__all, err := json.Marshal(&monitor)
2381
+				if err == nil {
2382
+					redis.Set(key, assessment_after_dislysis__all, time.Second*60*60*18)
2383
+				}
2384
+			}
2385
+			return monitor, nil
2386
+		}
2387
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2388
+		json.Unmarshal([]byte(monitor_record_list_all), &monitor)
2389
+		return monitor, nil
2390
+	}
2391
+}
2392
+
2393
+func GetAllPatientListByListOne(orgID int64) (patients []*models.VMMonitorPatients, err error) {
2394
+	redis := RedisClient()
2395
+	defer redis.Close()
2396
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2397
+	patient_info_str, _ := redis.Get(key).Result()
2398
+
2399
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2400
+		err = readDb.Model(&models.VMMonitorPatients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2401
+		if err != nil {
2402
+			if err == gorm.ErrRecordNotFound {
2403
+				return nil, nil
2404
+			} else {
2405
+				return nil, err
2406
+			}
2407
+		} else {
2408
+			if len(patients) > 0 {
2409
+				//缓存数据
2410
+				patient_info_json, err := json.Marshal(&patients)
2411
+				if err == nil {
2412
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2413
+				}
2414
+			}
2415
+			return patients, nil
2416
+		}
2417
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2418
+		json.Unmarshal([]byte(patient_info_str), &patients)
2419
+		return patients, nil
2420
+	}
2421
+}
2422
+
2423
+func GetAllTreatModeByList(orgID int64) (treatement []*models.TreatmentMode, err error) {
2424
+	redis := RedisClient()
2425
+	defer redis.Close()
2426
+	key := strconv.FormatInt(orgID, 10) + ":" + ":treatement_mode_all"
2427
+	treatment_info_str, _ := redis.Get(key).Result()
2428
+
2429
+	if len(treatment_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2430
+		err = readDb.Model(&models.TreatmentMode{}).Where("status=1").Find(&treatement).Error
2431
+		if err != nil {
2432
+			if err == gorm.ErrRecordNotFound {
2433
+				return nil, nil
2434
+			} else {
2435
+				return nil, err
2436
+			}
2437
+		} else {
2438
+			if len(treatement) > 0 {
2439
+				//缓存数据
2440
+				patient_info_json, err := json.Marshal(&treatement)
2441
+				if err == nil {
2442
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2443
+				}
2444
+			}
2445
+			return treatement, nil
2446
+		}
2447
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2448
+		json.Unmarshal([]byte(treatment_info_str), &treatement)
2449
+		return treatement, nil
2450
+	}
2451
+}
2452
+
2453
+func GetAllPatientListByListTwo(orgID int64) (patients []*MSchedualPatientVM, err error) {
2454
+	redis := RedisClient()
2455
+	defer redis.Close()
2456
+	key := strconv.FormatInt(orgID, 10) + ":" + ":patient_list_all"
2457
+	patient_info_str, _ := redis.Get(key).Result()
2458
+
2459
+	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2460
+		err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2461
+		if err != nil {
2462
+			if err == gorm.ErrRecordNotFound {
2463
+				return nil, nil
2464
+			} else {
2465
+				return nil, err
2466
+			}
2467
+		} else {
2468
+			if len(patients) > 0 {
2469
+				//缓存数据
2470
+				patient_info_json, err := json.Marshal(&patients)
2471
+				if err == nil {
2472
+					redis.Set(key, patient_info_json, time.Second*60*60*18)
2473
+				}
2474
+			}
2475
+			return patients, nil
2476
+		}
2477
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2478
+		json.Unmarshal([]byte(patient_info_str), &patients)
2479
+		return patients, nil
2480
+	}
2481
+}
2482
+
2483
+func GetAllDeviceNumberByListOne(orgID int64) (number []*MDeviceNumberVM, err error) {
2484
+	redis := RedisClient()
2485
+	defer redis.Close()
2486
+	key := strconv.FormatInt(orgID, 10) + ":" + ":device_number_all"
2487
+	number_info_str, _ := redis.Get(key).Result()
2488
+	if len(number_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2489
+		err = readDb.Model(&MDeviceNumberVM{}).Where("org_id=? and status=1", orgID).Find(&number).Error
2490
+		if err != nil {
2491
+			if err == gorm.ErrRecordNotFound {
2492
+				return nil, nil
2493
+			} else {
2494
+				return nil, err
2495
+			}
2496
+		} else {
2497
+			if len(number) > 0 {
2498
+				//缓存数据
2499
+				device_number_json, err := json.Marshal(&number)
2500
+				if err == nil {
2501
+					redis.Set(key, device_number_json, time.Second*60*60*18)
2502
+				}
2503
+			}
2504
+			return number, nil
2505
+		}
2506
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2507
+		json.Unmarshal([]byte(number_info_str), &number)
2508
+		return number, nil
2509
+	}
2510
+}
2511
+
2512
+func GetAllPrescriptionByListOne(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
2513
+
2514
+	redis := RedisClient()
2515
+	defer redis.Close()
2516
+	key := strconv.FormatInt(orgID, 10) + ":" + ":prescriptions_list_all"
2517
+	prescriptions_list_all, _ := redis.Get(key).Result()
2518
+
2519
+	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2520
+		err = readDb.Model(&models.DialysisPrescriptionList{}).Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
2521
+		if err != nil {
2522
+			if err == gorm.ErrRecordNotFound {
2523
+				return nil, nil
2524
+			} else {
2525
+				return nil, err
2526
+			}
2527
+		} else {
2528
+			if len(prescriptions) > 0 {
2529
+				//缓存数据
2530
+				prescriptions_list_all, err := json.Marshal(&prescriptions)
2531
+				if err == nil {
2532
+					redis.Set(key, prescriptions_list_all, time.Second*60*60*18)
2533
+				}
2534
+			}
2535
+			return prescriptions, nil
2536
+		}
2537
+	} else { //缓存数据了数据,将redis缓存的json字符串转为map
2538
+		json.Unmarshal([]byte(prescriptions_list_all), &prescriptions)
2539
+		return prescriptions, nil
2540
+	}
2541
+}

+ 43 - 0
service/patientmanage_service.go View File

@@ -1836,3 +1836,46 @@ func DeleteSummary(ids []string) error {
1836 1836
 	err := XTWriteDB().Model(&summary).Where("id in(?)", ids).Updates(map[string]interface{}{"status": 0}).Error
1837 1837
 	return err
1838 1838
 }
1839
+
1840
+func CreateHisSummary(summary *models.XtHospitalSummary) error {
1841
+
1842
+	err := XTReadDB().Create(&summary).Error
1843
+	return err
1844
+}
1845
+
1846
+func GetHospitalSummaryList(orgid int64, patient_id int64, startime int64, endtime int64) (list []*models.XtHospitalSummary, err error) {
1847
+
1848
+	db := XTReadDB().Model(&list).Where("status = 1")
1849
+	if orgid > 0 {
1850
+		db = db.Where("user_org_id = ?", orgid)
1851
+	}
1852
+	if startime > 0 {
1853
+		db = db.Where("record_date >=?", startime)
1854
+	}
1855
+	if endtime > 0 {
1856
+		db = db.Where("record_date >=?", endtime)
1857
+	}
1858
+	if patient_id > 0 {
1859
+		db = db.Where("patient_id = ?", patient_id)
1860
+	}
1861
+	err = db.Find(&list).Order("ctime desc").Error
1862
+	return list, err
1863
+}
1864
+
1865
+func GetHospitalSummaryDetail(id int64) (models.XtHospitalSummary, error) {
1866
+
1867
+	summary := models.XtHospitalSummary{}
1868
+	err := XTReadDB().Where("id = ? and status = 1", id).Find(&summary).Error
1869
+	return summary, err
1870
+}
1871
+
1872
+func UpdateHospital(id int64, summary models.XtHospitalSummary) error {
1873
+
1874
+	err := XTWriteDB().Model(&summary).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"title": summary.Title, "admission_time": summary.AdmissionTime, "discharge_time": summary.DischargeTime, "sick_personnel": summary.SickPersonnel, "xray": summary.Xray, "connecticut": summary.Connecticut, "nuclear_magnetic_resonance": summary.NuclearMagneticResonance, "ultrasound": summary.Ultrasound, "pathology": summary.Pathology, "admitting_diagnosis_id": summary.AdmittingDiagnosisId, "admitting_diagnosis": summary.AdmittingDiagnosis, "discharge_diagnosis_id": summary.DischargeAdviceId, "discharge_diagnosis": summary.DischargeDiagnosis, "diagnosis_admission_id": summary.DiagnosisAdmissionId, "diagnosis_admission": summary.DiagnosisAdmission, "treatment_id": summary.TreatmentId, "treatment": summary.Treatment, "illness_discharge_id": summary.IllnessDischargeId, "illness_discharge": summary.IllnessDischarge, "discharge_advice_id": summary.DischargeAdviceId, "discharge_advice": summary.DischargeAdvice, "mtime": summary.Mtime, "record_time": summary.RecordTime, "dean_id": summary.DeanId, "doctor": summary.Doctor, "record_date": summary.RecordDate}).Error
1875
+	return err
1876
+}
1877
+
1878
+func DeleteHospitalSummary(id int64) error {
1879
+	err := XTWriteDB().Model(models.XtHospitalSummary{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
1880
+	return err
1881
+}

+ 35 - 18
service/stock_service.go View File

@@ -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 = readDb2.Model(&models.GoodsType{}).Where("org_id = ? AND status = 1", org_id).Find(&goodType).Error
323
+	err = XTReadDB().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 = readDb2.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1", org_id).Find(&goodInfo).Error
333
+	err = XTReadDB().Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1", org_id).Find(&goodInfo).Error
334 334
 	return goodInfo, err
335 335
 }
336 336
 
@@ -1557,6 +1557,18 @@ func GetLastDrugCancelStockById(orgid int64) (models.DrugCancelStock, error) {
1557 1557
 	return stock, err
1558 1558
 }
1559 1559
 
1560
+func GetManufactureById(id int64) (models.Manufacturer, error) {
1561
+	manufacturer := models.Manufacturer{}
1562
+	err := XTReadDB().Model(&manufacturer).Where("id = ? and status = 1", id).Find(&manufacturer).Error
1563
+	return manufacturer, err
1564
+}
1565
+
1566
+func GetDealerById(id int64) (models.Dealer, error) {
1567
+	dealer := models.Dealer{}
1568
+	err := XTReadDB().Model(&dealer).Where("id=? and status = 1", id).Find(&dealer).Error
1569
+	return dealer, err
1570
+}
1571
+
1560 1572
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1561 1573
 	err := writeDb.Create(&cancelStock).Error
1562 1574
 	return err
@@ -1689,7 +1701,7 @@ func FindAllStockOutList(orgId int64, page int64, limit int64, startTime int64,
1689 1701
 
1690 1702
 func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, startime int64, endtime int64, type_name int64) (list []*models.StockInfo, total int64, err error) {
1691 1703
 
1692
-	db := readDb2.Model(&models.StockInfo{})
1704
+	db := XTReadDB().Model(&models.StockInfo{})
1693 1705
 	if startime > 0 {
1694 1706
 
1695 1707
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
@@ -2952,7 +2964,7 @@ func UpdateGoodsInformation(info *models.GoodInfo, goodName string, goodType int
2952 2964
 
2953 2965
 func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
2954 2966
 
2955
-	db := readDb2.Table("xt_warehouse_out_info as x").Where("x.status  =1")
2967
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status  =1")
2956 2968
 	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
2957 2969
 	return houseOutInfo, err
2958 2970
 }
@@ -2960,10 +2972,10 @@ func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutI
2960 2972
 func GetGoodInfomationList(orgid int64, keyword string) (goodInfo []*models.GoodInfo, err error) {
2961 2973
 	key := "%" + keyword + "%"
2962 2974
 	if len(keyword) == 0 {
2963
-		err = readDb2.Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodInfo).Error
2975
+		err = XTReadDB().Where("org_id = ? and status = 1 AND  find_in_set('停用',good_status) = 0", orgid).Find(&goodInfo).Error
2964 2976
 
2965 2977
 	} else {
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
2978
+		err = XTReadDB().Where("org_id = ? and status = 1 AND good_name like ? AND  find_in_set('停用',good_status) = 0", orgid, key).Find(&goodInfo).Error
2967 2979
 
2968 2980
 	}
2969 2981
 	return goodInfo, err
@@ -3044,7 +3056,7 @@ func EditDrugWarehousingOne(warehouse models.DrugWarehouse, id int64) {
3044 3056
 
3045 3057
 func GetAllManufacturerList(orgid int64) (list []*models.Manufacturer, err error) {
3046 3058
 
3047
-	err = readDb2.Where("org_id = ? and status = 1", orgid).Find(&list).Error
3059
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&list).Error
3048 3060
 	return list, err
3049 3061
 }
3050 3062
 
@@ -3344,7 +3356,7 @@ func GetAllStockList(page int64, limit int64, startime int64, endtime int64, goo
3344 3356
 func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.GoodInfo, total int64, err error) {
3345 3357
 
3346 3358
 	offset := (page - 1) * limit
3347
-	db := readDb2.Table("xt_good_information as x").Where("x.status= 1")
3359
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status= 1")
3348 3360
 
3349 3361
 	likeKey := "%" + keyword + "%"
3350 3362
 	if len(likeKey) > 0 {
@@ -3431,7 +3443,7 @@ func GetStockOutList(good_id int64, orgid int64, limit int64, page int64, starti
3431 3443
 
3432 3444
 func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
3433 3445
 
3434
-	db := readDb2.Table("xt_warehouse_info as x").Where("x.status = 1")
3446
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
3435 3447
 	if startime > 0 {
3436 3448
 		db = db.Where("x.ctime >=?", startime)
3437 3449
 	}
@@ -3447,7 +3459,7 @@ func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*mode
3447 3459
 }
3448 3460
 
3449 3461
 func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
3450
-	db := readDb2.Table("xt_warehouse_out_info as x").Where("x.status = 1")
3462
+	db := XTReadDB().Table("xt_warehouse_out_info as x").Where("x.status = 1")
3451 3463
 	if startime > 0 {
3452 3464
 		db = db.Where("x.ctime >=?", startime)
3453 3465
 	}
@@ -3465,7 +3477,7 @@ func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*
3465 3477
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
3466 3478
 
3467 3479
 	if endtime > 0 {
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
3480
+		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
3469 3481
 	}
3470 3482
 	if endtime == 0 {
3471 3483
 		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
@@ -3579,8 +3591,8 @@ func GetExprotStockList(orgid int64, orderid []string, startime int64, endtime i
3579 3591
 
3580 3592
 func GetDrugWarehouOrderInfo(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
3581 3593
 
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")
3594
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
3595
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
3584 3596
 	fmt.Println(table)
3585 3597
 	if startime > 0 {
3586 3598
 		db = db.Where("x.ctime>=?", startime)
@@ -3877,7 +3889,7 @@ func GetCancelStockOrderPrintOne(idstr []string, orgid int64) (info []*models.Ca
3877 3889
 
3878 3890
 func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
3879 3891
 
3880
-	db := readDb2.Table("xt_cancel_stock_info as x").Where("x.status = 1")
3892
+	db := XTReadDB().Table("xt_cancel_stock_info as x").Where("x.status = 1")
3881 3893
 
3882 3894
 	if startime > 0 {
3883 3895
 		db = db.Where("x.ctime >=?", startime)
@@ -3976,7 +3988,7 @@ func GetStockFlowBatchNumberOne(id int64, goodid int64) (stock []*models.VmStock
3976 3988
 	}
3977 3989
 
3978 3990
 	err = db.Select("x.id,x.warehousing_id,x.good_id,x.number,x.count,x.patient_id,x.system_time,x.is_sys,x.warehousing_order,x.warehouse_out_id,x.warehouse_out_order_number,x.price,x.product_date,x.expire_date,x.ctime,o.packing_unit,t.name").Joins("left join xt_patients as t on t.id = x.patient_id").Joins("left join xt_good_information as o on o.id = x.good_id").Scan(&stock).Error
3979
-	//err = XTReadDB().Model(&stock).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&stock).Error
3991
+	//err =XTReadDB()()()()().Model(&stock).Where("warehouse_out_id = ? and good_id = ? and status = 1", id, goodid).Find(&stock).Error
3980 3992
 	return stock, err
3981 3993
 }
3982 3994
 
@@ -4023,7 +4035,6 @@ func GetExportOutOrderDrugListOne(warehouse_out_id []string) (out []*models.StDr
4023 4035
 }
4024 4036
 
4025 4037
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid_id int64) (models.WarehouseOutInfo, error) {
4026
-func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64) (models.WarehouseOutInfo, error) {
4027 4038
 
4028 4039
 	info := models.WarehouseOutInfo{}
4029 4040
 	err := XTReadDB().Where("good_id = ? and warehouse_info_id= ? and status =1", goodid, warehouse_info_id).Last(&info).Error
@@ -4793,7 +4804,7 @@ func GetInventoryDetailById(id []string) (list []*models.XtStockInventory, err e
4793 4804
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4794 4805
 
4795 4806
 	info := models.WarehousingInfo{}
4796
-	//err := XTReadDB().Model(&info).Where("id = ? or warehouse_info_id and status = 1", id).Find(&info).Error
4807
+	//err :=XTReadDB().Model(&info).Where("id = ? or warehouse_info_id and status = 1", id).Find(&info).Error
4797 4808
 	//return info, err
4798 4809
 
4799 4810
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
@@ -4928,7 +4939,7 @@ func CeateStockCorrectRecord(record models.XtStockCorrectRecord) error {
4928 4939
 
4929 4940
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4930 4941
 	info := models.WarehousingInfo{}
4931
-	//err := XTReadDB().Where("id=? and status = 1", id).Find(&info).Error
4942
+	//err :=XTReadDB()()()()().Where("id=? and status = 1", id).Find(&info).Error
4932 4943
 	//return info, err
4933 4944
 
4934 4945
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
@@ -5089,3 +5100,9 @@ func UpdateDrugWarehouseingInfoSix(id int64, info models.XtDrugWarehouseInfo) er
5089 5100
 	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
5090 5101
 	return err
5091 5102
 }
5103
+
5104
+func CreatedCancelStock(info models.DrugCancelStockInfo) error {
5105
+
5106
+	err := XTWriteDB().Create(&info).Error
5107
+	return err
5108
+}

+ 1 - 1
service/user_service.go View File

@@ -139,7 +139,7 @@ func GetLastData(orgid int64) (models.SgjPatientDryweight, error) {
139 139
 
140 140
 func UpdateDialysisPrescription(patientid int64, orgid int64, dryweight float64, prescription models.PredialysisEvaluation) error {
141 141
 
142
-	err := XTWriteDB().Model(&prescription).Where("patient_id = ? AND user_org_id = ?", patientid, orgid).Update(map[string]interface{}{"dry_weight": dryweight, "mtime": time.Now().Unix()}).Last(&prescription).Error
142
+	err := XTWriteDB().Model(&prescription).Where("patient_id = ? AND user_org_id = ? and assessment_date = ?", patientid, orgid, prescription.AssessmentDate).Update(map[string]interface{}{"dry_weight": prescription.DryWeight, "mtime": time.Now().Unix()}).Error
143 143
 	fmt.Println("错误是设么", err)
144 144
 	return err
145 145
 }

+ 34 - 28
service/warhouse_service.go View File

@@ -235,6 +235,9 @@ func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *model
235 235
 		//}
236 236
 		maxNumber = deliver_number / drup.MinNumber
237 237
 		minNumber = deliver_number % drup.MinNumber
238
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
239
+			minNumber = maxNumber
240
+		}
238 241
 		fmt.Println("maxNumber0000000000000", maxNumber)
239 242
 		fmt.Println("minNumber999999999999999", minNumber)
240 243
 		if warehouse.StockMaxNumber < maxNumber {
@@ -498,6 +501,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
498 501
 	// 如果没有对应的库存,则报错
499 502
 
500 503
 	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId)
504
+	fmt.Println("warehouse233223232323", warehouse.ID)
501 505
 	//查找药品信息
502 506
 	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
503 507
 	if err != nil {
@@ -603,13 +607,18 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
603 607
 		var minNumber int64 = 0
604 608
 		fmt.Println("单位1111111", advice.PrescribingNumberUnit)
605 609
 		fmt.Println("单位232323233223", drup.MinUnit)
606
-
610
+		fmt.Println("出库数量", deliver_number)
607 611
 		maxNumber = deliver_number / drup.MinNumber
608 612
 		minNumber = deliver_number % drup.MinNumber
613
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
614
+			minNumber = maxNumber
615
+		}
616
+		fmt.Println("剩余库存233233232323323232")
609 617
 
610
-		if warehouse.StockMaxNumber < maxNumber {
611
-
612
-			return errors.New("库存数量不足")
618
+		if drup.MaxUnit != drup.MinUnit {
619
+			if warehouse.StockMaxNumber < maxNumber {
620
+				return errors.New("库存数量不足")
621
+			}
613 622
 		}
614 623
 
615 624
 		fmt.Println("库存数量2332232323", stock_number)
@@ -617,20 +626,30 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
617 626
 		fmt.Println("c出库数量", minNumber)
618 627
 
619 628
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
620
-
629
+		if warehouse.StockMaxNumber < 0 {
630
+			warehouse.StockMaxNumber = 0
631
+		}
621 632
 		fmt.Println("剩余库存", warehouse.StockMaxNumber)
633
+
634
+		fmt.Println("ha1", warehouse.StockMinNumber)
635
+		fmt.Println("ha2", minNumber)
622 636
 		warehouse.Mtime = time.Now().Unix()
623 637
 
624 638
 		if warehouse.StockMinNumber < minNumber {
625 639
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
626 640
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
627 641
 		} else {
642
+
628 643
 			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
644
+
629 645
 		}
630 646
 
631
-		if warehouse.StockMaxNumber < 0 {
632
-			return errors.New("库存数量不足")
647
+		if drup.MaxUnit != drup.MinUnit {
648
+			if warehouse.StockMaxNumber < 0 {
649
+				return errors.New("库存数量不足")
650
+			}
633 651
 		}
652
+
634 653
 		//扣减库存232332332332
635 654
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
636 655
 		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
@@ -695,15 +714,7 @@ func HisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
695 714
 			return errOne
696 715
 		}
697 716
 		//查询是否存在数据
698
-		//_, errcodes := GetDrugWarehouseOutInfoIsExit(advice.DrugId, advice.PatientId, advice.RecordDate)
699
-		//if errcodes == gorm.ErrRecordNotFound {
700
-		//	errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
701
-		//	if errOne != nil {
702
-		//		return errOne
703
-		//	}
704
-		//} else if errcodes == nil {
705
-		//	UpdatedDrugWarehouseOutInfo(warehouseOutInfo, advice.DrugId, advice.PatientId, advice.RecordDate, advice.UserOrgId)
706
-		//}
717
+
707 718
 		details := &models.DrugAutomaticReduceDetail{
708 719
 			WarehouseOutId:          warehouseout.ID,
709 720
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -1710,14 +1721,6 @@ func ConsumablesDeliveryOne(orgID int64, record_time int64, goods *models.Wareho
1710 1721
 		fmt.Println("几年里2323323232323232323232")
1711 1722
 		if errThree != nil {
1712 1723
 			return errThree
1713
-		if warehouse.StockCount <= 0 {
1714
-			return errors.New("库存数量不足")
1715
-		} else {
1716
-			//扣减库存
1717
-			errThree := UpDateWarehouseInfoByStock(&warehouse)
1718
-			if errThree != nil {
1719
-				return errThree
1720
-			}
1721 1724
 		}
1722 1725
 
1723 1726
 	} else {
@@ -2069,7 +2072,9 @@ func NewDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *mo
2069 2072
 		//将拆零数量转为 最大包装单位  和 最小单位
2070 2073
 		maxNumber = deliver_number / drup.MinNumber
2071 2074
 		minNumber = deliver_number % drup.MinNumber
2072
-
2075
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
2076
+			minNumber = maxNumber
2077
+		}
2073 2078
 		fmt.Println("maxNumber0000000000000", maxNumber)
2074 2079
 		fmt.Println("minNumber999999999999999", minNumber)
2075 2080
 		if warehouse.StockMaxNumber < maxNumber {
@@ -2376,9 +2381,10 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2376 2381
 		//把拆零单位转为最大单位  和 最小单位
2377 2382
 		maxNumber = deliver_number / drup.MinNumber
2378 2383
 		minNumber = deliver_number % drup.MinNumber
2379
-
2384
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
2385
+			minNumber = maxNumber
2386
+		}
2380 2387
 		if warehouse.StockMaxNumber < maxNumber {
2381
-
2382 2388
 			return errors.New("库存数量不足")
2383 2389
 		}
2384 2390
 
@@ -2397,7 +2403,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2397 2403
 		}
2398 2404
 
2399 2405
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
2400
-		fmt.Println("我你233232323232323332323232232332322323233232232323")
2406
+		fmt.Println("我你233232323232323332323232232332322323233232232323")
2401 2407
 		if errThree != nil {
2402 2408
 			return errThree
2403 2409
 		}