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
 appname = 血透
1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3
 runmode = dev
3
 runmode = dev
4
 
4
 
5
 #
5
 #
7
 sessionon = true
7
 sessionon = true
8
 #sessiongcmaxlifetime = 64800
8
 #sessiongcmaxlifetime = 64800
9
 
9
 
10
-tokencookiemaxlifetime = 604800
10
+tokencookiemaxlifetime = 7200
11
 enablexsrf = false
11
 enablexsrf = false
12
 xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
12
 xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
13
 xsrfexpire = 3600
13
 xsrfexpire = 3600
219
 writesgjpatientmysqlname = sgj_patient
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
 
226
 
233
 #redishost = 120.77.235.13
227
 #redishost = 120.77.235.13
234
 #redishost = 112.74.16.180
228
 #redishost = 112.74.16.180
235
-redishost = localhost
229
+redishost = kuyi6666.redis.rds.aliyuncs.com
236
 redisport = 6379
230
 redisport = 6379
237
 redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
231
 redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
238
 redisdb = 7
232
 redisdb = 7

+ 6 - 63
controllers/base_api_controller.go View File

3
 import (
3
 import (
4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
 	"XT_New/service"
5
 	"XT_New/service"
6
-	_ "fmt"
6
+	"fmt"
7
 	"strconv"
7
 	"strconv"
8
 	"strings"
8
 	"strings"
9
 )
9
 )
69
 func (this *BaseAuthAPIController) Prepare() {
69
 func (this *BaseAuthAPIController) Prepare() {
70
 	this.BaseAPIController.Prepare()
70
 	this.BaseAPIController.Prepare()
71
 	if this.GetAdminUserInfo() == nil {
71
 	if this.GetAdminUserInfo() == nil {
72
-		var userAdmin models.AdminUser
73
-		userAdmin.Id = 1448
74
-		userAdmin.Mobile = "13416402574"
75
 		//var userAdmin models.AdminUser
72
 		//var userAdmin models.AdminUser
76
 		//userAdmin.Id = 1448
73
 		//userAdmin.Id = 1448
77
 		//userAdmin.Mobile = "13318599895"
74
 		//userAdmin.Mobile = "13318599895"
102
 
99
 
103
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
100
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
104
 		this.StopRun()
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
 			} else {
118
 			} else {
148
 				roles = strings.Split(role.RoleIds, ",")
119
 				roles = strings.Split(role.RoleIds, ",")
149
 			}
120
 			}
150
-			// fmt.Println(roles)
121
+			fmt.Println(roles)
151
 
122
 
152
 			//获取该用户下所有角色的权限总集
123
 			//获取该用户下所有角色的权限总集
153
 			var userRolePurviews string
124
 			var userRolePurviews string
163
 			}
134
 			}
164
 			//该用户所拥有角色的权限的总集
135
 			//该用户所拥有角色的权限的总集
165
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
136
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
166
-			// fmt.Println(userRolePurviewsArr)
137
+			fmt.Println("userRolePurviewsArr", userRolePurviewsArr)
167
 			//系统所记录的权限列表
138
 			//系统所记录的权限列表
168
 			allPermission, _ := service.GetAllFunctionPurview()
139
 			allPermission, _ := service.GetAllFunctionPurview()
169
 
140
 
194
 						this.StopRun()
165
 						this.StopRun()
195
 					}
166
 					}
196
 				}
167
 				}
168
+
197
 			}
169
 			}
198
 		}
170
 		}
199
 	}
171
 	}
212
 			} else {
184
 			} else {
213
 				roles = strings.Split(role.RoleIds, ",")
185
 				roles = strings.Split(role.RoleIds, ",")
214
 			}
186
 			}
215
-			// fmt.Println(roles)
187
+			fmt.Println(roles)
216
 
188
 
217
 			//获取该用户下所有角色的权限总集
189
 			//获取该用户下所有角色的权限总集
218
 			var userRolePurviews string
190
 			var userRolePurviews string
228
 			}
200
 			}
229
 			//该用户所拥有角色的权限的总集
201
 			//该用户所拥有角色的权限的总集
230
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
202
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
231
-			// fmt.Println(userRolePurviewsArr)
203
+			fmt.Println(userRolePurviewsArr)
232
 			//系统所记录的权限列表
204
 			//系统所记录的权限列表
233
 			allPermission, _ := service.GetAllFunctionPurview()
205
 			allPermission, _ := service.GetAllFunctionPurview()
234
 
206
 
344
 func (this *BaseServeAPIController) Prepare() {
316
 func (this *BaseServeAPIController) Prepare() {
345
 	this.BaseAPIController.Prepare()
317
 	this.BaseAPIController.Prepare()
346
 	if this.GetAdminUserInfo() == nil {
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
 		//var userAdmin models.AdminUser
319
 		//var userAdmin models.AdminUser
377
 		//userAdmin.Id = 1448
320
 		//userAdmin.Id = 1448
378
 		//userAdmin.Mobile = "13318599895"
321
 		//userAdmin.Mobile = "13318599895"

+ 3 - 3
controllers/data_api_controller.go View File

114
 	} else {
114
 	} else {
115
 		dataconfig.Order = 0
115
 		dataconfig.Order = 0
116
 	}
116
 	}
117
-	fmt.Println("dataconfig-------------", dataconfig)
117
+
118
 	err = service.CreateConfig(&dataconfig)
118
 	err = service.CreateConfig(&dataconfig)
119
 	if err != nil {
119
 	if err != nil {
120
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
120
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
225
 	dataconfig.Remark = string(dataBody["remark"].(string))
225
 	dataconfig.Remark = string(dataBody["remark"].(string))
226
 	dataconfig.Order = int64(dataBody["orders"].(float64))
226
 	dataconfig.Order = int64(dataBody["orders"].(float64))
227
 	dataconfig.FieldType = int64(dataBody["field_type"].(float64))
227
 	dataconfig.FieldType = int64(dataBody["field_type"].(float64))
228
-	fmt.Println("dataconfitg------", dataconfig.Order)
228
+
229
 	//if dataBody["orders"] != nil {
229
 	//if dataBody["orders"] != nil {
230
 	//	dataconfig.Order = int64(dataBody["orders"].(float64))
230
 	//	dataconfig.Order = int64(dataBody["orders"].(float64))
231
 	//	fmt.Println("dataconfig",dataconfig.Order)
231
 	//	fmt.Println("dataconfig",dataconfig.Order)
400
 	}
400
 	}
401
 	dataconfig.Module = module
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
 		if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
404
 		if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
405
 			utils.ErrorLog("title")
405
 			utils.ErrorLog("title")
406
 			code = enums.ErrorCodeParamWrong
406
 			code = enums.ErrorCodeParamWrong

+ 59 - 13
controllers/dialysis_api_controller.go View File

387
 		redis := service.RedisClient()
387
 		redis := service.RedisClient()
388
 		//清空key 值
388
 		//清空key 值
389
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyTwo, "", time.Second)
391
 		redis.Set(keyTwo, "", time.Second)
392
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
392
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
393
 		redis.Set(keyThree, "", time.Second)
393
 		redis.Set(keyThree, "", time.Second)
452
 		//清空key 值
452
 		//清空key 值
453
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
456
 		redis.Set(keyOne, "", time.Second)
457
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
457
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
458
 		redis.Set(keyThree, "", time.Second)
458
 		redis.Set(keyThree, "", time.Second)
875
 	//清空key 值
875
 	//清空key 值
876
 	redis.Set(keyOne, "", time.Second)
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
 	redis.Set(keyTwo, "", time.Second)
879
 	redis.Set(keyTwo, "", time.Second)
880
 
880
 
881
 	keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
881
 	keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1288
 		redis := service.RedisClient()
1288
 		redis := service.RedisClient()
1289
 		//清空key 值
1289
 		//清空key 值
1290
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyThree, "", time.Second)
1292
 		redis.Set(keyThree, "", time.Second)
1293
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1293
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1294
 		redis.Set(keyTwo, "", time.Second)
1294
 		redis.Set(keyTwo, "", time.Second)
1311
 		redis := service.RedisClient()
1311
 		redis := service.RedisClient()
1312
 		//清空key 值
1312
 		//清空key 值
1313
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyThree, "", time.Second)
1315
 		redis.Set(keyThree, "", time.Second)
1316
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1316
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1317
 		redis.Set(keyTwo, "", time.Second)
1317
 		redis.Set(keyTwo, "", time.Second)
1377
 	puncture_method := c.GetString("puncture_method")
1377
 	puncture_method := c.GetString("puncture_method")
1378
 
1378
 
1379
 	dialysis_count := c.GetString("dialysis_count")
1379
 	dialysis_count := c.GetString("dialysis_count")
1380
-	//dialysis_count, _ := c.GetInt64("dialysis_count", 0)
1381
-	dialysis_count := c.GetString("dialysis_count")
1380
+
1382
 	emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
1381
 	emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
1383
 	emergency_treatment_other := c.GetString("emergency_treatment_other")
1382
 	emergency_treatment_other := c.GetString("emergency_treatment_other")
1384
 	ductus_arantii := c.GetString("ductus_arantii")
1383
 	ductus_arantii := c.GetString("ductus_arantii")
1403
 	puncture_needle := c.GetString("puncture_needle")
1402
 	puncture_needle := c.GetString("puncture_needle")
1404
 	//humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1403
 	//humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
1405
 
1404
 
1406
-	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1407
 	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1405
 	humor_excessive_symptom := c.GetString("humor_excessive_symptom")
1408
 	phinholing := c.GetString("pinholing")
1406
 	phinholing := c.GetString("pinholing")
1409
 
1407
 
1510
 		//清空key 值
1508
 		//清空key 值
1511
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
1512
 		redis.Set(keyOne, "", time.Second)
1515
 
1513
 
1516
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1514
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1736
 		//清空key 值
1734
 		//清空key 值
1737
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
1738
 		redis.Set(keyOne, "", time.Second)
1741
 		defer redis.Close()
1739
 		defer redis.Close()
1742
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1740
 		keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
1896
 		numberList, _ := service.GetAllDeviceNumberByList(adminUserInfo.CurrentOrgId)
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
 		prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
1899
 		prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
1902
 		//获取透前评估
1900
 		//获取透前评估
2295
 	//}
2293
 	//}
2296
 
2294
 
2297
 	err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
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
 	if err != nil {
2305
 	if err != nil {
2299
 		this.ErrorLog("删除透析监测记录失败:%v", err)
2306
 		this.ErrorLog("删除透析监测记录失败:%v", err)
2300
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
2307
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
2403
 	}
2410
 	}
2404
 
2411
 
2405
 	err := service.CreateMonitor(&monitorRecord)
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
 	if err != nil {
2420
 	if err != nil {
2407
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2421
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2408
 		return
2422
 		return
3257
 
3271
 
3258
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
3272
 	list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
3259
 	redis := service.RedisClient()
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
 	redis.Set(key, "", time.Second)
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
 	if err != nil {
3282
 	if err != nil {
3264
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3283
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
3265
 		return
3284
 		return
3434
 			UserId:        adminUserInfo.AdminUser.Id,
3453
 			UserId:        adminUserInfo.AdminUser.Id,
3435
 		}
3454
 		}
3436
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
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
 		if createErr == nil {
3470
 		if createErr == nil {
3439
 			c.ServeSuccessJSON(map[string]interface{}{
3471
 			c.ServeSuccessJSON(map[string]interface{}{
3440
 				"msg":    "提交成功",
3472
 				"msg":    "提交成功",
3469
 		fmt.Println(value)
3501
 		fmt.Println(value)
3470
 
3502
 
3471
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
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
 		if createErr == nil {
3518
 		if createErr == nil {
3473
 			c.ServeSuccessJSON(map[string]interface{}{
3519
 			c.ServeSuccessJSON(map[string]interface{}{
3474
 				"msg":    "提交成功",
3520
 				"msg":    "提交成功",

+ 17 - 3
controllers/dialysis_record_api_controller.go View File

593
 		createErr := service.CreateMonitor(&monitor)
593
 		createErr := service.CreateMonitor(&monitor)
594
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
594
 		key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(scheduleDate, 10) + ":monitor_records"
595
 		redis := service.RedisClient()
595
 		redis := service.RedisClient()
596
-		defer redis.Close()
597
 		//清空key 值
596
 		//清空key 值
598
 		redis.Set(key, "", time.Second)
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
 		if createErr != nil {
603
 		if createErr != nil {
601
 			this.ErrorLog("创建监测记录失败:%v", createErr)
604
 			this.ErrorLog("创建监测记录失败:%v", createErr)
602
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
605
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
889
 	//清空key 值
892
 	//清空key 值
890
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
896
 	redis.Set(keyOne, "", time.Second)
894
 
897
 
895
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
898
 	newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
979
 		// 如果当天有插入数据,则不再往透析纪录里插入数据
982
 		// 如果当天有插入数据,则不再往透析纪录里插入数据
980
 		if newdialysisRecord.ID > 0 {
983
 		if newdialysisRecord.ID > 0 {
981
 			err := service.CreateMonitor(&record)
984
 			err := service.CreateMonitor(&record)
985
+
982
 			if err != nil {
986
 			if err != nil {
983
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
987
 				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
984
 				return
988
 				return
1242
 	//清空key 值
1246
 	//清空key 值
1243
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
1250
 	redis.Set(keyOne, "", time.Second)
1247
 
1251
 
1248
 	if updateErr != nil {
1252
 	if updateErr != nil {
1411
 	}
1415
 	}
1412
 
1416
 
1413
 	updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
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
 	if updateErr != nil {
1422
 	if updateErr != nil {
1415
 		this.ErrorLog("修改上机失败:%v", updateErr)
1423
 		this.ErrorLog("修改上机失败:%v", updateErr)
1416
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1424
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1427
 			hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1435
 			hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1428
 			minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
1436
 			minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
1429
 			updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecord.PatientId, tempDialysisRecord.UserOrgId, tempDialysisRecord.DialysisDate, hour, minute)
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
 			if updateAssessmentErr != nil {
1444
 			if updateAssessmentErr != nil {
1431
 				utils.ErrorLog("%v", updateAssessmentErr)
1445
 				utils.ErrorLog("%v", updateAssessmentErr)
1432
 			}
1446
 			}

+ 294 - 58
controllers/doctors_api_controller.go View File

53
 	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
53
 	beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
54
 	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
54
 	beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
55
 	beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
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
 func (c *DoctorsApiController) ScheduleAdvices() {
63
 func (c *DoctorsApiController) ScheduleAdvices() {
85
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
90
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
86
 
91
 
87
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
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
 	for _, item := range project {
94
 	for _, item := range project {
93
 		index := 0
95
 		index := 0
94
 		for _, subItem := range item.HisPrescriptionTeamProject {
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
 			if subItem.HisProject.CostClassify != 3 {
140
 			if subItem.HisProject.CostClassify != 3 {
139
 				subItem.IsCheckTeam = 2
141
 				subItem.IsCheckTeam = 2
140
 				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
142
 				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
232
 	adminUserInfo := c.GetAdminUserInfo()
234
 	adminUserInfo := c.GetAdminUserInfo()
233
 	orgid := adminUserInfo.CurrentOrgId
235
 	orgid := adminUserInfo.CurrentOrgId
234
 	userid := adminUserInfo.AdminUser.Id
236
 	userid := adminUserInfo.AdminUser.Id
235
-	fmt.Println("userid", userid)
237
+
236
 	dry_weight, _ := c.GetFloat("dry_weight")
238
 	dry_weight, _ := c.GetFloat("dry_weight")
237
-	fmt.Println("dry_weight", dry_weight)
239
+
238
 	doctors, _ := c.GetInt64("doctors")
240
 	doctors, _ := c.GetInt64("doctors")
239
-	fmt.Println("doctors", doctors)
241
+
240
 	remarks := c.GetString("remarks")
242
 	remarks := c.GetString("remarks")
241
-	fmt.Println("remarks", remarks)
243
+
242
 	patientid, _ := c.GetInt64("patient_id")
244
 	patientid, _ := c.GetInt64("patient_id")
243
-	fmt.Println("patientid", patientid)
245
+
244
 	//透前数据
246
 	//透前数据
245
 	dryweight, _ := c.GetFloat("dryweight")
247
 	dryweight, _ := c.GetFloat("dryweight")
246
-	fmt.Println("dryweight", dryweight)
248
+
247
 	var weight = dryweight - dry_weight
249
 	var weight = dryweight - dry_weight
248
 	weights := fmt.Sprintf("%.1f", weight)
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
 	var sum string
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
 	if errcode == gorm.ErrRecordNotFound {
255
 	if errcode == gorm.ErrRecordNotFound {
258
 		sum = "/"
256
 		sum = "/"
259
 		patientDryweight := models.SgjPatientDryweight{
257
 		patientDryweight := models.SgjPatientDryweight{
269
 		}
267
 		}
270
 
268
 
271
 		err := service.CreatePatientWeight(&patientDryweight)
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
 		fmt.Println("err", err)
291
 		fmt.Println("err", err)
273
 		c.ServeSuccessJSON(map[string]interface{}{
292
 		c.ServeSuccessJSON(map[string]interface{}{
274
 			"patientDryweight": patientDryweight,
293
 			"patientDryweight": patientDryweight,
303
 	}
322
 	}
304
 
323
 
305
 	err := service.CreatePatientWeight(&patientDryweight)
324
 	err := service.CreatePatientWeight(&patientDryweight)
306
-	//sgjPatientDryweight, _ := service.GetLastData(orgid)
325
+
307
 	recordDateStr := time.Now().Format("2006-01-02")
326
 	recordDateStr := time.Now().Format("2006-01-02")
308
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
327
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
309
 	fmt.Scan("parseDateErr", parseDateErr)
328
 	fmt.Scan("parseDateErr", parseDateErr)
310
 	nowtime := recordDate.Unix()
329
 	nowtime := recordDate.Unix()
311
 	fmt.Println("nowtime", nowtime)
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
 	fmt.Println("err", err)
351
 	fmt.Println("err", err)
318
-	fmt.Println("patientdryweight", patientDryweight)
352
+	redis.Close()
319
 	c.ServeSuccessJSON(map[string]interface{}{
353
 	c.ServeSuccessJSON(map[string]interface{}{
320
 		"patientDryweight": patientDryweight,
354
 		"patientDryweight": patientDryweight,
321
 	})
355
 	})
1173
 	this.ServeSuccessJSON(returnData)
1207
 	this.ServeSuccessJSON(returnData)
1174
 	return
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
 	limit, _ := c.GetInt64("limit")
1632
 	limit, _ := c.GetInt64("limit")
1633
 
1633
 
1634
 	detail, total, err := service.GetDrugInOrderDetail(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
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
 	if err != nil {
1638
 	if err != nil {
1637
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1639
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1638
 		return
1640
 		return
1639
 	}
1641
 	}
1640
 	c.ServeSuccessJSON(map[string]interface{}{
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
 	keyword := c.GetString("keyword")
1722
 	keyword := c.GetString("keyword")
1720
 	limit, _ := c.GetInt64("limit")
1723
 	limit, _ := c.GetInt64("limit")
1721
 	page, _ := c.GetInt64("page")
1724
 	page, _ := c.GetInt64("page")
1722
-
1723
 	order, total, err := service.GetDrugOutOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
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
 	if err != nil {
1729
 	if err != nil {
1725
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1730
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1726
 		return
1731
 		return
1727
 	}
1732
 	}
1728
 	c.ServeSuccessJSON(map[string]interface{}{
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
 	page, _ := c.GetInt64("page")
1771
 	page, _ := c.GetInt64("page")
1766
 	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1772
 	orderPrint, _ := service.GetDrugCancelOrderPrint(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword)
1767
 	order, total, err := service.GetDrugCancelOrder(startTime, endTime, adminInfo.CurrentOrgId, order_type, manufacturer_id, keyword, page, limit)
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
 	if err != nil {
1777
 	if err != nil {
1770
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1778
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
1771
 		return
1779
 		return
1772
 	}
1780
 	}
1773
 	c.ServeSuccessJSON(map[string]interface{}{
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
 		}
582
 		}
583
 	}
583
 	}
584
 
584
 
585
-
586
 	manufacturers, _ := service.GetAllManufacturerList(adminInfo.CurrentOrgId)
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
 	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
587
 	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
604
 	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
588
 	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
605
 	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
589
 	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
670
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
654
 	patient, _ := service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
671
 
655
 
672
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
656
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
673
-	fmt.Println("drugStockConfig94394343344334344343434334", drugStockConfig)
657
+
674
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
658
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
675
 
659
 
676
 	if drugStockConfig.IsOpen == 1 {
660
 	if drugStockConfig.IsOpen == 1 {
828
 			PType:              p_type,
812
 			PType:              p_type,
829
 		}
813
 		}
830
 		service.SavePatientPrescriptionInfo(hpInfo)
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
 	} else {
824
 	} else {
833
 		hpInfo = models.HisPrescriptionInfo{
825
 		hpInfo = models.HisPrescriptionInfo{
834
 
826
 
854
 			HisPatientId:       info.HisPatientId,
846
 			HisPatientId:       info.HisPatientId,
855
 		}
847
 		}
856
 		service.SavePatientPrescriptionInfo(hpInfo)
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
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
860
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
938
 					}
939
 					}
939
 					tempPrescription = prescription
940
 					tempPrescription = prescription
940
 					service.SaveHisPrescription(tempPrescription)
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
 				} else {
951
 				} else {
943
 					tempPrescription.ID = id
952
 					tempPrescription.ID = id
944
 					tempPrescription.Type = types
953
 					tempPrescription.Type = types
949
 					tempPrescription.PreTime = pTime
958
 					tempPrescription.PreTime = pTime
950
 					tempPrescription.MedType = med_type
959
 					tempPrescription.MedType = med_type
951
 					service.SaveHisPrescription(tempPrescription)
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
 				//service.SaveHisPrescription(prescription)
971
 				//service.SaveHisPrescription(prescription)
954
 				//更改患者挂号状态
972
 				//更改患者挂号状态
988
 
1006
 
989
 							s.StartTime = pTime
1007
 							s.StartTime = pTime
990
 							service.CreateHisDoctorAdvice(&s)
1008
 							service.CreateHisDoctorAdvice(&s)
991
-							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(recordDateTime, 10) + ":his_doctor_advice"
992
 							redis := service.RedisClient()
1009
 							redis := service.RedisClient()
1010
+							key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(theTime.Unix(), 10) + ":his_advices_list_all"
993
 							redis.Set(key, "", time.Second)
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
 							var randNum int
1018
 							var randNum int
996
 							randNum = rand.Intn(10000) + 1000
1019
 							randNum = rand.Intn(10000) + 1000
997
 							timestamp := time.Now().Unix()
1020
 							timestamp := time.Now().Unix()
999
 							timeFormat := tempTime.Format("20060102150405")
1022
 							timeFormat := tempTime.Format("20060102150405")
1000
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
1023
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
1001
 							service.CreateHisDoctorAdvice(&s)
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
 								return
1351
 								return
1323
 							}
1352
 							}
1324
 							service.CreateHisDoctorAdvice(&s)
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
 			if len(advices) > 0 {
1466
 			if len(advices) > 0 {
1428
 				for _, item := range advices {
1467
 				for _, item := range advices {
1429
 					drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, item.DrugId)
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
 					if item.PrescribingNumberUnit == drug.MinUnit {
1473
 					if item.PrescribingNumberUnit == drug.MinUnit {
1431
 						drug.Total = drug.Total + item.PrescribingNumber
1474
 						drug.Total = drug.Total + item.PrescribingNumber
1432
 						service.UpdateBaseDrugLib(&drug)
1475
 						service.UpdateBaseDrugLib(&drug)
1453
 func (c *HisApiController) DeleteDoctorAdvice() {
1496
 func (c *HisApiController) DeleteDoctorAdvice() {
1454
 	id, _ := c.GetInt64("id")
1497
 	id, _ := c.GetInt64("id")
1455
 	advice, _ := service.GetHisDoctorAdvicesById(id)
1498
 	advice, _ := service.GetHisDoctorAdvicesById(id)
1499
+
1456
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1500
 	_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
1501
+
1457
 	err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
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
 	if err == nil {
1507
 	if err == nil {
1459
 		if drugStockConfig.IsOpen == 1 {
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
 		c.ServeSuccessJSON(map[string]interface{}{
1724
 		c.ServeSuccessJSON(map[string]interface{}{
1500
 		if stockConfig.IsOpen == 1 {
1751
 		if stockConfig.IsOpen == 1 {
1501
 			if project.Type == 3 {
1752
 			if project.Type == 3 {
1502
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
1753
 				good, _ := service.FindGoodInfoByIdTwo(project.ProjectId)
1503
-
1504
 				f_count, _ := strconv.ParseFloat(project.Count, 64)
1754
 				f_count, _ := strconv.ParseFloat(project.Count, 64)
1505
 				good.Total = good.Total + f_count
1755
 				good.Total = good.Total + f_count
1506
 				service.UpdateGoodInfo(&good)
1756
 				service.UpdateGoodInfo(&good)
5568
 	}
5818
 	}
5569
 	return
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
 	theAssessmentDateTime := theStartTime.Unix()
64
 	theAssessmentDateTime := theStartTime.Unix()
65
 
65
 
66
 	if dialysistype == 1 {
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
 		if getPEErr != nil {
69
 		if getPEErr != nil {
172
 			c.ErrorLog("获取透前评估失败:%v", getPEErr)
70
 			c.ErrorLog("获取透前评估失败:%v", getPEErr)
173
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
71
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
187
 			evaluation.PatientId = id
85
 			evaluation.PatientId = id
188
 			evaluation.UserOrgId = adminUserInfo.Org.Id
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
 			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
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
 			if getAADErr != nil {
92
 			if getAADErr != nil {
194
 				c.ErrorLog("获取透后评估失败:%v", getAADErr)
93
 				c.ErrorLog("获取透后评估失败:%v", getAADErr)
195
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
94
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
228
 		evaluation.AssessmentTime = time.Now().Unix()
127
 		evaluation.AssessmentTime = time.Now().Unix()
229
 
128
 
230
 		err := service.UpadatePredialysisEvaluation(&evaluation)
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
 		if err != nil {
142
 		if err != nil {
232
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
143
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
233
 			return
144
 			return
242
 	} else {
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
 		if getAADErr != nil {
158
 		if getAADErr != nil {
248
 			c.ErrorLog("获取透后评估失败:%v", getAADErr)
159
 			c.ErrorLog("获取透后评估失败:%v", getAADErr)
277
 		}
188
 		}
278
 
189
 
279
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
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
 		if err == nil {
201
 		if err == nil {
281
 			c.ServeSuccessJSON(map[string]interface{}{
202
 			c.ServeSuccessJSON(map[string]interface{}{
282
 				"assessmentAfterDislysis": afterevaluation,
203
 				"assessmentAfterDislysis": afterevaluation,
365
 		//if weightfirst.DryWeight > weighing_before {
286
 		//if weightfirst.DryWeight > weighing_before {
366
 		//	return
287
 		//	return
367
 		//}
288
 		//}
368
-
369
 		dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
289
 		dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
370
 		if schedual != nil {
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
 			mode_id = schedual.ModeId
295
 			mode_id = schedual.ModeId
376
 		} else {
296
 		} else {
377
 			// 获取透析模版
297
 			// 获取透析模版
438
 			newprescribe.DewaterAmount = dewater_amount
358
 			newprescribe.DewaterAmount = dewater_amount
439
 			newprescribe.TargetUltrafiltration = dewater_amount
359
 			newprescribe.TargetUltrafiltration = dewater_amount
440
 			newprescribe.Status = 1
360
 			newprescribe.Status = 1
441
-
361
+			//插入透析处方
442
 			err := service.AddSigleRecord(&newprescribe)
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
 			if err != nil {
373
 			if err != nil {
444
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
374
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
445
 			}
375
 			}
497
 				newprescribe.Status = 1
427
 				newprescribe.Status = 1
498
 
428
 
499
 				err := service.AddSigleRecord(&newprescribe)
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
 				if err != nil {
440
 				if err != nil {
501
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
441
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
502
 				}
442
 				}
554
 				fmt.Println(newprescribe.TargetUltrafiltration)
494
 				fmt.Println(newprescribe.TargetUltrafiltration)
555
 
495
 
556
 				err := service.AddSigleRecord(&newprescribe)
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
 				if err != nil {
507
 				if err != nil {
558
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
508
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
559
 				}
509
 				}
571
 				newprescribe.Status = 1
521
 				newprescribe.Status = 1
572
 
522
 
573
 				err := service.AddSigleRecord(&newprescribe)
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
 				if err != nil {
534
 				if err != nil {
575
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
535
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
576
 				}
536
 				}
583
 			dialysisPrescribe.DewaterAmount = dewater_amount
543
 			dialysisPrescribe.DewaterAmount = dewater_amount
584
 			dialysisPrescribe.TargetUltrafiltration = dewater_amount
544
 			dialysisPrescribe.TargetUltrafiltration = dewater_amount
585
 			dialysisPrescribe.Status = 1
545
 			dialysisPrescribe.Status = 1
546
+
586
 			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
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
 			if updateErr != nil {
558
 			if updateErr != nil {
588
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
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
 		if getPEErr != nil {
564
 		if getPEErr != nil {
594
 			c.ErrorLog("获取透前评估失败:%v", getPEErr)
565
 			c.ErrorLog("获取透前评估失败:%v", getPEErr)
595
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
566
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
609
 			evaluation.PatientId = id
580
 			evaluation.PatientId = id
610
 			evaluation.UserOrgId = adminUserInfo.Org.Id
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
 			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
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
 			if getAADErr != nil {
586
 			if getAADErr != nil {
616
 				c.ErrorLog("获取透后评估失败:%v", getAADErr)
587
 				c.ErrorLog("获取透后评估失败:%v", getAADErr)
617
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
588
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
667
 		evaluation.AssessmentTime = time.Now().Unix()
638
 		evaluation.AssessmentTime = time.Now().Unix()
668
 
639
 
669
 		err := service.UpadatePredialysisEvaluation(&evaluation)
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
 		if err != nil {
651
 		if err != nil {
671
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
652
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
672
 			return
653
 			return
681
 	} else {
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
 		if getAADErr != nil {
666
 		if getAADErr != nil {
686
 			c.ErrorLog("获取透后评估失败:%v", getAADErr)
667
 			c.ErrorLog("获取透后评估失败:%v", getAADErr)
687
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
668
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
720
 		// }
701
 		// }
721
 
702
 
722
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
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
 		if err == nil {
714
 		if err == nil {
724
 			c.ServeSuccessJSON(map[string]interface{}{
715
 			c.ServeSuccessJSON(map[string]interface{}{
725
 				"assessmentAfterDislysis": afterevaluation,
716
 				"assessmentAfterDislysis": afterevaluation,

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

326
 	adminInfo := this.GetMobileAdminUserInfo()
326
 	adminInfo := this.GetMobileAdminUserInfo()
327
 
327
 
328
 	ch := make(chan struct{})
328
 	ch := make(chan struct{})
329
-	count := 25 // count 表示活动的协程个数
329
+	count := 24 // count 表示活动的协程个数
330
 	var patient models.Patients
330
 	var patient models.Patients
331
 	var receiverTreatmentAccess *models.ReceiveTreatmentAsses
331
 	var receiverTreatmentAccess *models.ReceiveTreatmentAsses
332
 	var predialysisEvaluation *models.PredialysisEvaluation
332
 	var predialysisEvaluation *models.PredialysisEvaluation
348
 	var stockType []*models.GoodsTypeOne
348
 	var stockType []*models.GoodsTypeOne
349
 	var prepare []*models.XtDialysisBeforePrepare
349
 	var prepare []*models.XtDialysisBeforePrepare
350
 	var lastAssessment models.XtPatientVascularAccess
350
 	var lastAssessment models.XtPatientVascularAccess
351
-	var prescribeOne *models.DialysisPrescription
351
+
352
 	var lastDryWeightDislysis *models.SgjPatientDryweight
352
 	var lastDryWeightDislysis *models.SgjPatientDryweight
353
 	var gobalConfig models.GobalConfig
353
 	var gobalConfig models.GobalConfig
354
 	var operators []*models.SgjUserAdminRoles
354
 	var operators []*models.SgjUserAdminRoles
469
 		ch <- struct{}{}
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
 	go func() {
472
 	go func() {
479
 		// 先走redis,没有走数据库
473
 		// 先走redis,没有走数据库
480
 		lastDryWeightDislysis, _ = service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
474
 		lastDryWeightDislysis, _ = service.MobileGetLastDryWeight(adminInfo.Org.Id, patientID)
501
 			close(ch)
495
 			close(ch)
502
 		}
496
 		}
503
 	}
497
 	}
498
+
499
+	prescribeOne, _ := service.MobileGetDialysisPrescribeByModeIdOne(adminInfo.Org.Id, patientID, date.Unix())
500
+
504
 	_, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.Org.Id)
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
 	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
506
 	temp_team_projects, _ := service.GetHisPrescriptionTeamProjects(adminInfo.Org.Id, patientID, date.Unix())
510
 
507
 
511
 	var team_projects []*models.HisPrescriptionProject
508
 	var team_projects []*models.HisPrescriptionProject
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
 	var his_advices []*models.HisDoctorAdviceInfo
529
 	var his_advices []*models.HisDoctorAdviceInfo
536
 	if is_open_config.IsOpen == 1 {
530
 	if is_open_config.IsOpen == 1 {
537
 		// 先走redis,没有走数据库
531
 		// 先走redis,没有走数据库
658
 		redis := service.RedisClient()
652
 		redis := service.RedisClient()
659
 		//清空key 值
653
 		//清空key 值
660
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
656
 		redis.Set(keyOne, "", time.Second)
663
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
657
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
664
 		redis.Set(keyThree, "", time.Second)
658
 		redis.Set(keyThree, "", time.Second)
688
 		redis := service.RedisClient()
682
 		redis := service.RedisClient()
689
 		//清空key 值
683
 		//清空key 值
690
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
686
 		redis.Set(keyOne, "", time.Second)
693
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
687
 		keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
694
 		redis.Set(keyThree, "", time.Second)
688
 		redis.Set(keyThree, "", time.Second)
1141
 		}
1135
 		}
1142
 
1136
 
1143
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
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
 		redis := service.RedisClient()
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
 		//清空key 值
1143
 		//清空key 值
1147
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
1147
 		redis.Set(keyOne, "", time.Second)
1151
 		defer redis.Close()
1148
 		defer redis.Close()
1152
 		if err == nil {
1149
 		if err == nil {
1168
 
1165
 
1169
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1166
 		assessmentAfterDislysis.CreatedTime = assessmentAfter.CreatedTime
1170
 		assessmentAfterDislysis.ID = assessmentAfter.ID
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
 		redis := service.RedisClient()
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
 		//清空key 值
1176
 		//清空key 值
1174
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
1180
 		redis.Set(keyOne, "", time.Second)
1178
-		err := service.UpdateAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1179
-
1180
 		if err == nil {
1181
 		if err == nil {
1181
-			fmt.Println("hhhhhhhhhhh0000000000", err)
1182
 			c.ServeSuccessJSON(map[string]interface{}{
1182
 			c.ServeSuccessJSON(map[string]interface{}{
1183
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1183
 				"assessmentAfterDislysis": assessmentAfterDislysis,
1184
 			})
1184
 			})
1475
 
1475
 
1476
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1476
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
1477
 	if dialysisPrescription.ID == 0 { //新增
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
 		if appRole.UserType == 2 || appRole.UserType == 1 {
1479
 		if appRole.UserType == 2 || appRole.UserType == 1 {
1482
 			prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
1480
 			prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
1483
 		}
1481
 		}
1488
 		//获取key,清空redis
1486
 		//获取key,清空redis
1489
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
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
 		redis := service.RedisClient()
1488
 		redis := service.RedisClient()
1491
-		defer redis.Close()
1489
+
1492
 		//清空key 值
1490
 		//清空key 值
1493
 		redis.Set(key, "", time.Second)
1491
 		redis.Set(key, "", time.Second)
1494
 
1492
 
1500
 		//清空key 值
1498
 		//清空key 值
1501
 		redis.Set(keyTwo, "", time.Second)
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
 		redis.Set(keySix, "", time.Second)
1502
 		redis.Set(keySix, "", time.Second)
1505
 
1503
 
1506
 		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1504
 		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1509
 		if err == nil {
1507
 		if err == nil {
1510
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1508
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1511
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_by_mode"
1509
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe_by_mode"
1510
+
1512
 			//清空key 值
1511
 			//清空key 值
1513
 			redis.Set(keyThree, "", time.Second)
1512
 			redis.Set(keyThree, "", time.Second)
1514
 
1513
 
1518
 			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
1517
 			keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
1519
 			redis.Set(keyFive, "", time.Second)
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
 			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1523
 			keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1522
 			redis.Set(keySeven, "", time.Second)
1524
 			redis.Set(keySeven, "", time.Second)
1523
 
1525
 
1527
 			if updateErr != nil {
1529
 			if updateErr != nil {
1528
 				utils.ErrorLog("%v", updateErr)
1530
 				utils.ErrorLog("%v", updateErr)
1529
 			}
1531
 			}
1530
-
1532
+			defer redis.Close()
1531
 			c.ServeSuccessJSON(map[string]interface{}{
1533
 			c.ServeSuccessJSON(map[string]interface{}{
1532
 				"prescription": prescription,
1534
 				"prescription": prescription,
1533
 			})
1535
 			})
1572
 		//获取key,清空redis
1574
 		//获取key,清空redis
1573
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
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
 		redis := service.RedisClient()
1576
 		redis := service.RedisClient()
1575
-		defer redis.Close()
1577
+
1576
 		//清空key 值
1578
 		//清空key 值
1577
 		redis.Set(key, "", time.Second)
1579
 		redis.Set(key, "", time.Second)
1578
 
1580
 
1580
 		//清空key 值
1582
 		//清空key 值
1581
 		redis.Set(keyOne, "", time.Second)
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
 		redis.Set(keySix, "", time.Second)
1586
 		redis.Set(keySix, "", time.Second)
1585
 
1587
 
1586
 		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1588
 		keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
1587
 		redis.Set(keySeven, "", time.Second)
1589
 		redis.Set(keySeven, "", time.Second)
1590
+
1588
 		if err == nil {
1591
 		if err == nil {
1589
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1592
 			updateErr := service.UpdateScheduleModeId(patient.ID, adminUserInfo.Org.Id, recordDate.Unix(), mode_id)
1590
 			keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1593
 			keyOne := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1594
+
1591
 			//清空key 值
1595
 			//清空key 值
1592
 			redis.Set(keyOne, "", time.Second)
1596
 			redis.Set(keyOne, "", time.Second)
1597
+			defer redis.Close()
1593
 			if updateErr != nil {
1598
 			if updateErr != nil {
1594
 				utils.ErrorLog("%v", updateErr)
1599
 				utils.ErrorLog("%v", updateErr)
1595
 			}
1600
 			}
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
 	if getMonitorRecordsErr != nil {
1671
 	if getMonitorRecordsErr != nil {
1667
 		c.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
1672
 		c.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
1668
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1673
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1693
 		tempassessmentAfterDislysis.PatientId = id
1698
 		tempassessmentAfterDislysis.PatientId = id
1694
 		tempassessmentAfterDislysis.UserOrgId = adminUserInfo.Org.Id
1699
 		tempassessmentAfterDislysis.UserOrgId = adminUserInfo.Org.Id
1695
 	}
1700
 	}
1696
-	fmt.Println("上机状态233323232232332322332233232323223", dialysisOrder.Stage)
1701
+
1697
 	if dialysisOrder.Stage == 1 {
1702
 	if dialysisOrder.Stage == 1 {
1698
 		temp_time := (float64(endDate.Unix()) - float64(dialysisOrder.StartTime)) / 3600
1703
 		temp_time := (float64(endDate.Unix()) - float64(dialysisOrder.StartTime)) / 3600
1699
 		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
1704
 		value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
1702
 		c, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
1707
 		c, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
1703
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1708
 		hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
1704
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", c*60), 10, 64)
1709
 		minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", c*60), 10, 64)
1705
-		fmt.Println("323332322332323223232323232323232323", hour)
1706
-		fmt.Println(minute)
1710
+
1707
 		tempassessmentAfterDislysis.ActualTreatmentHour = hour
1711
 		tempassessmentAfterDislysis.ActualTreatmentHour = hour
1708
 		tempassessmentAfterDislysis.ActualTreatmentMinute = minute
1712
 		tempassessmentAfterDislysis.ActualTreatmentMinute = minute
1709
 	}
1713
 	}
1727
 		tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
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
 		if evaluation.SystolicBloodPressure == 0 {
1737
 		if evaluation.SystolicBloodPressure == 0 {
1734
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1738
 			evaluation.SystolicBloodPressure = fmonitorRecords.SystolicBloodPressure
1735
 			pre := models.PredialysisEvaluation{
1739
 			pre := models.PredialysisEvaluation{
1738
 			fmt.Println("prew", pre)
1742
 			fmt.Println("prew", pre)
1739
 			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1743
 			getNurseErr := service.UpdatePredialysisEvaluation(&pre, evaluation.ID)
1740
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
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
 			redis := service.RedisClient()
1747
 			redis := service.RedisClient()
1743
 			redis.Set(key, "", time.Second)
1748
 			redis.Set(key, "", time.Second)
1749
+			redis.Set(keyOne, "", time.Second)
1744
 			defer redis.Close()
1750
 			defer redis.Close()
1745
 			fmt.Println(getNurseErr)
1751
 			fmt.Println(getNurseErr)
1746
 		}
1752
 		}
1755
 			redis := service.RedisClient()
1761
 			redis := service.RedisClient()
1756
 			redis.Set(key, "", time.Second)
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
 			redis.Set(keyOne, "", time.Second)
1765
 			redis.Set(keyOne, "", time.Second)
1760
 			defer redis.Close()
1766
 			defer redis.Close()
1761
 			fmt.Println(getNurseErr)
1767
 			fmt.Println(getNurseErr)
1770
 
1776
 
1771
 			redis := service.RedisClient()
1777
 			redis := service.RedisClient()
1772
 			redis.Set(key, "", time.Second)
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
 			redis.Set(keyOne, "", time.Second)
1780
 			redis.Set(keyOne, "", time.Second)
1775
 			defer redis.Close()
1781
 			defer redis.Close()
1776
 			fmt.Println(getNurseErr)
1782
 			fmt.Println(getNurseErr)
1871
 
1877
 
1872
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1878
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
1873
 	redis := service.RedisClient()
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
 	redis.Set(keyOne, "", time.Second)
1881
 	redis.Set(keyOne, "", time.Second)
1876
 
1882
 
1877
 	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_last"
1883
 	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_last"
1901
 		//清空key 值
1907
 		//清空key 值
1902
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
1911
 		redis.Set(keyOne, "", time.Second)
1906
 		//结束时候透析次数加1
1912
 		//结束时候透析次数加1
1907
 		service.UpdateSolutionByPatientId(id)
1913
 		service.UpdateSolutionByPatientId(id)
2153
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2159
 		createErr := service.MobileCreateDialysisOrder(adminUserInfo.Org.Id, patientID, dialysisRecord)
2154
 
2160
 
2155
 		redis := service.RedisClient()
2161
 		redis := service.RedisClient()
2156
-		defer redis.Close()
2157
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2162
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_order"
2158
 		redis.Set(key, "", time.Second)
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
 		//清空key 值
2165
 		//清空key 值
2161
 		redis.Set(keyOne, "", time.Second)
2166
 		redis.Set(keyOne, "", time.Second)
2162
 
2167
 
2183
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2188
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2184
 	//后期预增脱水量
2189
 	//后期预增脱水量
2185
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2190
 	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
2186
-	fmt.Println(evaluation)
2191
+
2187
 	if prescription.ID > 0 {
2192
 	if prescription.ID > 0 {
2188
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2193
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2189
 
2194
 
2261
 	if newdialysisRecord.ID > 0 {
2266
 	if newdialysisRecord.ID > 0 {
2262
 		err := service.CreateMonitor(&record)
2267
 		err := service.CreateMonitor(&record)
2263
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2268
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":monitor_records"
2269
+
2264
 		redis := service.RedisClient()
2270
 		redis := service.RedisClient()
2265
-		defer redis.Close()
2266
 		//清空key 值
2271
 		//清空key 值
2267
 		redis.Set(key, "", time.Second)
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
 		if err != nil {
2276
 		if err != nil {
2270
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2277
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
2271
 			return
2278
 			return
2626
 	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
2633
 	keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":schedual_detail"
2627
 	redis.Set(keyTwo, "", time.Second)
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
 	redis.Set(keyThree, "", time.Second)
2637
 	redis.Set(keyThree, "", time.Second)
2631
 
2638
 
2632
 	keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
2639
 	keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
2991
 
2998
 
2992
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
2999
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":dialysis_order"
2993
 	redis.Set(key, "", time.Second)
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
 	//清空key 值
3003
 	//清空key 值
2997
 	redis.Set(keyOne, "", time.Second)
3004
 	redis.Set(keyOne, "", time.Second)
2998
 	scheduleDateStartOne := startDate.Format("2006-01-02")
3005
 	scheduleDateStartOne := startDate.Format("2006-01-02")
2999
 	keyTwo := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
3006
 	keyTwo := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
3000
-	fmt.Println("keyTwo2332323232233223232323", keyTwo)
3007
+
3001
 	redis.Set(keyTwo, "", time.Second)
3008
 	redis.Set(keyTwo, "", time.Second)
3002
 
3009
 
3003
 	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":doctor_advices"
3010
 	keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(record_date, 10) + ":doctor_advices"
3014
 	keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":device_list_all"
3021
 	keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":device_list_all"
3015
 	redis.Set(keySeven, "", time.Second)
3022
 	redis.Set(keySeven, "", time.Second)
3016
 
3023
 
3017
-	defer redis.Close()
3018
 	if updateErr != nil {
3024
 	if updateErr != nil {
3019
 		this.ErrorLog("修改上机失败:%v", updateErr)
3025
 		this.ErrorLog("修改上机失败:%v", updateErr)
3020
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3026
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
3031
 			hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
3037
 			hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
3032
 			minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
3038
 			minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
3033
 			updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecord.PatientId, tempDialysisRecord.UserOrgId, tempDialysisRecord.DialysisDate, hour, minute)
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
 			if updateAssessmentErr != nil {
3052
 			if updateAssessmentErr != nil {
3035
 				utils.ErrorLog("%v", updateAssessmentErr)
3053
 				utils.ErrorLog("%v", updateAssessmentErr)
3036
 			}
3054
 			}
3097
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
3115
 	key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":dialysis_order"
3098
 	//清空key 值
3116
 	//清空key 值
3099
 	redis.Set(key, "", time.Second)
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
 	//清空key 值
3119
 	//清空key 值
3102
 	redis.Set(keyOne, "", time.Second)
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
 	redis.Close()
3124
 	redis.Close()
3104
 	if updateErr != nil {
3125
 	if updateErr != nil {
3105
 		c.ErrorLog("修改下机失败:%v", updateErr)
3126
 		c.ErrorLog("修改下机失败:%v", updateErr)
3123
 		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":assessment_after_dislysis_last"
3144
 		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(tempDialysisRecords.PatientId, 10) + ":" + strconv.FormatInt(tempDialysisRecords.DialysisDate, 10) + ":assessment_after_dislysis_last"
3124
 		redis.Set(keyTwo, "", time.Second)
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
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyThree, "", time.Second)
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
 		defer redis.Close()
3155
 		defer redis.Close()
3132
 		if updateAssessmentErr != nil {
3156
 		if updateAssessmentErr != nil {
3133
 			utils.ErrorLog("%v", updateAssessmentErr)
3157
 			utils.ErrorLog("%v", updateAssessmentErr)
3222
 		}
3246
 		}
3223
 		if err == nil {
3247
 		if err == nil {
3224
 			c.ServeSuccessJSON(map[string]interface{}{
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
 		//清空key 值
3560
 		//清空key 值
3536
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
3564
 		redis.Set(keyOne, "", time.Second)
3540
 
3565
 
3541
 		keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
3566
 		keyThree := "scheduals_" + adviceDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
3629
 
3654
 
3630
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3655
 		createErr := service.CreatePatientWeightAdjust(dryWeight)
3631
 		redis := service.RedisClient()
3656
 		redis := service.RedisClient()
3632
-		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
3633
-		redis.Set(keyOne, "", time.Second)
3634
 		loc, _ := time.LoadLocation("Local")
3657
 		loc, _ := time.LoadLocation("Local")
3635
 		nowTime := time.Now()
3658
 		nowTime := time.Now()
3636
 		nowDay := nowTime.Format("2006-01-02")
3659
 		nowDay := nowTime.Format("2006-01-02")
3637
 		dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
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
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3664
 		key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
3639
 		redis.Set(key, "", time.Second)
3665
 		redis.Set(key, "", time.Second)
3640
 		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
3666
 		keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
3845
 
3871
 
3846
 		//查询是否有库存
3872
 		//查询是否有库存
3847
 		for _, item := range dialysisBefor {
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
 			if err == gorm.ErrRecordNotFound {
3876
 			if err == gorm.ErrRecordNotFound {
3851
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3877
 				goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
3852
 				c.ServeSuccessJSON(map[string]interface{}{
3878
 				c.ServeSuccessJSON(map[string]interface{}{

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

172
 	redis := service.RedisClient()
172
 	redis := service.RedisClient()
173
 	//清空key 值
173
 	//清空key 值
174
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
176
 	redis.Set(keyOne, "", time.Second)
177
 	defer redis.Close()
177
 	defer redis.Close()
178
 	if err != nil {
178
 	if err != nil {
336
 	redis := service.RedisClient()
336
 	redis := service.RedisClient()
337
 	//清空key 值
337
 	//清空key 值
338
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
340
 	redis.Set(keyOne, "", time.Second)
341
 
341
 
342
 	defer redis.Close()
342
 	defer redis.Close()
380
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
380
 	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
381
 	orgid := this.GetMobileAdminUserInfo().Org.Id
381
 	orgid := this.GetMobileAdminUserInfo().Org.Id
382
 	redis := service.RedisClient()
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
 	redis.Set(key, "", time.Second)
384
 	redis.Set(key, "", time.Second)
385
 	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
385
 	keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
386
 	redis.Set(keyOne, "", time.Second)
386
 	redis.Set(keyOne, "", time.Second)
501
 			}
501
 			}
502
 			createErr := service.CreateSchedule(newSchedule)
502
 			createErr := service.CreateSchedule(newSchedule)
503
 			redis := service.RedisClient()
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
 			redis.Set(keyOne, "", time.Second)
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
 			redis.Set(keyTwo, "", time.Second)
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
 			redis.Set(keySix, "", time.Second)
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
 			redis.Set(keyThree, "", time.Second)
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
 			redis.Set(keyFour, "", time.Second)
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
 			redis.Set(keyFive, "", time.Second)
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
 			redis.Set(keySeven, "", time.Second)
527
 			redis.Set(keySeven, "", time.Second)
526
 			redis.Close()
528
 			redis.Close()
527
 			if createErr != nil {
529
 			if createErr != nil {
561
 					daySchedule.UpdatedTime = time.Now().Unix()
563
 					daySchedule.UpdatedTime = time.Now().Unix()
562
 					err := service.UpdateSchedule(&daySchedule)
564
 					err := service.UpdateSchedule(&daySchedule)
563
 					redis := service.RedisClient()
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
 					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
571
 					keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
566
 					redis.Set(keyOne, "", time.Second)
572
 					redis.Set(keyOne, "", time.Second)

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

244
 	redis := service.RedisClient()
244
 	redis := service.RedisClient()
245
 	defer redis.Close()
245
 	defer redis.Close()
246
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
248
 	redis.Set(keyOne, "", time.Second)
249
 	if err != nil {
249
 	if err != nil {
250
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
250
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
327
 
327
 
328
 				defer redis.Close()
328
 				defer redis.Close()
329
 				redis.Set(key, "", time.Second)
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
 				redis.Set(keyOne, "", time.Second)
331
 				redis.Set(keyOne, "", time.Second)
332
 			}
332
 			}
333
 		} else if len(adviceSlice) > 1 {
333
 		} else if len(adviceSlice) > 1 {
339
 
339
 
340
 				defer redis.Close()
340
 				defer redis.Close()
341
 				redis.Set(key, "", time.Second)
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
 				redis.Set(keyOne, "", time.Second)
343
 				redis.Set(keyOne, "", time.Second)
344
 				isChangeGroup = false
344
 				isChangeGroup = false
345
 
345
 
352
 
352
 
353
 				defer redis.Close()
353
 				defer redis.Close()
354
 				redis.Set(key, "", time.Second)
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
 				redis.Set(keyOne, "", time.Second)
356
 				redis.Set(keyOne, "", time.Second)
357
 				isChangeGroup = true
357
 				isChangeGroup = true
358
 
358
 
363
 		err = service.UpdateDoctorAdvice(&advice)
363
 		err = service.UpdateDoctorAdvice(&advice)
364
 		redis := service.RedisClient()
364
 		redis := service.RedisClient()
365
 		defer redis.Close()
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
 		redis.Set(key, "", time.Second)
367
 		redis.Set(key, "", time.Second)
368
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
368
 		keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
369
 		redis.Set(keyOne, "", time.Second)
369
 		redis.Set(keyOne, "", time.Second)
627
 			redis := service.RedisClient()
627
 			redis := service.RedisClient()
628
 			//清空key 值
628
 			//清空key 值
629
 			redis.Set(key, "", time.Second)
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
 			redis.Set(keyTwo, "", time.Second)
631
 			redis.Set(keyTwo, "", time.Second)
632
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
632
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
633
 			redis.Set(keyThree, "", time.Second)
633
 			redis.Set(keyThree, "", time.Second)
638
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
638
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
639
 			fmt.Println("keyFour323223323232323232", keyFour)
639
 			fmt.Println("keyFour323223323232323232", keyFour)
640
 			redis.Set(keyFour, "", time.Second)
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
 			defer redis.Close()
644
 			defer redis.Close()
642
 		} else {
645
 		} else {
643
 
646
 
644
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
647
 			err = service.BatchExceOldDoctorAdvice(&advices, ids)
645
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
648
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
646
 			redis := service.RedisClient()
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
 			redis.Set(keyTwo, "", time.Second)
651
 			redis.Set(keyTwo, "", time.Second)
649
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
652
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
650
 			redis.Set(keyThree, "", time.Second)
653
 			redis.Set(keyThree, "", time.Second)
654
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
657
 			keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
655
 			fmt.Println("keyFour323223323232323232", keyFour)
658
 			fmt.Println("keyFour323223323232323232", keyFour)
656
 			redis.Set(keyFour, "", time.Second)
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
 			defer redis.Close()
662
 			defer redis.Close()
658
 			//清空key 值
663
 			//清空key 值
659
 			redis.Set(key, "", time.Second)
664
 			redis.Set(key, "", time.Second)
936
 		timeLayout2 := "2006-01-02 15:04:05"
941
 		timeLayout2 := "2006-01-02 15:04:05"
937
 		loc, _ := time.LoadLocation("Local")
942
 		loc, _ := time.LoadLocation("Local")
938
 		theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
943
 		theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
944
+
939
 		if errs != nil {
945
 		if errs != nil {
940
 			utils.ErrorLog(errs.Error())
946
 			utils.ErrorLog(errs.Error())
941
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
947
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
969
 			redis := service.RedisClient()
975
 			redis := service.RedisClient()
970
 			//清空key 值
976
 			//清空key 值
971
 			redis.Set(key, "", time.Second)
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
 			redis.Set(keyTwo, "", time.Second)
979
 			redis.Set(keyTwo, "", time.Second)
974
 			keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
980
 			keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
975
 			redis.Set(keyThree, "", time.Second)
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
 			redis.Set(keyFour, "", time.Second)
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
 			defer redis.Close()
989
 			defer redis.Close()
979
 		}
990
 		}
980
 
991
 
1129
 	}
1140
 	}
1130
 	var err error
1141
 	var err error
1131
 	if groupno > 0 {
1142
 	if groupno > 0 {
1143
+
1132
 		err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
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
 	} else {
1154
 	} else {
1135
 		err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
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
 	//判断是否开启his
1167
 	//判断是否开启his
1144
 			UpdatedTime:   time.Now().Unix(),
1173
 			UpdatedTime:   time.Now().Unix(),
1145
 		}
1174
 		}
1146
 		fmt.Println("ids2323232232323", ids)
1175
 		fmt.Println("ids2323232232323", ids)
1176
+		var advicehis models.HisDoctorAdviceInfo
1147
 		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
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
 		project := models.HisPrescriptionProject{
1194
 		project := models.HisPrescriptionProject{
1150
 			ExecutionTime: theTime.Unix(),
1195
 			ExecutionTime: theTime.Unix(),
1151
 			Mtime:         time.Now().Unix(),
1196
 			Mtime:         time.Now().Unix(),
1152
 		}
1197
 		}
1153
 		service.ModifyHisPrescriptionProject(&project, ids)
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
 	if err != nil {
1209
 	if err != nil {
1157
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1210
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1242
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1295
 			err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
1243
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1296
 			key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
1244
 			redis := service.RedisClient()
1297
 			redis := service.RedisClient()
1245
-			defer redis.Close()
1246
 			//清空key 值
1298
 			//清空key 值
1247
 			redis.Set(key, "", time.Second)
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
 		} else {
1311
 		} else {
1249
 
1312
 
1250
 			if len(ids[0]) <= 0 {
1313
 			if len(ids[0]) <= 0 {
1256
 				//loc, _ := time.LoadLocation("Local")
1319
 				//loc, _ := time.LoadLocation("Local")
1257
 				//theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
1320
 				//theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
1258
 				err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
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
 			item.CheckTime = time.Now().Unix()
1369
 			item.CheckTime = time.Now().Unix()
1293
 			item.CheckState = 1
1370
 			item.CheckState = 1
1294
 			err = service.SaveHisDoctorAdvice(item)
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
 			redis := service.RedisClient()
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
 			//清空key 值
1374
 			//清空key 值
1299
 			redis.Set(key, "", time.Second)
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
 		if err == nil {
1390
 		if err == nil {
1302
 			c.ServeSuccessJSON(map[string]interface{}{
1391
 			c.ServeSuccessJSON(map[string]interface{}{
1637
 	defer redis.Close()
1726
 	defer redis.Close()
1638
 	//清空key 值
1727
 	//清空key 值
1639
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
1730
 	redis.Set(keyOne, "", time.Second)
1642
 	keyTwo := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1731
 	keyTwo := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
1643
 	redis.Set(keyTwo, "", time.Second)
1732
 	redis.Set(keyTwo, "", time.Second)
2047
 		blood_access_part_id := dataBody["blood_access_part_id"].(string)
2136
 		blood_access_part_id := dataBody["blood_access_part_id"].(string)
2048
 		evaluation.BloodAccessPartId = blood_access_part_id
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
 	if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
2143
 	if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
2052
 		blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
2144
 		blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
2053
 		evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
2145
 		evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
2066
 		is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
2158
 		is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
2067
 		evaluation.IsHemorrhage = is_hemorrhage
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
 		if is_hemorrhage != 1 && is_hemorrhage != 2 {
2164
 		if is_hemorrhage != 1 && is_hemorrhage != 2 {
2070
 			is_hemorrhage = 0
2165
 			is_hemorrhage = 0
2071
 		}
2166
 		}
2181
 
2276
 
2182
 		humor_excessive_symptom, _ := dataBody["humor_excessive_symptom"].(string)
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
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2279
 		evaluation.HumorExcessiveSymptom = humor_excessive_symptom
2187
 	}
2280
 	}
2188
 
2281
 
2621
 			//获取透前评估
2714
 			//获取透前评估
2622
 			assessmentBefores, _ := service.GetAllAssessmentBeforesByListOne(orgID, theStartTime)
2715
 			assessmentBefores, _ := service.GetAllAssessmentBeforesByListOne(orgID, theStartTime)
2623
 			//获取上机
2716
 			//获取上机
2624
-			dialysisOrders, _ := service.GetAllDialysisOrdersByListOne(orgID, theStartTime)
2717
+			dialysisOrders, _ := service.GetAllDialysisOrdersByListSix(orgID, theStartTime)
2625
 			//获取透后
2718
 			//获取透后
2626
 			AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListOne(orgID, theStartTime)
2719
 			AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListOne(orgID, theStartTime)
2627
 
2720
 
3164
 		redis := service.RedisClient()
3257
 		redis := service.RedisClient()
3165
 		//清空key 值
3258
 		//清空key 值
3166
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
3261
 		redis.Set(keyOne, "", time.Second)
3169
 
3262
 
3170
 		defer redis.Close()
3263
 		defer redis.Close()
3237
 		redis := service.RedisClient()
3330
 		redis := service.RedisClient()
3238
 		//清空key 值
3331
 		//清空key 值
3239
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyOne, "", time.Second)
3334
 		redis.Set(keyOne, "", time.Second)
3242
 		fmt.Println("key`2232333332233223233232", key)
3335
 		fmt.Println("key`2232333332233223233232", key)
3243
 		defer redis.Close()
3336
 		defer redis.Close()
3376
 
3469
 
3377
 		redis.Set(key, "", time.Second)
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
 		redis.Set(keyTwo, "", time.Second)
3473
 		redis.Set(keyTwo, "", time.Second)
3381
 		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3474
 		keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3382
 		redis.Set(keyThree, "", time.Second)
3475
 		redis.Set(keyThree, "", time.Second)
3440
 
3533
 
3441
 			redis.Set(key, "", time.Second)
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
 			redis.Set(keyTwo, "", time.Second)
3538
 			redis.Set(keyTwo, "", time.Second)
3445
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3539
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
3446
 			redis.Set(keyThree, "", time.Second)
3540
 			redis.Set(keyThree, "", time.Second)
3451
 
3545
 
3452
 			redis.Set(key, "", time.Second)
3546
 			redis.Set(key, "", time.Second)
3453
 			fmt.Println("key2332323223323232323232323", key)
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
 			fmt.Println("key2332323223323232323232323", keyTwo)
3549
 			fmt.Println("key2332323223323232323232323", keyTwo)
3456
 			redis.Set(keyTwo, "", time.Second)
3550
 			redis.Set(keyTwo, "", time.Second)
3457
 			keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
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
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
273
 	_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetMobileAdminUserInfo().Org.Id)
274
 
274
 
275
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
275
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
276
+
276
 	if err == nil {
277
 	if err == nil {
277
 		if len(projects) > 0 {
278
 		if len(projects) > 0 {
278
 			for _, item := range projects {
279
 			for _, item := range projects {
303
 					if item.PrescribingNumberUnit == drug.MinUnit {
304
 					if item.PrescribingNumberUnit == drug.MinUnit {
304
 						drug.Total = drug.Total + item.PrescribingNumber
305
 						drug.Total = drug.Total + item.PrescribingNumber
305
 						service.UpdateBaseDrugLib(&drug)
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
 					} else {
311
 					} else {
307
 						if item.PrescribingNumberUnit == drug.MaxUnit {
312
 						if item.PrescribingNumberUnit == drug.MaxUnit {
308
 							item.PrescribingNumber = item.PrescribingNumber * float64(drug.MinNumber)
313
 							item.PrescribingNumber = item.PrescribingNumber * float64(drug.MinNumber)
721
 								return
726
 								return
722
 							}
727
 							}
723
 							service.CreateHisDoctorAdvice(&s)
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
 							var randNum int
738
 							var randNum int
725
 							randNum = rand.Intn(10000) + 1000
739
 							randNum = rand.Intn(10000) + 1000
726
 							timestamp := time.Now().Unix()
740
 							timestamp := time.Now().Unix()
729
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
743
 							s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
730
 							service.CreateHisDoctorAdvice(&s)
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
 	id, _ := this.GetInt64("id")
310
 	id, _ := this.GetInt64("id")
311
 	fmt.Println("id", id)
311
 	fmt.Println("id", id)
312
 	err := service.DeleteSchedule(id)
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
 	fmt.Println(err)
344
 	fmt.Println(err)
314
 	returnData := make(map[string]interface{}, 0)
345
 	returnData := make(map[string]interface{}, 0)
315
 	returnData["msg"] = "ok"
346
 	returnData["msg"] = "ok"

+ 168 - 8
controllers/patient_api_controller.go View File

1418
 	redis := service.RedisClient()
1418
 	redis := service.RedisClient()
1419
 	defer redis.Close()
1419
 	defer redis.Close()
1420
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
1422
 	redis.Set(keyOne, "", time.Second)
1423
 	if err != nil {
1423
 	if err != nil {
1424
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1424
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1506
 	redis := service.RedisClient()
1506
 	redis := service.RedisClient()
1507
 	defer redis.Close()
1507
 	defer redis.Close()
1508
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
1510
 	redis.Set(keyOne, "", time.Second)
1511
 	if err != nil {
1511
 	if err != nil {
1512
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1512
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
1650
 		}
1650
 		}
1651
 		if advice.ParentId > 0 {
1651
 		if advice.ParentId > 0 {
1652
 			err = service.ExceDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
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
 		} else {
1672
 		} else {
1654
 			err = service.ExceDoctorAdviceById(&exceAdvice, id, patient)
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
 		if err != nil {
1695
 		if err != nil {
1669
 
1707
 
1670
 		//药品管理信息
1708
 		//药品管理信息
1671
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
1709
 		_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
1672
-		fmt.Println("999999992322322323232", drugStockConfig.IsOpen)
1710
+
1673
 		//自备药信息
1711
 		//自备药信息
1674
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
1712
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.CurrentOrgId)
1675
-		fmt.Println("drugStockConfig2323232332232332", drugStockConfig.IsOpen)
1713
+
1676
 		if drugStockConfig.IsOpen == 1 {
1714
 		if drugStockConfig.IsOpen == 1 {
1677
 			var total int64
1715
 			var total int64
1678
 			var prescribing_number_total int64
1716
 			var prescribing_number_total int64
1679
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1717
 			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1680
 			for _, item := range advices {
1718
 			for _, item := range advices {
1681
-				fmt.Println("imte00000000000000", item.PrescribingNumber)
1719
+
1682
 				//查询该药品是否有库存
1720
 				//查询该药品是否有库存
1683
 				list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
1721
 				list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId)
1684
-				fmt.Println("list23232323232232323232323232", list)
1722
+
1685
 				//查询改药品信息
1723
 				//查询改药品信息
1686
 				medical, _ := service.GetBaseDrugMedical(item.DrugId)
1724
 				medical, _ := service.GetBaseDrugMedical(item.DrugId)
1687
 				//判断单位是否相等
1725
 				//判断单位是否相等
1832
 		}
1870
 		}
1833
 		if advice.ParentId > 0 {
1871
 		if advice.ParentId > 0 {
1834
 			err = service.ExceHidDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
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
 		} else {
1892
 		} else {
1836
 			err = service.ExceHidDoctorAdviceById(&exceAdvice, id, patient)
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
 		if err != nil {
1915
 		if err != nil {
2035
 		var err error
2111
 		var err error
2036
 		if advice.ParentId > 0 {
2112
 		if advice.ParentId > 0 {
2037
 			err = service.CheckDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
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
 		} else {
2128
 		} else {
2039
 			err = service.CheckDoctorAdviceById(&exceAdvice, id, patient)
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
 		if err != nil {
2146
 		if err != nil {
2094
 		var err error
2198
 		var err error
2095
 		if advice.ParentId > 0 {
2199
 		if advice.ParentId > 0 {
2096
 			err = service.CheckHisDoctorAdviceById(&exceAdvice, advice.ParentId, patient)
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
 		} else {
2215
 		} else {
2098
 			err = service.CheckHisDoctorAdviceById(&exceAdvice, id, patient)
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
 		if err != nil {
2233
 		if err != nil {
2170
 
2302
 
2171
 	err := service.UpdateDoctorAdvice(&advice)
2303
 	err := service.UpdateDoctorAdvice(&advice)
2172
 	redis := service.RedisClient()
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
 	redis.Set(key, "", time.Second)
2308
 	redis.Set(key, "", time.Second)
2309
+	fmt.Println("key2332233232322332", key)
2176
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2310
 	keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
2177
 	redis.Set(keyOne, "", time.Second)
2311
 	redis.Set(keyOne, "", time.Second)
2312
+	fmt.Println("key3333333333333333", keyOne)
2313
+	defer redis.Close()
2178
 	if err != nil {
2314
 	if err != nil {
2179
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
2315
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
2180
 		return
2316
 		return
2377
 	advice.Modifier = adminUserInfo.AdminUser.Id
2513
 	advice.Modifier = adminUserInfo.AdminUser.Id
2378
 
2514
 
2379
 	err := service.DeleteDoctorAdvice(&advice)
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
 	if err != nil {
2520
 	if err != nil {
2381
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2521
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2382
 		return
2522
 		return
2416
 	//}
2556
 	//}
2417
 
2557
 
2418
 	err := service.DeleteGroupAdvice(adminUserInfo.CurrentOrgId, groupNo, adminUserInfo.AdminUser.Id)
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
 	if err != nil {
2566
 	if err != nil {
2420
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2567
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
2421
 		return
2568
 		return
4495
 		StartTime: theTime.Unix(),
4642
 		StartTime: theTime.Unix(),
4496
 	}
4643
 	}
4497
 	err := service.UpdateDoctorEditAdvice(advice, orgid, groupno, date, patient_id)
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
 	if err != nil {
4658
 	if err != nil {
4499
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4659
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
4500
 		return
4660
 		return

+ 32 - 7
controllers/schedule_api_controller.go View File

372
 
372
 
373
 	redis.Set(key, "", time.Second)
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
 	redis.Set(keyOne, "", time.Second)
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
 	redis.Set(keyTwo, "", time.Second)
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
 	redis.Set(keySix, "", time.Second)
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
 	redis.Set(keyThree, "", time.Second)
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
 	redis.Set(keyFour, "", time.Second)
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
 	redis.Set(keyFive, "", time.Second)
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
 	redis.Set(keySeven, "", time.Second)
394
 	redis.Set(keySeven, "", time.Second)
395
 	fmt.Println(err)
395
 	fmt.Println(err)
396
 	defer redis.Close()
396
 	defer redis.Close()
436
 	schedule.Status = 0
436
 	schedule.Status = 0
437
 	schedule.UpdatedTime = time.Now().Unix()
437
 	schedule.UpdatedTime = time.Now().Unix()
438
 	err = service.UpdateSchedule(schedule)
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
 	if err != nil {
464
 	if err != nil {
440
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
465
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
441
 		return
466
 		return

+ 2 - 1
controllers/stock_in_api_controller.go View File

1698
 	if len(upDateWarehouseOutInfos) > 0 {
1698
 	if len(upDateWarehouseOutInfos) > 0 {
1699
 		for _, item := range upDateWarehouseOutInfos {
1699
 		for _, item := range upDateWarehouseOutInfos {
1700
 			fmt.Println("item2332323232323", item.ProductDate, item.ExpiryDate)
1700
 			fmt.Println("item2332323232323", item.ProductDate, item.ExpiryDate)
1701
+
1701
 			//1.查询该耗材该批次的最后一次出库记录
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
 	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
81
 	CancelStockInfo             []*CancelStockInfo   `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"cancel_stock_info"`
82
 	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
82
 	RegisterNumber              string               `gorm:"column:register_number" json:"register_number" form:"register_number"`
83
 	GoodSotckInfo               []*GoodSotckInfo     `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_stock_in"`
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
 func (GoodInfo) TableName() string {
86
 func (GoodInfo) TableName() string {

+ 0 - 25
models/his_charge_models.go View File

204
 	return "his_label_print_info"
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
 type HisFapiaoRecord struct {
207
 type HisFapiaoRecord struct {
233
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
208
 	ID           int64  `gorm:"column:id" json:"id" form:"id"`
234
 	FapiaoCode   string `gorm:"column:fapiao_code" json:"fapiao_code" form:"fapiao_code"`
209
 	FapiaoCode   string `gorm:"column:fapiao_code" json:"fapiao_code" form:"fapiao_code"`

+ 0 - 47
models/his_models.go View File

776
 
776
 
777
 	XtHisProjectTeam XtHisProjectTeam `gorm:"ForeignKey:TeamId;AssociationForeignKey:ID" json:"team"`
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
 	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
779
 	FrequencyType int64        `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
784
 	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
780
 	DayCount      int64        `gorm:"column:day_count" json:"day_count" form:"day_count"`
785
 	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
781
 	WeekDay       string       `gorm:"column:week_day" json:"week_day" form:"week_day"`
1066
 	return "his_order_info"
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
 type VMHisPatient struct {
1065
 type VMHisPatient struct {
1113
 	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1066
 	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
1114
 	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
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
 	OxygenUptake               int64         `gorm:"column:oxygen_uptake" json:"oxygen_uptake" form:"oxygen_uptake"`
309
 	OxygenUptake               int64         `gorm:"column:oxygen_uptake" json:"oxygen_uptake" form:"oxygen_uptake"`
310
 	OxygenFlow                 string        `gorm:"column:oxygen_flow" json:"oxygen_flow" form:"oxygen_flow"`
310
 	OxygenFlow                 string        `gorm:"column:oxygen_flow" json:"oxygen_flow" form:"oxygen_flow"`
311
 	OxygenTime                 string        `gorm:"column:oxygen_time" json:"oxygen_time" form:"oxygen_time"`
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
 func (DialysisPrescription) TableName() string {
321
 func (DialysisPrescription) TableName() string {
324
 }
323
 }
325
 
324
 
326
 type DialysisPrescriptionList struct {
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
 	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
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
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
403
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
337
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
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
 	HemodialysisPipelines      string  `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
417
 	HemodialysisPipelines      string  `gorm:"column:hemodialysis_pipelines" json:"hemodialysis_pipelines" form:"hemodialysis_pipelines"`
340
 	HemodialysisPipelinesCount float64 `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
418
 	HemodialysisPipelinesCount float64 `gorm:"column:hemodialysis_pipelines_count" json:"hemodialysis_pipelines_count" form:"hemodialysis_pipelines_count"`
341
 	PunctureNeedle             string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
419
 	PunctureNeedle             string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
342
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
420
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
343
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
421
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
344
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
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
 func (DialysisPrescriptionList) TableName() string {
426
 func (DialysisPrescriptionList) TableName() string {
1388
 func (MsDeviceZone) TableName() string {
1467
 func (MsDeviceZone) TableName() string {
1389
 	return "xt_device_zone"
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
 func (PatientWarehouseInfo) TableName() string {
1145
 func (PatientWarehouseInfo) TableName() string {
1146
 	return "xt_warehouse_info"
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
 
274
 
275
 //修改透析处方
275
 //修改透析处方
276
 func UpDateDialysisPrescription(dialysisPrescription *models.DialysisPrescription) error {
276
 func UpDateDialysisPrescription(dialysisPrescription *models.DialysisPrescription) error {
277
+	tx := writeDb.Begin()
277
 	err := writeDb.Save(&dialysisPrescription).Error
278
 	err := writeDb.Save(&dialysisPrescription).Error
279
+	if err != nil {
280
+		tx.Rollback()
281
+	}
282
+	tx.Commit()
278
 	return err
283
 	return err
279
 }
284
 }
280
 
285
 
1370
 	return err
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
 func ModifyHisPrescriptionProject(m *models.HisPrescriptionProject, ids []string) (err error) {
1383
 func ModifyHisPrescriptionProject(m *models.HisPrescriptionProject, ids []string) (err error) {
1374
 	ut := writeDb.Begin()
1384
 	ut := writeDb.Begin()
1375
 	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
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
 func GetAllPcAdvicestByList(orgID int64, scheduleDate int64) (advices []*VMDoctorAdvice, err error) {
1448
 func GetAllPcAdvicestByList(orgID int64, scheduleDate int64) (advices []*VMDoctorAdvice, err error) {
1439
 	redis := RedisClient()
1449
 	redis := RedisClient()
1440
 	defer redis.Close()
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
 	advice_list_str, _ := redis.Get(key).Result()
1453
 	advice_list_str, _ := redis.Get(key).Result()
1443
 
1454
 
1444
 	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1455
 	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1478
 func GetAllPcDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVMList, err error) {
1489
 func GetAllPcDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*MDialysisOrderVMList, err error) {
1479
 	redis := RedisClient()
1490
 	redis := RedisClient()
1480
 	defer redis.Close()
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
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
1493
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
1483
 
1494
 
1484
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1495
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1516
 func GetAllPcAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*AssessmentAfterDislysis, err error) {
1527
 func GetAllPcAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*AssessmentAfterDislysis, err error) {
1517
 	redis := RedisClient()
1528
 	redis := RedisClient()
1518
 	defer redis.Close()
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
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
1531
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
1521
 
1532
 
1522
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1533
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1556
 func GetAllPcTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*VMTreatmentSummary, err error) {
1567
 func GetAllPcTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*VMTreatmentSummary, err error) {
1557
 	redis := RedisClient()
1568
 	redis := RedisClient()
1558
 	defer redis.Close()
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
 	treatment_summarys_all, _ := redis.Get(key).Result()
1571
 	treatment_summarys_all, _ := redis.Get(key).Result()
1561
 
1572
 
1562
 	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
1573
 	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis

+ 4 - 4
service/gobal_config_service.go View File

590
 func GetAllBaseDurgListCount(page int64, limit int64, keyword string, drugcategory int64, startime int64, endtime int64, orgid int64) (drug []*models.VmBaseDrug, total int64, err error) {
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
 	offset := (page - 1) * limit
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
 	likeKey := "%" + keyword + "%"
594
 	likeKey := "%" + keyword + "%"
595
 	if orgid > 0 {
595
 	if orgid > 0 {
596
 		db = db.Where("org_id = ?", orgid)
596
 		db = db.Where("org_id = ?", orgid)
727
 }
727
 }
728
 
728
 
729
 func GetOutDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseInfo, err error) {
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
 	if startime > 0 {
732
 	if startime > 0 {
733
 		db = db.Where("x.ctime >=?", startime)
733
 		db = db.Where("x.ctime >=?", startime)
743
 }
743
 }
744
 
744
 
745
 func GetAutoDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugAutomaticReduceDetail, err error) {
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
 	if startime > 0 {
748
 	if startime > 0 {
749
 		db = db.Where("x.record_time >=?", startime)
749
 		db = db.Where("x.record_time >=?", startime)
761
 
761
 
762
 func GetCancelDrugCountList(startime int64, endtime int64, orgid int64) (info []*models.DrugCancelStockInfo, err error) {
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
 	if startime > 0 {
766
 	if startime > 0 {
767
 		db = db.Where("x.ctime >=?", startime)
767
 		db = db.Where("x.ctime >=?", startime)

+ 22 - 0
service/manage_center_service.go View File

173
 	return
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
 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) {
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
 	db := readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id)
200
 	db := readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id)

+ 101 - 47
service/mobile_dialysis_service.go View File

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
 func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
609
 func MobileGetPredialysisEvaluation(orgID int64, patientID int64, recordDate int64) (*models.PredialysisEvaluation, error) {
595
 
610
 
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
 // 获取 maxDate 之前一次的透前评估记录
664
 // 获取 maxDate 之前一次的透前评估记录
636
 func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDate int64) (*models.PredialysisEvaluation, error) {
665
 func MobileGetLastTimePredialysisEvaluation(orgID int64, patientID int64, maxDate int64) (*models.PredialysisEvaluation, error) {
637
 	var record models.PredialysisEvaluation
666
 	var record models.PredialysisEvaluation
701
 
730
 
702
 	// cur_date := time.Now().Format("2006-01-02")
731
 	// cur_date := time.Now().Format("2006-01-02")
703
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
732
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":doctor_advices"
704
-	fmt.Println("医嘱keyh23232323223", key)
733
+
705
 	doctor_advices_str, _ := redis.Get(key).Result()
734
 	doctor_advices_str, _ := redis.Get(key).Result()
706
-	fmt.Println("长度hh2332233232233232", len(doctor_advices_str))
735
+
707
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
736
 	if len(doctor_advices_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
708
 		err := readDb.Model(&models.DoctorAdvice{}).
737
 		err := readDb.Model(&models.DoctorAdvice{}).
709
 			Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ? and (advice_type = 2 || advice_type = 3)", patientID, orgID, recordDate).
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
 	// cur_date := time.Now().Format("2006-01-02")
866
 	// cur_date := time.Now().Format("2006-01-02")
838
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
867
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":monitor_records"
839
 	monitor_records_str, _ := redis.Get(key).Result()
868
 	monitor_records_str, _ := redis.Get(key).Result()
840
-	fmt.Println("监测23323232323233232", len(monitor_records_str))
869
+
841
 	if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
870
 	if len(monitor_records_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
842
 		err := readDb.Model(&models.MonitoringRecord{}).Where("patient_id = ? and user_org_id = ? and status = 1 and monitoring_date = ?", patientID, orgID, recordDate).Order("operate_time asc").Find(&records).Error
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
 		if err != nil {
872
 		if err != nil {
881
 	return &records, nil
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
 func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
926
 func MobileGetLastMonitorRecord(orgID int64, patientID int64, beforeDate int64) (*models.MonitoringRecord, error) {
885
 	var record models.MonitoringRecord
927
 	var record models.MonitoringRecord
886
 	redis := RedisClient()
928
 	redis := RedisClient()
1057
 		if err != nil {
1099
 		if err != nil {
1058
 			if err == gorm.ErrRecordNotFound {
1100
 			if err == gorm.ErrRecordNotFound {
1059
 				if record.ID <= 0 {
1101
 				if record.ID <= 0 {
1060
-					fmt.Println("创建成功没有", treatment_summary_str)
1102
+
1061
 					redis.Set(key, "null", time.Second*60*60*18)
1103
 					redis.Set(key, "null", time.Second*60*60*18)
1062
 				}
1104
 				}
1063
 				return nil, nil
1105
 				return nil, nil
1090
 // 透析处方
1132
 // 透析处方
1091
 func MobileGetDialysisPrescribe(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
1133
 func MobileGetDialysisPrescribe(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
1092
 	var record models.DialysisPrescription
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
 	if err != nil {
1136
 	if err != nil {
1095
 		if err == gorm.ErrRecordNotFound {
1137
 		if err == gorm.ErrRecordNotFound {
1096
 			return nil, nil
1138
 			return nil, nil
1955
 	redis := RedisClient()
1997
 	redis := RedisClient()
1956
 	defer redis.Close()
1998
 	defer redis.Close()
1957
 
1999
 
1958
-	// cur_date := time.Now().Format("2006-01-02")
1959
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":last_dry_weight"
2000
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":last_dry_weight"
1960
 	last_dry_weight_str, _ := redis.Get(key).Result()
2001
 	last_dry_weight_str, _ := redis.Get(key).Result()
1961
 
2002
 
2100
 
2141
 
2101
 func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
2142
 func MobileGetDialysisPrescribeByModeIdOne(orgID int64, patientID int64, recordDate int64) (*models.DialysisPrescription, error) {
2102
 	var record models.DialysisPrescription
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
 		} else {
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
 func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.DialysisPrescription, error) {
2203
 func MobileGetLastDialysisPrescribe(orgID int64, patientID int64) (*models.DialysisPrescription, error) {
2150
 	var record models.DialysisPrescription
2204
 	var record models.DialysisPrescription
2151
 	err := readDb.Model(&models.DialysisPrescription{}).Where("patient_id = ? and user_org_id = ? and status = 1 ", patientID, orgID).Last(&record).Error
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
 func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMDoctorAdviceForList, err error) {
162
 func GetAllAdvicestByList(orgID int64, scheduleDate int64) (advices []models.VMDoctorAdviceForList, err error) {
163
 	redis := RedisClient()
163
 	redis := RedisClient()
164
 	defer redis.Close()
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
 	advice_list_str, _ := redis.Get(key).Result()
166
 	advice_list_str, _ := redis.Get(key).Result()
167
 
167
 
168
 	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
168
 	if len(advice_list_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
202
 func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
202
 func GetAllPrescriptionsByList(orgID int64, scheduleDate int64) (prescriptions []*models.DialysisPrescriptionList, err error) {
203
 	redis := RedisClient()
203
 	redis := RedisClient()
204
 	defer redis.Close()
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
 	prescriptions_list_all, _ := redis.Get(key).Result()
206
 	prescriptions_list_all, _ := redis.Get(key).Result()
207
-	fmt.Println("铲毒23322332323232323", len(prescriptions_list_all))
207
+
208
 	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
208
 	if len(prescriptions_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
209
 		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
209
 		err = readDb.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Find(&prescriptions).Error
210
 		if err != nil {
210
 		if err != nil {
242
 func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluationList, err error) {
242
 func GetAllAssessmentBeforesByList(orgID int64, scheduleDate int64) (assessmentBefores []*models.PredialysisEvaluationList, err error) {
243
 	redis := RedisClient()
243
 	redis := RedisClient()
244
 	defer redis.Close()
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
 	assessment_befores_list_all, _ := redis.Get(key).Result()
246
 	assessment_befores_list_all, _ := redis.Get(key).Result()
247
 
247
 
248
 	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
248
 	if len(assessment_befores_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
282
 func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
282
 func GetAllDialysisOrdersByList(orgID int64, scheduleDate int64) (dialysisOrders []*models.MDialysisOrderForList, err error) {
283
 	redis := RedisClient()
283
 	redis := RedisClient()
284
 	defer redis.Close()
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
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
286
 	dialysis_orders_list_all, _ := redis.Get(key).Result()
287
-	fmt.Println("dialysis_orders_list_all23323223232323323232332", len(dialysis_orders_list_all))
287
+
288
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
288
 	if len(dialysis_orders_list_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
289
 		err = readDb.Model(&models.MDialysisOrderForList{}).Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).Where("status = 1 AND user_org_id = ? AND dialysis_date = ?", orgID, scheduleDate).Find(&dialysisOrders).Error
289
 		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
 func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*models.VMTreatmentSummaryForList, err error) {
320
 func GetAllTreatmentSummarysByList(orgID int64, scheduleDate int64) (treatmentSummarys []*models.VMTreatmentSummaryForList, err error) {
321
 	redis := RedisClient()
321
 	redis := RedisClient()
322
 	defer redis.Close()
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
 	treatment_summarys_all, _ := redis.Get(key).Result()
324
 	treatment_summarys_all, _ := redis.Get(key).Result()
325
 
325
 
326
 	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
326
 	if len(treatment_summarys_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
359
 func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.VMAssessmentAfterDislysis, err error) {
359
 func GetAllAssessmentAfterDislysisByList(orgID int64, scheduleDate int64) (assessmentAfterDislysis []*models.VMAssessmentAfterDislysis, err error) {
360
 	redis := RedisClient()
360
 	redis := RedisClient()
361
 	defer redis.Close()
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
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
363
 	assessment_after_dislysis__all, _ := redis.Get(key).Result()
364
 
364
 
365
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
365
 	if len(assessment_after_dislysis__all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
399
 func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHisDoctorAdviceInfo, err error) {
399
 func GetAllHisAdvicesByList(orgID int64, scheduleDate int64) (hisAdvices []VMHisDoctorAdviceInfo, err error) {
400
 	redis := RedisClient()
400
 	redis := RedisClient()
401
 	defer redis.Close()
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
 	his_advices_all, _ := redis.Get(key).Result()
403
 	his_advices_all, _ := redis.Get(key).Result()
404
-
404
+	fmt.Println("hish233232222332232323232323", len(his_advices_all))
405
 	if len(his_advices_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
405
 	if len(his_advices_all) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
406
 		err = readDb.Model(&VMHisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).Find(&hisAdvices).Error
406
 		err = readDb.Model(&VMHisDoctorAdviceInfo{}).Where("status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).Find(&hisAdvices).Error
407
 		if err != nil {
407
 		if err != nil {
1958
 	return
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
 	err := XTWriteDB().Model(&summary).Where("id in(?)", ids).Updates(map[string]interface{}{"status": 0}).Error
1836
 	err := XTWriteDB().Model(&summary).Where("id in(?)", ids).Updates(map[string]interface{}{"status": 0}).Error
1837
 	return err
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
 }
320
 }
321
 
321
 
322
 func FindAllGoodType(org_id int64) (goodType []*models.GoodsType, err error) {
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
 	return goodType, err
324
 	return goodType, err
325
 }
325
 }
326
 
326
 
330
 }
330
 }
331
 
331
 
332
 func FindAllGoodInfo(org_id int64) (goodInfo []*models.GoodInfo, err error) {
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
 	return goodInfo, err
334
 	return goodInfo, err
335
 }
335
 }
336
 
336
 
1557
 	return stock, err
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
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1572
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1561
 	err := writeDb.Create(&cancelStock).Error
1573
 	err := writeDb.Create(&cancelStock).Error
1562
 	return err
1574
 	return err
1689
 
1701
 
1690
 func FindAllStockInfo(orgId int64, page int64, limit int64, keyword string, startime int64, endtime int64, type_name int64) (list []*models.StockInfo, total int64, err error) {
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
 	if startime > 0 {
1705
 	if startime > 0 {
1694
 
1706
 
1695
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
1707
 		db = db.Preload("QueryWarehouseOutInfo", func(db *gorm.DB) *gorm.DB {
2952
 
2964
 
2953
 func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutInfo []*models.VmWarehouseOutInfo, err error) {
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
 	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
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
 	return houseOutInfo, err
2969
 	return houseOutInfo, err
2958
 }
2970
 }
2960
 func GetGoodInfomationList(orgid int64, keyword string) (goodInfo []*models.GoodInfo, err error) {
2972
 func GetGoodInfomationList(orgid int64, keyword string) (goodInfo []*models.GoodInfo, err error) {
2961
 	key := "%" + keyword + "%"
2973
 	key := "%" + keyword + "%"
2962
 	if len(keyword) == 0 {
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
 	} else {
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
 	return goodInfo, err
2981
 	return goodInfo, err
3044
 
3056
 
3045
 func GetAllManufacturerList(orgid int64) (list []*models.Manufacturer, err error) {
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
 	return list, err
3060
 	return list, err
3049
 }
3061
 }
3050
 
3062
 
3344
 func GetAllGoodInfoStockList(page int64, limit int64, startime int64, endtime int64, good_type int64, keyword string, orgid int64) (info []*models.GoodInfo, total int64, err error) {
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
 	offset := (page - 1) * limit
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
 	likeKey := "%" + keyword + "%"
3361
 	likeKey := "%" + keyword + "%"
3350
 	if len(likeKey) > 0 {
3362
 	if len(likeKey) > 0 {
3431
 
3443
 
3432
 func GetStockDrugCount(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
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
 	if startime > 0 {
3447
 	if startime > 0 {
3436
 		db = db.Where("x.ctime >=?", startime)
3448
 		db = db.Where("x.ctime >=?", startime)
3437
 	}
3449
 	}
3447
 }
3459
 }
3448
 
3460
 
3449
 func GetAutoDiallysisBefor(startime int64, endtime int64, orgid int64) (info []*models.VmWarehouseInfo, err error) {
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
 	if startime > 0 {
3463
 	if startime > 0 {
3452
 		db = db.Where("x.ctime >=?", startime)
3464
 		db = db.Where("x.ctime >=?", startime)
3453
 	}
3465
 	}
3465
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
3477
 func GetOutStockTotalCountFour(startime int64, endtime int64, orgid int64) (autoMatic []*models.NewXtAutomaticReduceDetail, err error) {
3466
 
3478
 
3467
 	if endtime > 0 {
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
 	if endtime == 0 {
3482
 	if endtime == 0 {
3471
 		err = XTReadDB().Raw("SELECT good_id,SUM(b.count) as count FROM (SELECT DISTINCT x.patient_id,x.good_id,x.count,x.record_time FROM xt_automatic_reduce_detail as x WHERE x.org_id = ? and `status` = 1)  as b GROUP BY good_id", orgid).Scan(&autoMatic).Error
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
 
3591
 
3580
 func GetDrugWarehouOrderInfo(startime int64, endtime int64, orgid int64) (info []*models.VmDrugWarehouseOutInfo, err error) {
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
 	fmt.Println(table)
3596
 	fmt.Println(table)
3585
 	if startime > 0 {
3597
 	if startime > 0 {
3586
 		db = db.Where("x.ctime>=?", startime)
3598
 		db = db.Where("x.ctime>=?", startime)
3877
 
3889
 
3878
 func GetCancelOutTotalCount(startime int64, endtime int64, orgid int64) (info []*models.VmCancelStockInfo, err error) {
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
 	if startime > 0 {
3894
 	if startime > 0 {
3883
 		db = db.Where("x.ctime >=?", startime)
3895
 		db = db.Where("x.ctime >=?", startime)
3976
 	}
3988
 	}
3977
 
3989
 
3978
 	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
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
 	return stock, err
3992
 	return stock, err
3981
 }
3993
 }
3982
 
3994
 
4023
 }
4035
 }
4024
 
4036
 
4025
 func GetLastGoodInformationByGoodId(goodid int64, warehouse_info_id int64, orgid_id int64) (models.WarehouseOutInfo, error) {
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
 	info := models.WarehouseOutInfo{}
4039
 	info := models.WarehouseOutInfo{}
4029
 	err := XTReadDB().Where("good_id = ? and warehouse_info_id= ? and status =1", goodid, warehouse_info_id).Last(&info).Error
4040
 	err := XTReadDB().Where("good_id = ? and warehouse_info_id= ? and status =1", goodid, warehouse_info_id).Last(&info).Error
4793
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4804
 func GetWarehouseInfoById(id int64) (models.WarehousingInfo, error) {
4794
 
4805
 
4795
 	info := models.WarehousingInfo{}
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
 	//return info, err
4808
 	//return info, err
4798
 
4809
 
4799
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4810
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4928
 
4939
 
4929
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4940
 func GetWarehouseTotal(id int64) (models.WarehousingInfo, error) {
4930
 	info := models.WarehousingInfo{}
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
 	//return info, err
4943
 	//return info, err
4933
 
4944
 
4934
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
4945
 	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
5089
 	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
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
 	return err
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
 
139
 
140
 func UpdateDialysisPrescription(patientid int64, orgid int64, dryweight float64, prescription models.PredialysisEvaluation) error {
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
 	fmt.Println("错误是设么", err)
143
 	fmt.Println("错误是设么", err)
144
 	return err
144
 	return err
145
 }
145
 }

+ 34 - 28
service/warhouse_service.go View File

235
 		//}
235
 		//}
236
 		maxNumber = deliver_number / drup.MinNumber
236
 		maxNumber = deliver_number / drup.MinNumber
237
 		minNumber = deliver_number % drup.MinNumber
237
 		minNumber = deliver_number % drup.MinNumber
238
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
239
+			minNumber = maxNumber
240
+		}
238
 		fmt.Println("maxNumber0000000000000", maxNumber)
241
 		fmt.Println("maxNumber0000000000000", maxNumber)
239
 		fmt.Println("minNumber999999999999999", minNumber)
242
 		fmt.Println("minNumber999999999999999", minNumber)
240
 		if warehouse.StockMaxNumber < maxNumber {
243
 		if warehouse.StockMaxNumber < maxNumber {
498
 	// 如果没有对应的库存,则报错
501
 	// 如果没有对应的库存,则报错
499
 
502
 
500
 	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId)
503
 	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId)
504
+	fmt.Println("warehouse233223232323", warehouse.ID)
501
 	//查找药品信息
505
 	//查找药品信息
502
 	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
506
 	//baseInfo, _ := FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
503
 	if err != nil {
507
 	if err != nil {
603
 		var minNumber int64 = 0
607
 		var minNumber int64 = 0
604
 		fmt.Println("单位1111111", advice.PrescribingNumberUnit)
608
 		fmt.Println("单位1111111", advice.PrescribingNumberUnit)
605
 		fmt.Println("单位232323233223", drup.MinUnit)
609
 		fmt.Println("单位232323233223", drup.MinUnit)
606
-
610
+		fmt.Println("出库数量", deliver_number)
607
 		maxNumber = deliver_number / drup.MinNumber
611
 		maxNumber = deliver_number / drup.MinNumber
608
 		minNumber = deliver_number % drup.MinNumber
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
 		fmt.Println("库存数量2332232323", stock_number)
624
 		fmt.Println("库存数量2332232323", stock_number)
617
 		fmt.Println("c出库数量", minNumber)
626
 		fmt.Println("c出库数量", minNumber)
618
 
627
 
619
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
628
 		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
620
-
629
+		if warehouse.StockMaxNumber < 0 {
630
+			warehouse.StockMaxNumber = 0
631
+		}
621
 		fmt.Println("剩余库存", warehouse.StockMaxNumber)
632
 		fmt.Println("剩余库存", warehouse.StockMaxNumber)
633
+
634
+		fmt.Println("ha1", warehouse.StockMinNumber)
635
+		fmt.Println("ha2", minNumber)
622
 		warehouse.Mtime = time.Now().Unix()
636
 		warehouse.Mtime = time.Now().Unix()
623
 
637
 
624
 		if warehouse.StockMinNumber < minNumber {
638
 		if warehouse.StockMinNumber < minNumber {
625
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
639
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
626
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
640
 			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
627
 		} else {
641
 		} else {
642
+
628
 			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
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
 		//扣减库存232332332332
653
 		//扣减库存232332332332
635
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
654
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
636
 		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
655
 		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
695
 			return errOne
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
 		details := &models.DrugAutomaticReduceDetail{
718
 		details := &models.DrugAutomaticReduceDetail{
708
 			WarehouseOutId:          warehouseout.ID,
719
 			WarehouseOutId:          warehouseout.ID,
709
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
720
 			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
1710
 		fmt.Println("几年里2323323232323232323232")
1721
 		fmt.Println("几年里2323323232323232323232")
1711
 		if errThree != nil {
1722
 		if errThree != nil {
1712
 			return errThree
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
 	} else {
1726
 	} else {
2069
 		//将拆零数量转为 最大包装单位  和 最小单位
2072
 		//将拆零数量转为 最大包装单位  和 最小单位
2070
 		maxNumber = deliver_number / drup.MinNumber
2073
 		maxNumber = deliver_number / drup.MinNumber
2071
 		minNumber = deliver_number % drup.MinNumber
2074
 		minNumber = deliver_number % drup.MinNumber
2072
-
2075
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
2076
+			minNumber = maxNumber
2077
+		}
2073
 		fmt.Println("maxNumber0000000000000", maxNumber)
2078
 		fmt.Println("maxNumber0000000000000", maxNumber)
2074
 		fmt.Println("minNumber999999999999999", minNumber)
2079
 		fmt.Println("minNumber999999999999999", minNumber)
2075
 		if warehouse.StockMaxNumber < maxNumber {
2080
 		if warehouse.StockMaxNumber < maxNumber {
2376
 		//把拆零单位转为最大单位  和 最小单位
2381
 		//把拆零单位转为最大单位  和 最小单位
2377
 		maxNumber = deliver_number / drup.MinNumber
2382
 		maxNumber = deliver_number / drup.MinNumber
2378
 		minNumber = deliver_number % drup.MinNumber
2383
 		minNumber = deliver_number % drup.MinNumber
2379
-
2384
+		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
2385
+			minNumber = maxNumber
2386
+		}
2380
 		if warehouse.StockMaxNumber < maxNumber {
2387
 		if warehouse.StockMaxNumber < maxNumber {
2381
-
2382
 			return errors.New("库存数量不足")
2388
 			return errors.New("库存数量不足")
2383
 		}
2389
 		}
2384
 
2390
 
2397
 		}
2403
 		}
2398
 
2404
 
2399
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
2405
 		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
2400
-		fmt.Println("我你233232323232323332323232232332322323233232232323")
2406
+		fmt.Println("我你233232323232323332323232232332322323233232232323")
2401
 		if errThree != nil {
2407
 		if errThree != nil {
2402
 			return errThree
2408
 			return errThree
2403
 		}
2409
 		}