Explorar el Código

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

XMLWAN hace 4 años
padre
commit
9ca90fd8d2

+ 1 - 0
controllers/mobile_api_controllers/patient_api_controller.go Ver fichero

@@ -2670,6 +2670,7 @@ func (this *PatientApiController) GetPatientsByKeyWord() {
2670 2670
 }
2671 2671
 
2672 2672
 func (this *PatientApiController) GetSearchPatient() {
2673
+
2673 2674
 	keyWord := this.GetString("keyword")
2674 2675
 	adminUserInfo := this.GetMobileAdminUserInfo()
2675 2676
 	patient, err := service.GetPatientsByKey(adminUserInfo.Org.Id, keyWord)

+ 10 - 2
controllers/new_mobile_api_controllers/index_evaluation_api_controller.go Ver fichero

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service/statistics_service"
7 7
 	"XT_New/utils"
8
+	"fmt"
8 9
 	"time"
9 10
 )
10 11
 
@@ -27,9 +28,15 @@ func (this *IndexEvaluationApiController) GetLaboratoryIndexInitData() {
27 28
 	var references []*models.InspectionReference
28 29
 	count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.Org.Id)
29 30
 	if count <= 0 {
30
-		references, _ = statistics_service.FindOrgInspectionReference(0)
31
+		references, _ = statistics_service.FindOrgInspectionReference(0, 1)
32
+		references_two, _ := statistics_service.FindOrgInspectionReference(0, 2)
33
+		references = append(references, references_two...)
34
+
31 35
 	} else {
32
-		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.Org.Id)
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
+
33 40
 	}
34 41
 
35 42
 	this.ServeSuccessJSON(map[string]interface{}{
@@ -41,6 +48,7 @@ func (this *IndexEvaluationApiController) GetLaboratoryIndexInitData() {
41 48
 //获取取值范围
42 49
 func (this *IndexEvaluationApiController) GetLaboratoryIndexProjectRangeValueData() {
43 50
 	range_type, _ := this.GetInt64("range_type")
51
+	fmt.Println(range_type)
44 52
 	project_id, _ := this.GetInt64("project_id")
45 53
 	item_id, _ := this.GetInt64("item_id")
46 54
 	adminUserInfo := this.GetMobileAdminUserInfo()

+ 8 - 2
controllers/pc_index_evaluation_api_controller.go Ver fichero

@@ -55,9 +55,15 @@ func (this *PCIndexEvaluationApiController) GetLaboratoryIndexInitData() {
55 55
 	var references []*models.InspectionReference
56 56
 	count, _ := statistics_service.FindOrgInspectionCount(adminUserInfo.CurrentOrgId)
57 57
 	if count <= 0 {
58
-		references, _ = statistics_service.FindOrgInspectionReference(0)
58
+		references, _ = statistics_service.FindOrgInspectionReference(0, 1)
59
+		temp_references, _ := statistics_service.FindOrgInspectionReference(0, 2)
60
+		references = append(references, temp_references...)
61
+
59 62
 	} else {
60
-		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.CurrentOrgId)
63
+		references, _ = statistics_service.FindOrgInspectionReference(adminUserInfo.CurrentOrgId, 1)
64
+		temp_references, _ := statistics_service.FindOrgInspectionReference(0, 2)
65
+		references = append(references, temp_references...)
66
+
61 67
 	}
62 68
 
63 69
 	this.ServeSuccessJSON(map[string]interface{}{

+ 104 - 23
service/statistics_service/index_evaluation_service.go Ver fichero

@@ -124,7 +124,7 @@ func GetDialysisProcessIndexOtherChartData(user_org_id int64, patient_id int64,
124 124
 
125 125
 	for _, item := range items {
126 126
 		if math.IsNaN(float64(item.Total) / float64(total)) {
127
-			item.Ratio = "0"
127
+			item.Ratio = "0.0"
128 128
 		} else {
129 129
 			float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(total))*100), 64)
130 130
 			item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -428,7 +428,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
428 428
 
429 429
 		for _, item := range items {
430 430
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
431
-				item.Ratio = "0"
431
+				item.Ratio = "0.0"
432 432
 			} else {
433 433
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
434 434
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -522,7 +522,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
522 522
 
523 523
 		for _, item := range items {
524 524
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
525
-				item.Ratio = "0"
525
+				item.Ratio = "0.0"
526 526
 			} else {
527 527
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
528 528
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -622,7 +622,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
622 622
 
623 623
 		for _, item := range items {
624 624
 			if math.IsNaN(float64(item.Total) / float64(newTotal)) {
625
-				item.Ratio = "0"
625
+				item.Ratio = "0.0"
626 626
 			} else {
627 627
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(newTotal))*100), 64)
628 628
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -717,7 +717,7 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
717 717
 
718 718
 		for _, item := range items {
719 719
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
720
-				item.Ratio = "0"
720
+				item.Ratio = "0.0"
721 721
 			} else {
722 722
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
723 723
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -913,7 +913,7 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
913 913
 
914 914
 		for _, item := range items {
915 915
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
916
-				item.Ratio = "0"
916
+				item.Ratio = "0.0"
917 917
 			} else {
918 918
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
919 919
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -1002,7 +1002,7 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
1002 1002
 
1003 1003
 		for _, item := range items {
1004 1004
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
1005
-				item.Ratio = "0"
1005
+				item.Ratio = "0.0"
1006 1006
 			} else {
1007 1007
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1008 1008
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -1089,7 +1089,7 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
1089 1089
 
1090 1090
 		for _, item := range items {
1091 1091
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
1092
-				item.Ratio = "0"
1092
+				item.Ratio = "0.0"
1093 1093
 			} else {
1094 1094
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1095 1095
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -1167,25 +1167,59 @@ func GetDoctorWorkloadChartData(user_org_id int64, start_time int64, end_time in
1167 1167
 
1168 1168
 	switch statistics_type {
1169 1169
 	case 1:
1170
+		var Total int64
1171
+		db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1  AND created_time >= ? AND  created_time <= ?", user_org_id, start_time, end_time).Count(&Total)
1172
+
1170 1173
 		for _, item := range datas {
1171 1174
 			var total int64
1172 1175
 			db.Table("xt_dialysis_prescription as p").Where("user_org_id = ? AND status = 1 AND prescription_doctor = ? AND created_time >= ? AND  created_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1173 1176
 			item.PCount = total
1177
+
1178
+			if math.IsNaN(float64(item.PCount) / float64(Total)) {
1179
+				item.PRatio = "0.0"
1180
+			} else {
1181
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.PCount)/float64(Total))*100), 64)
1182
+				item.PRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1183
+			}
1184
+
1174 1185
 		}
1175 1186
 		break
1176 1187
 	case 2:
1188
+		var Total int64
1189
+		db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND ctime >= ? AND ctime <= ?", user_org_id, start_time, end_time).Count(&Total)
1190
+
1177 1191
 		for _, item := range datas {
1178 1192
 			var total int64
1179 1193
 			db.Table("xt_patient_course_of_disease as course").Where("org_id = ? AND status = 1 AND recorder = ? AND ctime >= ? AND ctime <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1180 1194
 			item.CourseCount = total
1195
+
1196
+			if math.IsNaN(float64(item.CourseCount) / float64(Total)) {
1197
+				item.CourseRatio = "0.0"
1198
+			} else {
1199
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.CourseCount)/float64(Total))*100), 64)
1200
+				item.CourseRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1201
+			}
1202
+
1181 1203
 		}
1182 1204
 
1183 1205
 		break
1184 1206
 	case 3:
1207
+		var Total int64
1208
+
1209
+		db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1  AND ctime >= ? AND ctime <= ?", user_org_id, start_time, end_time).Count(&Total)
1210
+
1185 1211
 		for _, item := range datas {
1186 1212
 			var total int64
1187 1213
 			db.Table("xt_patient_rescue_record as rescue").Where("org_id = ? AND status = 1 AND recorder = ?  AND ctime >= ? AND ctime <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1188 1214
 			item.RescueCount = total
1215
+
1216
+			if math.IsNaN(float64(item.RescueCount) / float64(Total)) {
1217
+				item.RescueRatio = "0.0"
1218
+			} else {
1219
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.RescueCount)/float64(Total))*100), 64)
1220
+				item.RescueRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1221
+			}
1222
+
1189 1223
 		}
1190 1224
 		break
1191 1225
 	}
@@ -1227,15 +1261,33 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1227 1261
 	db := service.XTReadDB()
1228 1262
 	userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 3 ", user_org_id).Scan(&datas)
1229 1263
 
1264
+	var NewTotalOne int64
1265
+	var NewTotalTwo int64
1266
+	var NewTotalThree int64
1267
+	var NewTotalFour int64
1268
+
1230 1269
 	var tempConfig models.Dataconfig
1231 1270
 	db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1232 1271
 
1272
+	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.created_time >= ? AND xt_dialysis_order.created_time <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time).Count(&NewTotalOne)
1273
+	db.Raw("select count(*) as total_one 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.created_time >= ? AND xt_dialysis_order.created_time <= ? ", user_org_id, tempConfig.ID, user_org_id, start_time, end_time).Count(&NewTotalTwo)
1274
+	db.Table("xt_monitoring_record ").Where("user_org_id = ? AND status = 1  AND created_time >= ? AND created_time <= ?", user_org_id, start_time, end_time).Count(&NewTotalThree)
1275
+	db.Table("xt_treatment_summary").Where("user_org_id = ? AND status = 1  AND created_time >= ? AND created_time <= ?", user_org_id, start_time, end_time).Count(&NewTotalFour)
1276
+
1233 1277
 	switch statistics_type {
1234 1278
 	case 1:
1235 1279
 		for _, item := range datas {
1236 1280
 			var Total int64
1237 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)
1238 1282
 			item.PunctureCount = Total
1283
+
1284
+			if math.IsNaN(float64(item.PunctureCount) / float64(NewTotalOne)) {
1285
+				item.PunctureRatio = "0.0"
1286
+			} else {
1287
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.PunctureCount)/float64(NewTotalOne))*100), 64)
1288
+				item.PunctureRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1289
+			}
1290
+
1239 1291
 		}
1240 1292
 		break
1241 1293
 	case 2:
@@ -1243,6 +1295,13 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1243 1295
 			var Total int64
1244 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)
1245 1297
 			item.ChangemedicineCount = Total
1298
+
1299
+			if math.IsNaN(float64(item.ChangemedicineCount) / float64(NewTotalTwo)) {
1300
+				item.ChangemedicineRatio = "0.0"
1301
+			} else {
1302
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.ChangemedicineCount)/float64(NewTotalTwo))*100), 64)
1303
+				item.ChangemedicineRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1304
+			}
1246 1305
 		}
1247 1306
 
1248 1307
 		break
@@ -1251,6 +1310,13 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1251 1310
 			var total int64
1252 1311
 			db.Table("xt_monitoring_record").Where("user_org_id = ? AND status = 1 AND monitoring_nurse = ?  AND created_time >= ? AND created_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&total)
1253 1312
 			item.CureCount = total
1313
+			if math.IsNaN(float64(item.CureCount) / float64(NewTotalThree)) {
1314
+				item.CureRatio = "0.0"
1315
+			} else {
1316
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.CureCount)/float64(NewTotalThree))*100), 64)
1317
+				item.CureRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1318
+			}
1319
+
1254 1320
 		}
1255 1321
 		break
1256 1322
 
@@ -1259,6 +1325,12 @@ func GetNurseWorkloadChartData(user_org_id int64, start_time int64, end_time int
1259 1325
 			var Total int64
1260 1326
 			db.Table("xt_treatment_summary ").Where("user_org_id = ? AND status = 1 AND creater = ?  AND created_time >= ? AND created_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&Total)
1261 1327
 			item.MissionCount = Total
1328
+			if math.IsNaN(float64(item.MissionCount) / float64(NewTotalFour)) {
1329
+				item.MissionRatio = "0.0"
1330
+			} else {
1331
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.MissionCount)/float64(NewTotalFour))*100), 64)
1332
+				item.MissionRatio = strconv.FormatFloat(float_value, 'f', 1, 32)
1333
+			}
1262 1334
 		}
1263 1335
 		break
1264 1336
 	}
@@ -1273,6 +1345,7 @@ func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int
1273 1345
 	userDb := service.UserReadDB()
1274 1346
 	db := service.XTReadDB()
1275 1347
 	var tempConfig models.Dataconfig
1348
+
1276 1349
 	db.Model(&models.Dataconfig{}).Where("name = '血管通路' AND module = 'hemodialysis' AND field_name = 'vascular_access_desc' AND parent_id = 0").First(&tempConfig)
1277 1350
 
1278 1351
 	if admin_user_id == 0 {
@@ -1280,6 +1353,7 @@ func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int
1280 1353
 	} else {
1281 1354
 		userDb.Raw("select admin_user_id, user_name,org_id  from sgj_user_admin_role  Where status = 1 AND org_id = ?  AND user_type = 3  AND admin_user_id = ?", user_org_id, admin_user_id).Scan(&datas)
1282 1355
 	}
1356
+
1283 1357
 	for _, item := range datas {
1284 1358
 		var Total int64
1285 1359
 		var TotalOne int64
@@ -1291,10 +1365,11 @@ func GetNurseWorkloadTableData(user_org_id int64, start_time int64, end_time int
1291 1365
 		db.Table("xt_treatment_summary").Where("user_org_id = ? AND status = 1 AND creater = ? AND created_time >= ? AND created_time <= ?", user_org_id, item.AdminUserId, start_time, end_time).Count(&TotalThree)
1292 1366
 		item.PunctureCount = Total
1293 1367
 		item.ChangemedicineCount = TotalOne
1294
-		item.PCount = Total
1295 1368
 		item.CureCount = TotalTwo
1296 1369
 		item.MissionCount = TotalThree
1370
+
1297 1371
 	}
1372
+
1298 1373
 	if err != nil {
1299 1374
 		return nil, err
1300 1375
 	}
@@ -1324,9 +1399,15 @@ func FindOrgInspectionCount(user_org_id int64) (count int64, err error) {
1324 1399
 	return
1325 1400
 }
1326 1401
 
1327
-func FindOrgInspectionReference(user_org_id int64) (references []*models.InspectionReference, err error) {
1402
+func FindOrgInspectionReference(user_org_id int64, range_type int) (references []*models.InspectionReference, err error) {
1328 1403
 	db := service.XTReadDB()
1329
-	err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ? AND range_max REGEXP '(^[0-9]+.[0-9]+$)|(^[0-9]$)' AND range_min REGEXP '(^[0-9]+.[0-9]+$)|(^[0-9]$)' ", user_org_id).Find(&references).Error
1404
+	if range_type == 1 {
1405
+		err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ? AND range_type = 1 AND range_max REGEXP '([^0-9.])' AND range_min REGEXP '([^0-9.])' ", user_org_id).Find(&references).Error
1406
+
1407
+	} else {
1408
+		err = db.Model(&models.InspectionReference{}).Where("status = 1 AND org_id = ? AND range_type = 2", user_org_id).Find(&references).Error
1409
+
1410
+	}
1330 1411
 	return
1331 1412
 }
1332 1413
 
@@ -1338,7 +1419,7 @@ func FindProcjectInspectionReference(user_org_id int64, project_id int64, item_i
1338 1419
 
1339 1420
 func FindOrgInspectionReferenceRangeTypeValue(user_org_id int64, project_id int64, item_id int64) (inspection []*models.Inspection, err error) {
1340 1421
 	db := service.XTReadDB()
1341
-	err = db.Model(&models.Inspection{}).Where("status = 1 AND org_id = ? AND project_id = ? AND item_id = ? AND  inspect_type = 2 AND inspect_value <> ''", user_org_id, project_id, item_id).Group("inspect_value").Find(&inspection).Error
1422
+	err = db.Model(&models.Inspection{}).Where("status = 1 AND org_id = ? AND project_id = ? AND item_id = ? ", user_org_id, project_id, item_id).Group("inspect_value").Find(&inspection).Error
1342 1423
 	return
1343 1424
 }
1344 1425
 
@@ -1356,10 +1437,10 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1356 1437
 	selectContent := "CASE"
1357 1438
 	range_value_arr := strings.Split(range_value, ",")
1358 1439
 
1359
-	db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, project_id, item_id).Count(&Total)
1440
+	db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND inspect_value <> '' ", user_org_id, start_time, end_time, project_id, item_id).Count(&Total)
1360 1441
 
1361 1442
 	if range_type == 1 {
1362
-		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, project_id, item_id).
1443
+		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND inspect_value <> ''", user_org_id, start_time, end_time, project_id, item_id).
1363 1444
 			Select("CASE WHEN inspect_value < " + range_value_arr[0] + " THEN " + "'" + "小于" + range_value_arr[0] + "'" +
1364 1445
 				" WHEN inspect_value >= " + range_value_arr[0] + " AND  inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +
1365 1446
 				" WHEN inspect_value > " + range_value_arr[1] + " THEN " + "'" + "大于" + range_value_arr[1] + "'" +
@@ -1409,7 +1490,7 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1409 1490
 
1410 1491
 		for _, item := range items {
1411 1492
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
1412
-				item.Ratio = "0"
1493
+				item.Ratio = "0.0"
1413 1494
 			} else {
1414 1495
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1415 1496
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -1423,14 +1504,14 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1423 1504
 			selectContent = selectContent + " WHEN inspect_value =" + "'" + item + "'" + " THEN " + "'" + item + "'"
1424 1505
 
1425 1506
 		}
1426
-		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, project_id, item_id).
1507
+		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND inspect_value <> '' ", user_org_id, start_time, end_time, project_id, item_id).
1427 1508
 			Select(selectContent +
1428 1509
 				" ELSE '未知' END AS name, COUNT(*) AS total",
1429 1510
 			).Group("name").Scan(&items).Error
1430 1511
 
1431 1512
 		for _, item := range items {
1432 1513
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
1433
-				item.Ratio = "0"
1514
+				item.Ratio = "0.0"
1434 1515
 			} else {
1435 1516
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1436 1517
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -1519,7 +1600,7 @@ func GetInspectionChartTableData(user_org_id int64, start_time int64, end_time i
1519 1600
 		if range_value == "全部" {
1520 1601
 			db := service.XTReadDB()
1521 1602
 			offset := (page - 1) * limit
1522
-			err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ?  AND project_id = ? AND item_id = ? AND status = 1  ", user_org_id, start_time, end_time, project_id, item_id).Preload("Patient", func(db *gorm.DB) *gorm.DB {
1603
+			err = db.Model(&Inspection{}).Where("org_id = ? AND status = 1 AND created_time >= ? AND created_time <= ?  AND project_id = ? AND item_id = ? AND status = 1   ", user_org_id, start_time, end_time, project_id, item_id).Preload("Patient", func(db *gorm.DB) *gorm.DB {
1523 1604
 				return db.Where("status = 1 AND user_org_id = ?", user_org_id)
1524 1605
 			}).Count(&total).Offset(offset).Limit(limit).Find(&datas).Error
1525 1606
 			return datas, total, err
@@ -1562,10 +1643,10 @@ func GetPatientInspectionBarChartData(user_org_id int64, start_time int64, end_t
1562 1643
 	range_value_arr := strings.Split(range_value, ",")
1563 1644
 	var Total int64
1564 1645
 
1565
-	db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND patient_id = ?", user_org_id, start_time, end_time, project_id, item_id, patient_id).Count(&Total)
1646
+	db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND patient_id = ?  AND inspect_value <> ''", user_org_id, start_time, end_time, project_id, item_id, patient_id).Count(&Total)
1566 1647
 
1567 1648
 	if range_type == 1 {
1568
-		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND patient_id = ?", user_org_id, start_time, end_time, project_id, item_id, patient_id).
1649
+		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND project_id = ? AND item_id = ? AND patient_id = ? AND inspect_value <> ''", user_org_id, start_time, end_time, project_id, item_id, patient_id).
1569 1650
 			Select("CASE WHEN inspect_value < " + range_value_arr[0] + " THEN " + "'" + "小于" + range_value_arr[0] + "'" +
1570 1651
 				" WHEN inspect_value >= " + range_value_arr[0] + " AND  inspect_value <= " + range_value_arr[1] + " THEN " + "'" + range_value_arr[0] + "~" + range_value_arr[1] + "'" +
1571 1652
 				" WHEN inspect_value > " + range_value_arr[1] + " THEN " + "'" + "大于" + range_value_arr[1] + "'" +
@@ -1615,7 +1696,7 @@ func GetPatientInspectionBarChartData(user_org_id int64, start_time int64, end_t
1615 1696
 
1616 1697
 		for _, item := range items {
1617 1698
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
1618
-				item.Ratio = "0"
1699
+				item.Ratio = "0.0"
1619 1700
 			} else {
1620 1701
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1621 1702
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
@@ -1629,13 +1710,13 @@ func GetPatientInspectionBarChartData(user_org_id int64, start_time int64, end_t
1629 1710
 		for _, item := range range_value_arr {
1630 1711
 			selectContent = selectContent + " WHEN inspect_value =" + "'" + item + "'" + " THEN " + "'" + item + "'"
1631 1712
 		}
1632
-		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND patient_id  = ?", user_org_id, start_time, end_time, patient_id).
1713
+		tempErr = db.Table("xt_inspection").Where("org_id=? and status=1 and  created_time >= ? and created_time <= ? AND patient_id  = ? AND inspect_value <> '' AND project_id = ? AND item_id = ?", user_org_id, start_time, end_time, patient_id, project_id, item_id).
1633 1714
 			Select(selectContent +
1634 1715
 				" ELSE '未知' END AS name, COUNT(*) AS total",
1635 1716
 			).Group("name").Scan(&items).Error
1636 1717
 		for _, item := range items {
1637 1718
 			if math.IsNaN(float64(item.Total) / float64(Total)) {
1638
-				item.Ratio = "0"
1719
+				item.Ratio = "0.0"
1639 1720
 			} else {
1640 1721
 				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1641 1722
 				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)

+ 13 - 3
service/statistics_service/index_models.go Ver fichero

@@ -119,14 +119,24 @@ type VMUserAdminRole struct {
119 119
 	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
120 120
 	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
121 121
 	UserName    string `gorm:"column:user_name" json:"user_name" form:"user_name"`
122
-	PCount      int64  `gorm:"-" json:"p_count"`
123
-	CourseCount int64  `gorm:"-" json:"course_count" `
122
+
123
+	PCount      int64 `gorm:"-" json:"p_count"`
124
+	CourseCount int64 `gorm:"-" json:"course_count" `
125
+	RescueCount int64 `gorm:"-" json:"rescue_count" `
124 126
 
125 127
 	PunctureCount       int64 `gorm:"-" json:"puncture_count" `
126 128
 	ChangemedicineCount int64 `gorm:"-" json:"change_medicine_count" `
127
-	RescueCount         int64 `gorm:"-" json:"rescue_count" `
128 129
 	CureCount           int64 `gorm:"-" json:"cure_count" `
129 130
 	MissionCount        int64 `gorm:"-" json:"mission_count" `
131
+
132
+	PRatio      string `gorm:"-" json:"p_ratio"`
133
+	CourseRatio string `gorm:"-" json:"course_ratio" `
134
+	RescueRatio string `gorm:"-" json:"rescue_ratio" `
135
+
136
+	PunctureRatio       string `gorm:"-" json:"puncture_ratio" `
137
+	ChangemedicineRatio string `gorm:"-" json:"change_medicine_ratio" `
138
+	CureRatio           string `gorm:"-" json:"cure_ratio" `
139
+	MissionRatio        string `gorm:"-" json:"mission_ratio" `
130 140
 }
131 141
 
132 142
 func (VMUserAdminRole) TableName() string {