Przeglądaj źródła

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

XMLWAN 3 lat temu
rodzic
commit
be44f57153

+ 150 - 75
controllers/base_api_controller.go Wyświetl plik

@@ -2,10 +2,15 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
+	"XT_New/models"
5 6
 	"XT_New/service"
6
-	"fmt"
7
+	"encoding/json"
8
+	"os"
9
+	"path"
10
+	"runtime"
7 11
 	"strconv"
8 12
 	"strings"
13
+	"time"
9 14
 )
10 15
 
11 16
 type BaseAPIController struct {
@@ -69,56 +74,72 @@ type BaseAuthAPIController struct {
69 74
 func (this *BaseAuthAPIController) Prepare() {
70 75
 	this.BaseAPIController.Prepare()
71 76
 	if this.GetAdminUserInfo() == nil {
72
-		//var userAdmin models.AdminUser
73
-		//userAdmin.Id = 1448
74
-		//userAdmin.Mobile = "13318599895"
75
-		//
76
-		//userAdmin.Id = 597
77
-		//userAdmin.Mobile = "19874122664"
78
-		//userAdmin.IsSuperAdmin = false
79
-		//userAdmin.Status = 1
80
-		//userAdmin.CreateTime = 1530786071
81
-		//userAdmin.ModifyTime = 1530786071
82
-		//var subscibe models.ServeSubscibe
83
-		//subscibe.ID = 1
84
-		//subscibe.OrgId = 3877
85
-		//subscibe.PeriodStart = 1538035409
86
-		//subscibe.PeriodEnd = 1569571409
87
-		//subscibe.State = 1
88
-		//subscibe.Status = 1
89
-		//subscibe.CreatedTime = 1538035409
90
-		//subscibe.UpdatedTime = 1538035409
91
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
-		//subscibes[4] = &subscibe
93
-		//var adminUserInfo service.AdminUserInfo
94
-		//adminUserInfo.CurrentOrgId = 3877
95
-		//adminUserInfo.CurrentAppId = 4
96
-		//adminUserInfo.AdminUser = &userAdmin
97
-		//adminUserInfo.Subscibes = subscibes
98
-		//this.SetSession("admin_user_info", &adminUserInfo)
99
-
100
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
-		this.StopRun()
77
+		var userAdmin models.AdminUser
78
+		userAdmin.Id = 1448
79
+		userAdmin.Mobile = "13318599895"
80
+
81
+		userAdmin.Id = 597
82
+		userAdmin.Mobile = "19874122664"
83
+		userAdmin.IsSuperAdmin = false
84
+		userAdmin.Status = 1
85
+		userAdmin.CreateTime = 1530786071
86
+		userAdmin.ModifyTime = 1530786071
87
+		var subscibe models.ServeSubscibe
88
+		subscibe.ID = 1
89
+		subscibe.OrgId = 10215
90
+		subscibe.PeriodStart = 1538035409
91
+		subscibe.PeriodEnd = 1569571409
92
+		subscibe.State = 1
93
+		subscibe.Status = 1
94
+		subscibe.CreatedTime = 1538035409
95
+		subscibe.UpdatedTime = 1538035409
96
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
97
+		subscibes[4] = &subscibe
98
+		var adminUserInfo service.AdminUserInfo
99
+		adminUserInfo.CurrentOrgId = 10215
100
+		adminUserInfo.CurrentAppId = 4
101
+		adminUserInfo.AdminUser = &userAdmin
102
+		adminUserInfo.Subscibes = subscibes
103
+		this.SetSession("admin_user_info", &adminUserInfo)
104
+
105
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
106
+		//this.StopRun()
102 107
 
103 108
 	}
104 109
 
105 110
 	adminUserInfo := this.GetAdminUserInfo()
106 111
 
107 112
 	if this.Ctx.Request.Header.Get("Permission") == "2" {
113
+		err_msgs := LoadErrMsgConfig("./err_msg.json").Msgs
114
+
108 115
 		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
109 116
 		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
110 117
 
111 118
 			isPermission := false
112 119
 			adminUserInfo := this.GetAdminUserInfo()
113
-			//该机构下该用户有多少个
114
-			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
115
-			var roles []string
116
-			if len(role.RoleIds) <= 0 { //该用户没有设置角色
117 120
 
121
+			redisClient := service.RedisClient()
122
+			defer redisClient.Close()
123
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 64) + "_" + strconv.FormatInt(adminUserInfo.AdminUser.Id, 64) + "_role_ids"
124
+			result, _ := redisClient.Get(key).Result()
125
+			var role models.App_Role
126
+			var roles []string
127
+			if len(result) == 0 {
128
+				//该机构下该用户有多少个
129
+				role, _ = service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
130
+				redisClient.Set(key, role, time.Second*60*60*18)
131
+				if len(role.RoleIds) > 0 { //该用户没有设置角色
132
+					roles = strings.Split(role.RoleIds, ",")
133
+				}
118 134
 			} else {
119
-				roles = strings.Split(role.RoleIds, ",")
135
+				json.Unmarshal([]byte(result), &role)
136
+				if len(role.RoleIds) > 0 { //该用户没有设置角色
137
+					roles = strings.Split(role.RoleIds, ",")
138
+				}
120 139
 			}
121
-			fmt.Println(roles)
140
+
141
+			//key := strconv.FormatInt(role_id, 64) + "_" + strconv.FormatInt(adminUserInfo.AdminUser.Id, 64) + "_role_ids"
142
+			//result, _ := redisClient.Get(key).Result()
122 143
 
123 144
 			//获取该用户下所有角色的权限总集
124 145
 			var userRolePurviews string
@@ -134,7 +155,7 @@ func (this *BaseAuthAPIController) Prepare() {
134 155
 			}
135 156
 			//该用户所拥有角色的权限的总集
136 157
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
137
-			fmt.Println("userRolePurviewsArr", userRolePurviewsArr)
158
+
138 159
 			//系统所记录的权限列表
139 160
 			allPermission, _ := service.GetAllFunctionPurview()
140 161
 
@@ -155,7 +176,13 @@ func (this *BaseAuthAPIController) Prepare() {
155 176
 						}
156 177
 					}
157 178
 					if !isPermission {
158
-						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
179
+						var msg string
180
+						for _, item := range err_msgs {
181
+							if strings.Index(item.Url, strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode")) != -1 {
182
+								msg = item.ErrMsg
183
+							}
184
+						}
185
+						//msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
159 186
 						json := make(map[string]interface{})
160 187
 						json["msg"] = msg
161 188
 						json["code"] = 0
@@ -171,20 +198,33 @@ func (this *BaseAuthAPIController) Prepare() {
171 198
 	}
172 199
 
173 200
 	if this.Ctx.Request.Header.Get("Permission") == "3" {
201
+		err_msgs := LoadErrMsgConfig("./err_msg.json").Msgs
202
+
174 203
 		org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
175 204
 		if adminUserInfo.AdminUser.Id != org.Creator { //超级管理员不受此限制
176 205
 
177 206
 			isPermission := false
178 207
 			adminUserInfo := this.GetAdminUserInfo()
179 208
 			//该机构下该用户有多少个
180
-			role, _ := service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
209
+			redisClient := service.RedisClient()
210
+			defer redisClient.Close()
211
+			key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 64) + "_" + strconv.FormatInt(adminUserInfo.AdminUser.Id, 64) + "_role_ids"
212
+			result, _ := redisClient.Get(key).Result()
213
+			var role models.App_Role
181 214
 			var roles []string
182
-			if len(role.RoleIds) <= 0 { //该用户没有设置角色
183
-
215
+			if len(result) == 0 {
216
+				//该机构下该用户有多少个
217
+				role, _ = service.GetUserAllRole(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id)
218
+				redisClient.Set(key, role, time.Second*60*60*18)
219
+				if len(role.RoleIds) > 0 { //该用户没有设置角色
220
+					roles = strings.Split(role.RoleIds, ",")
221
+				}
184 222
 			} else {
185
-				roles = strings.Split(role.RoleIds, ",")
223
+				json.Unmarshal([]byte(result), &role)
224
+				if len(role.RoleIds) > 0 { //该用户没有设置角色
225
+					roles = strings.Split(role.RoleIds, ",")
226
+				}
186 227
 			}
187
-			fmt.Println(roles)
188 228
 
189 229
 			//获取该用户下所有角色的权限总集
190 230
 			var userRolePurviews string
@@ -200,7 +240,6 @@ func (this *BaseAuthAPIController) Prepare() {
200 240
 			}
201 241
 			//该用户所拥有角色的权限的总集
202 242
 			userRolePurviewsArr = RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
203
-			fmt.Println(userRolePurviewsArr)
204 243
 			//系统所记录的权限列表
205 244
 			allPermission, _ := service.GetAllFunctionPurview()
206 245
 
@@ -219,7 +258,13 @@ func (this *BaseAuthAPIController) Prepare() {
219 258
 						}
220 259
 					}
221 260
 					if !isPermission {
222
-						msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
261
+						var msg string
262
+						for _, item := range err_msgs {
263
+							if strings.Index(item.Url, strings.Split(this.Ctx.Request.RequestURI, "?")[0]+"?"+"mode="+this.GetString("mode")) != -1 {
264
+								msg = item.ErrMsg
265
+							}
266
+						}
267
+						//msg, _ := service.FindErrorMsgByStr(strings.Split(this.Ctx.Request.RequestURI, "?")[0] + "?" + "mode=" + this.GetString("mode"))
223 268
 						json := make(map[string]interface{})
224 269
 						json["msg"] = msg
225 270
 						json["code"] = 0
@@ -316,35 +361,35 @@ type BaseServeAPIController struct {
316 361
 func (this *BaseServeAPIController) Prepare() {
317 362
 	this.BaseAPIController.Prepare()
318 363
 	if this.GetAdminUserInfo() == nil {
319
-		//var userAdmin models.AdminUser
320
-		//userAdmin.Id = 1448
321
-		//userAdmin.Mobile = "13318599895"
322
-		//
323
-		//userAdmin.Id = 597
324
-		//userAdmin.Mobile = "19874122664"
325
-		//userAdmin.IsSuperAdmin = false
326
-		//userAdmin.Status = 1
327
-		//userAdmin.CreateTime = 1530786071
328
-		//userAdmin.ModifyTime = 1530786071
329
-		//var subscibe models.ServeSubscibe
330
-		//subscibe.ID = 1
331
-		//subscibe.OrgId = 3877
332
-		//subscibe.PeriodStart = 1538035409
333
-		//subscibe.PeriodEnd = 1569571409
334
-		//subscibe.State = 1
335
-		//subscibe.Status = 1
336
-		//subscibe.CreatedTime = 1538035409
337
-		//subscibe.UpdatedTime = 1538035409
338
-		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
-		//subscibes[4] = &subscibe
340
-		//var adminUserInfo service.AdminUserInfo
341
-		//adminUserInfo.CurrentOrgId = 3877
342
-		//adminUserInfo.CurrentAppId = 4
343
-		//adminUserInfo.AdminUser = &userAdmin
344
-		//adminUserInfo.Subscibes = subscibes
345
-		//this.SetSession("admin_user_info", &adminUserInfo)
346
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
-		this.StopRun()
364
+		var userAdmin models.AdminUser
365
+		userAdmin.Id = 1448
366
+		userAdmin.Mobile = "13318599895"
367
+
368
+		userAdmin.Id = 597
369
+		userAdmin.Mobile = "19874122664"
370
+		userAdmin.IsSuperAdmin = false
371
+		userAdmin.Status = 1
372
+		userAdmin.CreateTime = 1530786071
373
+		userAdmin.ModifyTime = 1530786071
374
+		var subscibe models.ServeSubscibe
375
+		subscibe.ID = 1
376
+		subscibe.OrgId = 10215
377
+		subscibe.PeriodStart = 1538035409
378
+		subscibe.PeriodEnd = 1569571409
379
+		subscibe.State = 1
380
+		subscibe.Status = 1
381
+		subscibe.CreatedTime = 1538035409
382
+		subscibe.UpdatedTime = 1538035409
383
+		subscibes := make(map[int64]*models.ServeSubscibe, 0)
384
+		subscibes[4] = &subscibe
385
+		var adminUserInfo service.AdminUserInfo
386
+		adminUserInfo.CurrentOrgId = 10215
387
+		adminUserInfo.CurrentAppId = 4
388
+		adminUserInfo.AdminUser = &userAdmin
389
+		adminUserInfo.Subscibes = subscibes
390
+		this.SetSession("admin_user_info", &adminUserInfo)
391
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
392
+		//this.StopRun()
348 393
 	}
349 394
 
350 395
 	//if adminUserInfo.AppRole != nil {
@@ -381,3 +426,33 @@ func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
381 426
 	}
382 427
 	return
383 428
 }
429
+
430
+type ErrMsgConfig struct {
431
+	Msgs []*models.ErrMsg "json:msg"
432
+}
433
+
434
+func LoadErrMsgConfig(dataFile string) *ErrMsgConfig {
435
+	var config ErrMsgConfig
436
+	_, filename, _, _ := runtime.Caller(1)
437
+	datapath := path.Join(path.Dir(filename), dataFile)
438
+	config_file, err := os.Open(datapath)
439
+	if err != nil {
440
+		emit("Failed to open config file '%s': %s\n", datapath, err)
441
+		return &config
442
+	}
443
+	fi, _ := config_file.Stat()
444
+	buffer := make([]byte, fi.Size())
445
+	_, err = config_file.Read(buffer)
446
+	buffer, err = StripComments(buffer) //去掉注释
447
+	if err != nil {
448
+		emit("Failed to strip comments from json: %s\n", err)
449
+		return &config
450
+	}
451
+	buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
452
+	err = json.Unmarshal(buffer, &config)         //解析json格式数据
453
+	if err != nil {
454
+		emit("Failed unmarshalling json: %s\n", err)
455
+		return &config
456
+	}
457
+	return &config
458
+}

controllers/new_mobile_api_controllers/common_api_controller.go → controllers/common_api_controller.go Wyświetl plik

@@ -1,7 +1,6 @@
1
-package new_mobile_api_controllers
1
+package controllers
2 2
 
3 3
 import (
4
-	"XT_New/controllers"
5 4
 	"XT_New/enums"
6 5
 	"XT_New/models"
7 6
 	"XT_New/service"
@@ -14,7 +13,7 @@ import (
14 13
 )
15 14
 
16 15
 type CommonApiController struct {
17
-	controllers.BaseAuthAPIController
16
+	BaseAuthAPIController
18 17
 }
19 18
 
20 19
 func (this *CommonApiController) GetInspectionMajor() {
@@ -527,9 +526,15 @@ func (this *CommonApiController) GetDialysisModeType() {
527 526
 	orgid := adminUser.CurrentOrgId
528 527
 	//统计透析总量
529 528
 	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
530
-	fmt.Println("total3333333333333", total)
529
+	//var mode models.PatientPrescriptionCountStruct
530
+	//mode.Count = total
531 531
 	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
532
-	fmt.Println("modetype555555555555555", modeType)
532
+
533
+	//var total models.PatientPrescriptionCountStruct
534
+	//for _, item := range modeType {
535
+	//	total.Count = total.Count + item.Count
536
+	//}
537
+
533 538
 	if err != nil {
534 539
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
535 540
 		return
@@ -645,8 +650,8 @@ func (this *CommonApiController) GetTotalAgeCount() {
645 650
 	sourcetype, _ := this.GetInt64("sourcetype")
646 651
 	//统计透析总人数
647 652
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
653
+
648 654
 	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
649
-	fmt.Println("ageCount22222222222", agecount)
650 655
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
651 656
 	if err != nil {
652 657
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -717,7 +722,6 @@ func (this *CommonApiController) GetDialysislist() {
717 722
 	statime := startDate.Unix()
718 723
 
719 724
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
720
-
721 725
 	entime := endDate.Unix()
722 726
 
723 727
 	page, _ := this.GetInt64("page")

controllers/new_mobile_api_controllers/common_api_router.go → controllers/common_api_router.go Wyświetl plik

@@ -1,4 +1,4 @@
1
-package new_mobile_api_controllers
1
+package controllers
2 2
 
3 3
 import (
4 4
 	"github.com/astaxie/beego"

+ 61 - 43
controllers/doctors_api_controller.go Wyświetl plik

@@ -91,53 +91,11 @@ func (c *DoctorsApiController) ScheduleAdvices() {
91 91
 	hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
92 92
 
93 93
 	project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
94
-
94
+	//project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
95 95
 	for _, item := range project {
96 96
 		index := 0
97 97
 		for _, subItem := range item.HisPrescriptionTeamProject {
98 98
 
99
-			//获取所有的患者
100
-			patients, _ := service.GetAllPatientListByListTwo(orgID)
101
-
102
-			//获取所有床位
103
-			numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
104
-
105
-			//获取透析处方
106
-			prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
107
-
108
-			//获取上机
109
-			dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
110
-			for key, item := range project {
111
-				for _, patient := range patients {
112
-					if item.PatientId == patient.ID {
113
-						project[key].SchedualPatient = patient
114
-						break
115
-					}
116
-				}
117
-				// 获取床位信息
118
-				for _, it := range numberList {
119
-					if item.BedId == it.ID {
120
-						project[key].DeviceNumber = it
121
-						break
122
-					}
123
-				}
124
-
125
-				// 获取处方
126
-				for _, it := range prescriptions {
127
-					if item.PatientId == it.PatientId {
128
-						project[key].Prescription = it
129
-						break
130
-					}
131
-				}
132
-
133
-				//获取上机
134
-				for _, it := range dialysisOrders {
135
-					if item.PatientId == it.PatientId {
136
-						project[key].DialysisOrder = it
137
-						break
138
-					}
139
-				}
140
-			}
141 99
 			if subItem.HisProject.CostClassify != 3 {
142 100
 				subItem.IsCheckTeam = 2
143 101
 				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
@@ -152,6 +110,66 @@ func (c *DoctorsApiController) ScheduleAdvices() {
152 110
 			}
153 111
 		}
154 112
 	}
113
+	//for _, item := range project {
114
+	//	index := 0
115
+	//	for _, subItem := range item.HisPrescriptionTeamProject {
116
+	//
117
+	//		//获取所有的患者
118
+	//		patients, _ := service.GetAllPatientListByListTwo(orgID)
119
+	//
120
+	//		//获取所有床位
121
+	//		numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
122
+	//
123
+	//		//获取透析处方
124
+	//		prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
125
+	//
126
+	//		//获取上机
127
+	//		dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
128
+	//		for key, item := range project {
129
+	//			for _, patient := range patients {
130
+	//				if item.PatientId == patient.ID {
131
+	//					project[key].SchedualPatient = patient
132
+	//					break
133
+	//				}
134
+	//			}
135
+	//			// 获取床位信息
136
+	//			for _, it := range numberList {
137
+	//				if item.BedId == it.ID {
138
+	//					project[key].DeviceNumber = it
139
+	//					break
140
+	//				}
141
+	//			}
142
+	//
143
+	//			// 获取处方
144
+	//			for _, it := range prescriptions {
145
+	//				if item.PatientId == it.PatientId {
146
+	//					project[key].Prescription = it
147
+	//					break
148
+	//				}
149
+	//			}
150
+	//
151
+	//			//获取上机
152
+	//			for _, it := range dialysisOrders {
153
+	//				if item.PatientId == it.PatientId {
154
+	//					project[key].DialysisOrder = it
155
+	//					break
156
+	//				}
157
+	//			}
158
+	//		}
159
+	//		if subItem.HisProject.CostClassify != 3 {
160
+	//			subItem.IsCheckTeam = 2
161
+	//			item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
162
+	//		}
163
+	//
164
+	//		if subItem.HisProject.CostClassify == 3 {
165
+	//			subItem.IsCheckTeam = 1
166
+	//			index = index + 1
167
+	//			if index == 1 {
168
+	//				item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
169
+	//			}
170
+	//		}
171
+	//	}
172
+	//}
155 173
 	config, _ := service.GetHisDoctorConfig(orgID)
156 174
 	project_config, _ := service.GetHisProjectConfig(orgID)
157 175
 

+ 32 - 30
controllers/his_api_controller.go Wyświetl plik

@@ -1063,50 +1063,52 @@ func (c *HisApiController) CreateHisPrescription() {
1063 1063
 							timeFormat := tempTime.Format("20060102150405")
1064 1064
 							p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
1065 1065
 
1066
-							//新增或者编辑项目,修改对应的标签数据
1067
-							labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
1068
-							if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
1069
-								var label models.HisLabelPrintInfo
1070
-								project, _ := service.GetProjectDetail(p.ProjectId)
1071
-								if project.CostClassify == 3 { //类别为检验检查
1072
-									if p.TeamId > 0 { //检验检查组套
1073
-										tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
1074
-										if tempLabel.ID == 0 {
1075
-											team, _ := service.GetProjectTeamDetail(p.TeamId)
1066
+							if p.Type == 2 { //因为项目和耗材的基础库存在id相同的情况,所以需要根据该字段来判断,type为2的话为从项目开出来的
1067
+								//新增或者编辑项目,修改对应的标签数据
1068
+								labelOrigin, _ := service.GetProjectById(p.UserOrgId, p.ID, patient_id, recordDateTime)
1069
+								if labelOrigin.ID == 0 { //当天某个人的处方中的项目不存在
1070
+									var label models.HisLabelPrintInfo
1071
+									project, _ := service.GetProjectDetail(p.ProjectId)
1072
+									if project.CostClassify == 3 { //类别为检验检查
1073
+										if p.TeamId > 0 { //检验检查组套
1074
+											tempLabel, _ := service.GetProjectByTeamId(p.UserOrgId, p.TeamId, patient_id, recordDateTime)
1075
+											if tempLabel.ID == 0 {
1076
+												team, _ := service.GetProjectTeamDetail(p.TeamId)
1077
+												label.Number = tempPrescription.PrescriptionNumber
1078
+												label.ProjectId = project.ID
1079
+												label.Status = 1
1080
+												label.IsPrint = 2
1081
+												label.DoctorId = info.DoctorId
1082
+												label.UserOrgId = p.UserOrgId
1083
+												label.PatientId = patient_id
1084
+												label.RecordDate = recordDateTime
1085
+												label.Ctime = time.Now().Unix()
1086
+												label.Mtime = time.Now().Unix()
1087
+												label.ItemId = p.TeamId
1088
+												label.FeedetlSn = p.FeedetlSn
1089
+												label.PProjectId = p.ID
1090
+												label.ProjectName = team.ProjectTeam
1091
+												label.PatientName = patient.Name
1092
+												service.CreateHisLabelRecord(&label)
1093
+											}
1094
+										} else { //单条检验检查项目
1076 1095
 											label.Number = tempPrescription.PrescriptionNumber
1077 1096
 											label.ProjectId = project.ID
1078 1097
 											label.Status = 1
1079
-											label.IsPrint = 2
1080 1098
 											label.DoctorId = info.DoctorId
1081 1099
 											label.UserOrgId = p.UserOrgId
1082 1100
 											label.PatientId = patient_id
1083 1101
 											label.RecordDate = recordDateTime
1102
+											label.IsPrint = 2
1084 1103
 											label.Ctime = time.Now().Unix()
1085 1104
 											label.Mtime = time.Now().Unix()
1086
-											label.ItemId = p.TeamId
1087 1105
 											label.FeedetlSn = p.FeedetlSn
1088 1106
 											label.PProjectId = p.ID
1089
-											label.ProjectName = team.ProjectTeam
1107
+											label.ItemId = p.TeamId
1108
+											label.ProjectName = project.ProjectName
1090 1109
 											label.PatientName = patient.Name
1091 1110
 											service.CreateHisLabelRecord(&label)
1092 1111
 										}
1093
-									} else { //单条检验检查项目
1094
-										label.Number = tempPrescription.PrescriptionNumber
1095
-										label.ProjectId = project.ID
1096
-										label.Status = 1
1097
-										label.DoctorId = info.DoctorId
1098
-										label.UserOrgId = p.UserOrgId
1099
-										label.PatientId = patient_id
1100
-										label.RecordDate = recordDateTime
1101
-										label.IsPrint = 2
1102
-										label.Ctime = time.Now().Unix()
1103
-										label.Mtime = time.Now().Unix()
1104
-										label.FeedetlSn = p.FeedetlSn
1105
-										label.PProjectId = p.ID
1106
-										label.ItemId = p.TeamId
1107
-										label.ProjectName = project.ProjectName
1108
-										label.PatientName = patient.Name
1109
-										service.CreateHisLabelRecord(&label)
1110 1112
 									}
1111 1113
 								}
1112 1114
 							}

+ 158 - 0
controllers/mobile_api_controllers/err_msg.json Wyświetl plik

@@ -0,0 +1,158 @@
1
+{
2
+  "msg": [
3
+    {
4
+      "url": "/m/api/solution?mode=1,/api/dialysis/soulution?mode=1,/api/patients/dialysissolution/create?mode=1",
5
+      "err_msg": "没有权限新增长期处方"
6
+    },{
7
+      "url": ",,/api/patients/dialysissolution/edit?mode=2",
8
+      "err_msg": "没有权限修改长期处方"
9
+    },{
10
+      "url": ",,/api/patients/dialysissolution/edit?mode=3",
11
+      "err_msg": "没有权限修改别人的长期处方"
12
+    },{
13
+      "url": "/m/api/dialysis/dialysisPrescription?mode=1,/api/dialysis/prescription?mode=1,",
14
+      "err_msg": "没有权限新增临时处方"
15
+    },{
16
+      "url": "/m/api/dialysis/dialysisPrescription?mode=3,/api/dialysis/prescription?mode=3,",
17
+      "err_msg": "没有权限修改他人的临时处方"
18
+    },{
19
+      "url": "/m/api/dialysis/acceptsAssessment?mode=1,/api/dialysis/accepts?mode=1,",
20
+      "err_msg": "没有权限新增接诊评估"
21
+    },{
22
+      "url": "/m/api/dialysis/acceptsAssessment?mode=2,/api/dialysis/accepts?mode=2,",
23
+      "err_msg": "没有权限修改接诊评估"
24
+    },{
25
+      "url": "/m/api/dialysis/acceptsAssessment?mode=3,/api/dialysis/accepts?mode=3,",
26
+      "err_msg": "没有权限修改别人接诊评估"
27
+    },{
28
+      "url": "/m/api/assessmentbefore/commit?mode=1,/api/dialysis/assessmentbeforedislysis?mode=1,",
29
+      "err_msg": "没有权限新增透前评估"
30
+    },{
31
+      "url": "/m/api/assessmentbefore/commit?mode=2,/api/dialysis/assessmentbeforedislysis?mode=2,",
32
+      "err_msg": "没有权限修改透前评估"
33
+    },{
34
+      "url": "/m/api/assessmentbefore/commit?mode=3,/api/dialysis/assessmentbeforedislysis?mode=3,",
35
+      "err_msg": "没有权限修改别人透前评估"
36
+    },{
37
+      "url": "/m/api/dialysis/start?mode=1,/api/dialysis/start_record?mode=1,",
38
+      "err_msg": "没有权限执行上机"
39
+    },{
40
+      "url": "/m/api/startOrder/edit?mode=2,/api/start_dialysis/modify?mode=2,",
41
+      "err_msg": "没有权限修改执行上机"
42
+    },{
43
+      "url": "/m/api/startOrder/edit?mode=3,/api/start_dialysis/modify?mode=3,",
44
+      "err_msg": "没有权限修改他人执行上机"
45
+    },{
46
+      "url": "/m/api/monitor/add?mode=1,/api/dislysis/monitor/edit?mode=1,",
47
+      "err_msg": "没有权限新增透析监测"
48
+    },{
49
+      "url": "/m/api/monitor/edit?mode=2,/api/dislysis/monitor/edit?mode=2,",
50
+      "err_msg": "没有权限修改透析监测"
51
+    },{
52
+      "url": "/m/api/monitor/edit?mode=3,/api/dislysis/monitor/edit?mode=3,",
53
+      "err_msg": "没有权限修改他人透析监测"
54
+    },{
55
+      "url": "/m/api/monitor/delete?mode=4,/api/dialysis/monitor/del?mode=4,",
56
+      "err_msg": "没有权限删除透析监测"
57
+    },{
58
+      "url": "/m/api/monitor/delete?mode=5,/api/dialysis/monitor/del?mode=5,",
59
+      "err_msg": "没有权限删除他人透析监测"
60
+    },{
61
+      "url": "/m/api/dialysis/finish?mode=1,/api/dialysis/finish?mode=1,",
62
+      "err_msg": "没有权限执行下机"
63
+    },{
64
+      "url": "/m/api/finishOrder/edit?mode=2,/api/finish_dialysis/modify?mode=2,",
65
+      "err_msg": "没有权限修改执行下机"
66
+    },{
67
+      "url": "/m/api/finishOrder/edit?mode=3,/api/finish_dialysis/modify?mode=3,",
68
+      "err_msg": "没有权限修改他人执行下机"
69
+    },{
70
+      "url": "/m/api/dialysis/assessmentAfterDislysis?mode=1,/api/dialysis/assessmentafterdislysis?mode=1,",
71
+      "err_msg": "没有权限新增透后评估"
72
+    },{
73
+      "url": "/m/api/dialysis/assessmentAfterDislysis?mode=2,/api/dialysis/assessmentafterdislysis?mode=2,",
74
+      "err_msg": "没有权限修改透后评估"
75
+    },{
76
+      "url": "/m/api/dialysis/assessmentAfterDislysis?mode=3,/api/dialysis/assessmentafterdislysis?mode=3,",
77
+      "err_msg": "没有权限修改他人透后评估"
78
+    },{
79
+      "url": "/m/api/dialysis/treatmentSummary?mode=1,/api/dialysis/treatmentsummary?mode=1,",
80
+      "err_msg": "没有权限新增治疗小结"
81
+    },{
82
+      "url": "/m/api/dialysis/treatmentSummary?mode=2,/api/dialysis/treatmentsummary?mode=2,",
83
+      "err_msg": "没有权限修改治疗小结"
84
+    },{
85
+      "url": "/m/api/dialysis/treatmentSummary?mode=3,/api/dialysis/treatmentsummary?mode=3,",
86
+      "err_msg": "没有权限修改他人治疗小结"
87
+    },{
88
+      "url": "/m/api/dryweight/commit?mode=1,/api/dryweight/commit?mode=1,/api/patient/updatedryweightdata?mode=1",
89
+      "err_msg": "没有权限新增干体重"
90
+    },{
91
+      "url": ",/api/patients/advice/create?mode=1-1,/api/patients/advice/creategroup?mode=1-1",
92
+      "err_msg": "没有权限新增临时医嘱"
93
+    },{
94
+      "url": ",/api/patients/advice/edit?mode=2-1,",
95
+      "err_msg": "没有权限修改临时医嘱"
96
+    },{
97
+      "url": ",/api/patients/advice/edit?mode=3-1,",
98
+      "err_msg": "没有权限修改他人临时医嘱"
99
+    },{
100
+      "url": ",/api/patients/advice/delete?mode=4-1,/api/patients/advice/deletegroup?mode=4-1",
101
+      "err_msg": "没有权限删除临时医嘱"
102
+    },{
103
+      "url": ",/api/patients/advice/delete?mode=5-1,/api/patients/advice/deletegroup?mode=5-1",
104
+      "err_msg": "没有权限删除他人开的临时医嘱"
105
+    },{
106
+      "url": ",/api/patients/advice/create?mode=1-2,/api/patients/advice/creategroup?mode=1-2",
107
+      "err_msg": "没有权限新增长期医嘱"
108
+    },{
109
+      "url": ",/api/patients/advice/edit?mode=1-3,",
110
+      "err_msg": "没有权限修改长期医嘱"
111
+    },{
112
+      "url": ",/api/patients/advice/edit?mode=1-4,",
113
+      "err_msg": "没有权限修改他人长期医嘱"
114
+    },{
115
+      "url": ",/api/patients/advice/stop?mode=1-5,",
116
+      "err_msg": "没有权限停止长期医嘱"
117
+    },{
118
+      "url": ",/api/patients/advice/delete?mode=1-6,/api/patients/advice/deletegroup?mode=1-6",
119
+      "err_msg": "没有权限删除长期医嘱"
120
+    },{
121
+      "url": ",/api/patients/advice/delete?mode=1-7,/api/patients/advice/deletegroup?mode=1-7",
122
+      "err_msg": "没有权限删除他人长期医嘱"
123
+    },{
124
+      "url": "/m/api/advice/creategroup?mode=1,/api/patients/advice/creategroup?mode=1,/api/patients/advice/create?mode=1",
125
+      "err_msg": "没有权限新增透析临时医嘱"
126
+    },{
127
+      "url": "/m/api/advice/edit?mode=2,/api/patients/advice/edit?mode=2,",
128
+      "err_msg": "没有权限修改透析临时医嘱"
129
+    },{
130
+      "url": "/m/api/advice/edit?mode=3,/api/patients/advice/edit?mode=3,",
131
+      "err_msg": "没有权限修改他人透析临时医嘱"
132
+    },{
133
+      "url": "/m/api/newadvice/delete?mode=4,/api/patients/advice/delete?mode=4,/api/patients/advice/deletegroup?mode=4",
134
+      "err_msg": "没有权限删除透析临时医嘱"
135
+    },{
136
+      "url": "/m/api/newadvice/delete?mode=5,/api/patients/advice/delete?mode=5,/api/patients/advice/deletegroup?mode=5",
137
+      "err_msg": "没有权限删除他人透析临时医嘱"
138
+    },{
139
+      "url": "/m/api/advice/exec?mode=6,/api/patients/advice/exec?mode=6,",
140
+      "err_msg": "没有权限执行透析临时医嘱"
141
+    },{
142
+      "url": "/m/api/advice/exec/modify?mode=8,,",
143
+      "err_msg": "没有权限修改已执行医嘱"
144
+    },{
145
+      "url": "/m/api/advice/check?mode=7,/api/patients/advice/check?mode=7,",
146
+      "err_msg": "没有权限核对透析临时医嘱"
147
+    },{
148
+      "url": ",/api/patients/advice/stop?mode=1-8,",
149
+      "err_msg": "没有权限停止他人长期医嘱"
150
+    },{
151
+      "url": ",/api/patients/advice/execgroup?mode=6-1,",
152
+      "err_msg": "没有权限执行医嘱"
153
+    },{
154
+      "url": ",/api/patients/advice/checkgroup?mode=7-1,",
155
+      "err_msg": "没有权限核对医嘱"
156
+    }
157
+  ]
158
+}

+ 6 - 2
controllers/new_mobile_api_controllers/new_common_api_controller.go Wyświetl plik

@@ -36,9 +36,13 @@ func (this *NewCommonApiController) GetTotalDialysis() {
36 36
 
37 37
 	//统计透析总量
38 38
 	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
39
-
39
+	//var mode models.PatientPrescriptionCountStruct
40
+	//mode.Count = total
40 41
 	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
41
-
42
+	//var total models.PatientPrescriptionCountStruct
43
+	//for _, item := range modeType {
44
+	//	total.Count = total.Count + item.Count
45
+	//}
42 46
 	if err != nil {
43 47
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
44 48
 		return

+ 6 - 0
models/err_msg.go Wyświetl plik

@@ -0,0 +1,6 @@
1
+package models
2
+
3
+type ErrMsg struct {
4
+	Url    string `gorm:"column:url" json:"url"`
5
+	ErrMsg string `gorm:"column:err_msg" json:"err_msg"`
6
+}

+ 11 - 24
service/common_service.go Wyświetl plik

@@ -213,38 +213,28 @@ func DeleteCheck(id int64) error {
213 213
 func GetDialysiTotal(startime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (models.PatientPrescriptionCountStruct, error) {
214 214
 	counts := models.PatientPrescriptionCountStruct{}
215 215
 
216
-	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
217
-	table := XTReadDB().Table("xt_paitents as s").Where("s.status = 1")
218
-	fmt.Println(table)
216
+	db := XTReadDB().Table("xt_dialysis_order as x").Select("count(x.id) as count").Joins("Join xt_dialysis_prescription as prescription On x.dialysis_date = prescription.record_date AND x.patient_id = prescription.patient_id  AND prescription.status = 1 AND prescription.mode_id > 0").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? AND x.status = 1", startime, endtime, orgid)
219 217
 
220 218
 	if lapsetotype > 0 {
221
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.lapseto = ?", startime, endtime, orgid, lapsetotype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
219
+		err = db.Where("x.user_org_id = ? and s.lapseto = ?", startime, endtime, orgid, lapsetotype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
222 220
 	}
223 221
 	if lapsetotype == 0 {
224
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? ", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
222
+		err = db.Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
225 223
 	}
226 224
 
227 225
 	if sourcetype > 0 {
228
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.source = ?", startime, endtime, orgid, sourcetype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
226
+		err = db.Where("x.user_org_id = ? and s.source = ?", startime, endtime, orgid, sourcetype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
229 227
 	}
230 228
 
231 229
 	if sourcetype == 0 {
232
-		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ?", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
230
+		err = db.Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
233 231
 	}
234 232
 
235 233
 	return counts, err
236 234
 }
237 235
 
238 236
 func GetDialysisCountMode(starttime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
239
-
240
-	//err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
241
-	//return counts, err
242
-
243 237
 	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
244
-	table := readDb.Table("xt_schedule as s").Where("s.status = 1")
245
-	fmt.Println(table)
246
-	p := readDb.Table("xt_patients as p").Where("p.status = 1")
247
-	fmt.Println(p)
248 238
 	if starttime > 0 {
249 239
 		db = db.Where("o.dialysis_date >=?", starttime)
250 240
 	}
@@ -260,7 +250,7 @@ func GetDialysisCountMode(starttime int64, endtime int64, orgid int64, lapsetoty
260 250
 	if sourcetype > 0 {
261 251
 		db = db.Where("p.source = ?", sourcetype)
262 252
 	}
263
-	err = db.Select("s.mode_id,count(s.mode_id) as count").Joins("left join xt_schedule as s on s.patient_id = o.patient_id and s.schedule_date = o.dialysis_date and s.status= 1").Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
253
+	err = db.Select("s.mode_id,count(s.mode_id) as count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id and s.record_date = o.dialysis_date and s.status= 1 AND s.record_date >= ? AND s.record_date <= ? AND AND s.mode_id > 0 ", starttime, endtime).Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
264 254
 	return counts, err
265 255
 }
266 256
 
@@ -287,13 +277,14 @@ func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64, lapseto
287 277
 }
288 278
 
289 279
 func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
290
-
291 280
 	db := XTReadDB().Table("xt_patients as x")
292 281
 	if sourcetype == 0 {
282
+
293 283
 		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
294 284
 
295 285
 	}
296 286
 	if sourcetype > 0 {
287
+
297 288
 		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
298 289
 	}
299 290
 	return patients, err
@@ -629,10 +620,6 @@ func GetPrescritionByName(orgid int64, patient_id int64, startime int64, endtime
629 620
 func GetTreateInfo(orgID int64, startime int64, endtime int64, lapseto int64, limit int64, page int64) (blood []*models.TreatDialysisOrder, total int64, err error) {
630 621
 
631 622
 	db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status =  1")
632
-	table := XTReadDB().Table("xt_schedule as s")
633
-	fmt.Println(table)
634
-	p := XTReadDB().Table("xt_patients as p")
635
-	fmt.Println(p)
636 623
 	sql := "from_unixtime(o.dialysis_date, '%Y%m%d') AS date"
637 624
 
638 625
 	if orgID > 0 {
@@ -651,7 +638,7 @@ func GetTreateInfo(orgID int64, startime int64, endtime int64, lapseto int64, li
651 638
 		db = db.Where("p.lapseto = ?", lapseto)
652 639
 	}
653 640
 	offset := (page - 1) * limit
654
-	err = db.Group("o.dialysis_date").Select(sql).Joins("left join xt_schedule as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.schedule_date = o.dialysis_date and s.status =1").Count(&total).Offset(offset).Limit(limit).Scan(&blood).Error
641
+	err = db.Group("o.dialysis_date").Select(sql).Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.record_date = o.dialysis_date and s.status =1").Count(&total).Offset(offset).Limit(limit).Scan(&blood).Error
655 642
 	return blood, total, err
656 643
 
657 644
 }
@@ -676,7 +663,7 @@ func GetTreatList(orgid int64, startime int64, endtime int64, lapseto int64) (tt
676 663
 	if lapseto > 0 {
677 664
 		db = db.Where("p.lapseto = ?", lapseto)
678 665
 	}
679
-	err = db.Select("s.mode_id, count(s.mode_id) as number").Joins("left join xt_schedule as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.schedule_date = o.dialysis_date and s.status = 1").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
666
+	err = db.Select("s.mode_id, count(s.mode_id) as number").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.record_date = o.dialysis_date and s.status = 1").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
680 667
 	return ttd, err
681 668
 }
682 669
 
@@ -685,7 +672,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
685 672
 	sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
686 673
 	datesql := " o.dialysis_date as date"
687 674
 	group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
688
-	db = db.Table(" xt_dialysis_order AS o").Joins("left join xt_schedule as s on o.patient_id = s.patient_id").Where("s.schedule_date = o.dialysis_date and s.status =1")
675
+	db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id").Where("s.record_date = o.dialysis_date and s.status =1")
689 676
 	if orgID > 0 {
690 677
 		db = db.Where("o.user_org_id = ?", orgID)
691 678
 	}

+ 0 - 49
service/mobile_dialysis_service.go Wyświetl plik

@@ -3505,55 +3505,6 @@ func GetPCHisPrescriptionProject(orgID int64, scheduleDate int64, deliverWay str
3505 3505
 		}
3506 3506
 		err = db.Find(&vms).Error
3507 3507
 	}
3508
-	//if patientType == 0 {
3509
-	//	db := readDb.
3510
-	//		Table("xt_schedule").
3511
-	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
3512
-	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3513
-	//			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3514
-	//		}).
3515
-	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
3516
-	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
3517
-	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
3518
-	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
3519
-	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
3520
-	//		}).Where("status = 1 AND user_org_id = ?", orgID)
3521
-	//	if scheduleDate != 0 {
3522
-	//		db = db.Where("schedule_date = ?", scheduleDate)
3523
-	//	}
3524
-	//	err = db.Find(&vms).Error
3525
-	//}
3526
-	//
3527
-	//if patientType > 0 {
3528
-	//	db := readDb.
3529
-	//		Table("xt_schedule").
3530
-	//		Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
3531
-	//		Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
3532
-	//			return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
3533
-	//		}).
3534
-	//		Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
3535
-	//		Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
3536
-	//		Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
3537
-	//		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
3538
-	//		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
3539
-	//			return db.Where("status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).Preload("HisProject").Preload("GoodInfo", "status=1")
3540
-	//		}).
3541
-	//		Where("status = 1 AND user_org_id = ?", orgID)
3542
-	//	if scheduleDate != 0 {
3543
-	//		db = db.Where("schedule_date = ?", scheduleDate)
3544
-	//	}
3545
-	//	err = db.Find(&vms).Error
3546
-	//}
3547
-
3548
-	db := readDb.Table("xt_schedule").Where("status = 1")
3549
-	if scheduleDate > 0 {
3550
-		db = db.Where("schedule_date = ?", scheduleDate)
3551
-	}
3552
-	if orgID > 0 {
3553
-		db = db.Where("user_org_id = ?", orgID)
3554
-	}
3555
-
3556
-	err = db.Find(&vms).Error
3557 3508
 
3558 3509
 	return vms, err
3559 3510
 }