Browse Source

Merge branch 'xt_statistics_branch'

csx 4 years ago
parent
commit
b6405e50df

+ 5 - 68
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go View File

@@ -2,7 +2,6 @@ package new_mobile_api_controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
-	"XT_New/models"
6 5
 	"XT_New/service/statistics_service"
7 6
 	"XT_New/utils"
8 7
 	"fmt"
@@ -25,20 +24,7 @@ func (this *IndexEvaluationApiController) GetAdminUser() {
25 24
 //初始化数据
26 25
 func (this *IndexEvaluationApiController) GetLaboratoryIndexInitData() {
27 26
 	adminUserInfo := this.GetMobileAdminUserInfo()
28
-	var references []*models.InspectionReference
29
-	count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
30
-	if count <= 0 {
31
-		references, _ = statistics_service.FindOrgInspectionReference(0, 1)
32
-		references_two, _ := statistics_service.FindOrgInspectionReference(0, 2)
33
-		references = append(references, references_two...)
34
-
35
-	} else {
36
-		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id, 1)
37
-		references_two, _ := statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id, 2)
38
-		references = append(references, references_two...)
39
-
40
-	}
41
-
27
+	references, _ := statistics_service.FindOrgQualityControlStandardInspectionReference(adminUserInfo.Org.Id)
42 28
 	this.ServeSuccessJSON(map[string]interface{}{
43 29
 		"references": references,
44 30
 	})
@@ -55,33 +41,13 @@ func (this *IndexEvaluationApiController) GetLaboratoryIndexProjectRangeValueDat
55 41
 	var range_vaule []string
56 42
 	if range_type == 1 {
57 43
 		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
58
-
59
-		if qcs.ID == 0 { //没有配置选项
60
-			count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id) //判断是否为集成过来的数据
61
-			if count <= 0 {                                                             //不是,读系统参考值
62
-				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
63
-				range_vaule = append(range_vaule, reference.RangeMin)
64
-				range_vaule = append(range_vaule, reference.RangeMax)
65
-
66
-			} else { //是,读集成过来的参考值
67
-				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.Org.Id, project_id, item_id)
68
-				range_vaule = append(range_vaule, reference.RangeMin)
69
-				range_vaule = append(range_vaule, reference.RangeMax)
70
-			}
71
-
72
-		} else { //有配置
73
-			range_vaule = append(range_vaule, qcs.MinRange)
74
-			range_vaule = append(range_vaule, qcs.LargeRange)
75
-
76
-		}
77
-
44
+		range_vaule = append(range_vaule, qcs.MinRange)
45
+		range_vaule = append(range_vaule, qcs.LargeRange)
78 46
 	} else {
79
-
80 47
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
81 48
 		for _, item := range inspection {
82 49
 			range_vaule = append(range_vaule, item.InspectValue)
83 50
 		}
84
-
85 51
 	}
86 52
 	this.ServeSuccessJSON(map[string]interface{}{
87 53
 		"range_vaule": range_vaule,
@@ -119,22 +85,7 @@ func (this *IndexEvaluationApiController) GetInspectionChartData() {
119 85
 	var range_value string
120 86
 	if range_type == 1 {
121 87
 		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
122
-		if qcs.ID == 0 { //没有配置选项
123
-			count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id) //判断是否为集成过来的数据
124
-			if count <= 0 {                                                             //不是,读系统参考值
125
-				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
126
-				range_value = reference.RangeMin + "," + reference.RangeMax
127
-
128
-			} else { //是,读集成过来的参考值
129
-				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.Org.Id, project_id, item_id)
130
-				range_value = reference.RangeMin + "," + reference.RangeMax
131
-
132
-			}
133
-
134
-		} else { //有配置
135
-			range_value = qcs.MinRange + "," + qcs.LargeRange
136
-
137
-		}
88
+		range_value = qcs.MinRange + "," + qcs.LargeRange
138 89
 
139 90
 	} else {
140 91
 
@@ -264,22 +215,8 @@ func (this *IndexEvaluationApiController) GetPatientInspectionBarChartData() {
264 215
 	var range_value string
265 216
 	if range_type == 1 {
266 217
 		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.Org.Id, project_id, item_id)
267
-		if qcs.ID == 0 { //没有配置选项
268
-			count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id) //判断是否为集成过来的数据
269
-			if count <= 0 {                                                             //不是,读系统参考值
270
-				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
271
-				range_value = reference.RangeMin + "," + reference.RangeMax
272
-
273
-			} else { //是,读集成过来的参考值
274
-				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.Org.Id, project_id, item_id)
275
-				range_value = reference.RangeMin + "," + reference.RangeMax
276
-
277
-			}
278
-
279
-		} else { //有配置
280
-			range_value = qcs.MinRange + "," + qcs.LargeRange
281 218
 
282
-		}
219
+		range_value = qcs.MinRange + "," + qcs.LargeRange
283 220
 
284 221
 	} else {
285 222
 

+ 5 - 60
controllers/pc_index_evaluation_api_controller.go View File

@@ -2,7 +2,6 @@ package controllers
2 2
 
3 3
 import (
4 4
 	"XT_New/enums"
5
-	"XT_New/models"
6 5
 	"XT_New/service/statistics_service"
7 6
 	"XT_New/utils"
8 7
 	"github.com/astaxie/beego"
@@ -52,24 +51,10 @@ type PCIndexEvaluationApiController struct {
52 51
 //初始化数据
53 52
 func (this *PCIndexEvaluationApiController) GetLaboratoryIndexInitData() {
54 53
 	adminUserInfo := this.GetAdminUserInfo()
55
-	var references []*models.InspectionReference
56
-	count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
57
-	if count <= 0 {
58
-		references, _ = statistics_service.FindOrgInspectionReference(0, 1)
59
-		temp_references, _ := statistics_service.FindOrgInspectionReference(0, 2)
60
-		references = append(references, temp_references...)
61
-
62
-	} else {
63
-		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.CurrentOrgId, 1)
64
-		temp_references, _ := statistics_service.FindOrgInspectionReference(0, 2)
65
-		references = append(references, temp_references...)
66
-
67
-	}
68
-
54
+	references, _ := statistics_service.FindOrgQualityControlStandardInspectionReference(adminUserInfo.CurrentOrgId)
69 55
 	this.ServeSuccessJSON(map[string]interface{}{
70 56
 		"references": references,
71 57
 	})
72
-
73 58
 }
74 59
 
75 60
 //获取取值范围
@@ -81,24 +66,8 @@ func (this *PCIndexEvaluationApiController) GetLaboratoryIndexProjectRangeValueD
81 66
 	var range_vaule []string
82 67
 	if range_type == 1 {
83 68
 		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
84
-		if qcs.ID == 0 { //没有配置选项
85
-			count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId) //判断是否为集成过来的数据
86
-			if count <= 0 {                                                                   //不是,读系统参考值
87
-				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
88
-				range_vaule = append(range_vaule, reference.RangeMin)
89
-				range_vaule = append(range_vaule, reference.RangeMax)
90
-
91
-			} else { //是,读集成过来的参考值
92
-				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.CurrentOrgId, project_id, item_id)
93
-				range_vaule = append(range_vaule, reference.RangeMin)
94
-				range_vaule = append(range_vaule, reference.RangeMax)
95
-			}
96
-
97
-		} else { //有配置
98
-			range_vaule = append(range_vaule, qcs.MinRange)
99
-			range_vaule = append(range_vaule, qcs.LargeRange)
100
-
101
-		}
69
+		range_vaule = append(range_vaule, qcs.MinRange)
70
+		range_vaule = append(range_vaule, qcs.LargeRange)
102 71
 
103 72
 	} else {
104 73
 
@@ -144,19 +113,7 @@ func (this *PCIndexEvaluationApiController) GetInspectionChartData() {
144 113
 	var range_value string
145 114
 	if range_type == 1 {
146 115
 		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
147
-		if qcs.ID == 0 { //没有配置选项
148
-			count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId) //判断是否为集成过来的数据
149
-			if count <= 0 {                                                                   //不是,读系统参考值
150
-				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
151
-				range_value = reference.RangeMin + "," + reference.RangeMax
152
-
153
-			} else { //是,读集成过来的参考值
154
-				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.CurrentOrgId, project_id, item_id)
155
-				range_value = reference.RangeMin + "," + reference.RangeMax
156
-			}
157
-		} else { //有配置
158
-			range_value = qcs.MinRange + "," + qcs.LargeRange
159
-		}
116
+		range_value = qcs.MinRange + "," + qcs.LargeRange
160 117
 
161 118
 	} else {
162 119
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
@@ -286,19 +243,7 @@ func (this *PCIndexEvaluationApiController) GetPatientInspectionBarChartData() {
286 243
 	var range_value string
287 244
 	if range_type == 1 {
288 245
 		qcs, _ := statistics_service.FindOrgConfigRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
289
-		if qcs.ID == 0 { //没有配置选项
290
-			count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId) //判断是否为集成过来的数据
291
-			if count <= 0 {                                                                   //不是,读系统参考值
292
-				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
293
-				range_value = reference.RangeMin + "," + reference.RangeMax
294
-			} else { //是,读集成过来的参考值
295
-				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.CurrentOrgId, project_id, item_id)
296
-				range_value = reference.RangeMin + "," + reference.RangeMax
297
-			}
298
-
299
-		} else { //有配置
300
-			range_value = qcs.MinRange + "," + qcs.LargeRange
301
-		}
246
+		range_value = qcs.MinRange + "," + qcs.LargeRange
302 247
 
303 248
 	} else {
304 249
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)

+ 25 - 4
service/statistics_service/index_evaluation_service.go View File

@@ -1278,7 +1278,7 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1278 1278
 	case 1:
1279 1279
 		for _, item := range datas {
1280 1280
 			var Total int64
1281
-			db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND  FIND_IN_SET('内瘘',config.name) > 0   Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.created_time >= ? AND xt_dialysis_order.created_time <= ? ", user_org_id, tempConfig.ID, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1281
+			db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND (config.org_id = ? OR config.org_id = 0)  AND config.parent_id = ? AND  FIND_IN_SET('内瘘',config.name) > 0   Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.created_time >= ? AND xt_dialysis_order.created_time <= ? ", user_org_id, tempConfig.ID, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1282 1282
 			item.PunctureCount = Total
1283 1283
 
1284 1284
 			if math.IsNaN(float64(item.PunctureCount) / float64(NewTotalOne)) {
@@ -1293,7 +1293,7 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1293 1293
 	case 2:
1294 1294
 		for _, item := range datas {
1295 1295
 			var Total int64
1296
-			db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND config.org_id = ? AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.created_time >= ? AND xt_dialysis_order.created_time <= ? ", user_org_id, tempConfig.ID, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1296
+			db.Raw("select count(*) as total from  (select d.patient_id as patient, d.id, d.`assessment_date` as date,config.name as name from  xt_assessment_before_dislysis as d  JOIN `xt_data_config` config on  d.`blood_access_part_opera_id` = config.value AND  (config.org_id = ? OR config.org_id = 0) AND config.parent_id = ? AND FIND_IN_SET('导管',config.name) > 0 Group by d.id)  b JOIN `xt_dialysis_order`  on xt_dialysis_order.`dialysis_date` = b.date AND xt_dialysis_order.user_org_id = ? AND xt_dialysis_order.status = 1  AND xt_dialysis_order.start_nurse = ? AND xt_dialysis_order.created_time >= ? AND xt_dialysis_order.created_time <= ? ", user_org_id, tempConfig.ID, user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1297 1297
 			item.ChangemedicineCount = Total
1298 1298
 
1299 1299
 			if math.IsNaN(float64(item.ChangemedicineCount) / float64(NewTotalTwo)) {
@@ -1393,9 +1393,30 @@ func GetAllAdminUser(user_org_id int64) (datas []*AdminUser, err error) {
1393 1393
 
1394 1394
 }
1395 1395
 
1396
-func FindOrgInspectionCount(user_org_id int64) (count int64, err error) {
1396
+//func FindOrgInspectionCount(user_org_id int64) (count int64, err error) {
1397
+//	db := service.XTReadDB()
1398
+//	err = db.Model(&models.QualityControlStandard{}).Where("status = 1 AND org_id = ? ", user_org_id).Count(&count).Error
1399
+//	return
1400
+//}
1401
+
1402
+type InspectionReference struct {
1403
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
1404
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
1405
+	ProjectName string `gorm:"column:project_name" json:"project_name" form:"project_name"`
1406
+	Project     string `gorm:"column:project" json:"project" form:"project"`
1407
+	ProjectId   int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1408
+	ItemName    string `gorm:"column:item_name" json:"item_name" form:"item_name"`
1409
+	RangeType   int64  `gorm:"column:range_type" json:"range_type" form:"range_type"`
1410
+	RangeMin    string `gorm:"column:range_min" json:"range_min" form:"range_min"`
1411
+	RangeMax    string `gorm:"column:range_max" json:"range_max" form:"range_max"`
1412
+	RangeValue  string `gorm:"column:range_value" json:"range_value" form:"range_value"`
1413
+	Unit        string `gorm:"column:unit" json:"unit" form:"unit"`
1414
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
1415
+}
1416
+
1417
+func FindOrgQualityControlStandardInspectionReference(user_org_id int64) (references []*InspectionReference, err error) {
1397 1418
 	db := service.XTReadDB()
1398
-	err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ?", user_org_id).Count(&count).Error
1419
+	err = db.Raw("Select reference.project_name as project_name,qcs.inspection_major as project_id, qcs.inspection_minor as id,reference.item_name as item_name,reference.range_type as range_type,reference.range_min as range_min, reference.range_max as range_max,reference.unit as  unit  from xt_quality_control_standard qcs Left JOIN xt_inspection_reference reference ON  qcs.inspection_major = reference.project_id and qcs.inspection_minor = reference.id and  (reference.org_id = ? OR org_id = 0)  Where qcs.user_org_id = ?  AND qcs.status = 1", user_org_id, user_org_id).Scan(&references).Error
1399 1420
 	return
1400 1421
 }
1401 1422