Browse Source

Merge branch 'xt_statistics_branch'

csx 4 years ago
parent
commit
62445200d9

+ 0 - 10
controllers/pc_index_evaluation_api_controller.go View File

@@ -147,17 +147,12 @@ func (this *PCIndexEvaluationApiController) GetInspectionChartData() {
147 147
 			} else { //是,读集成过来的参考值
148 148
 				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.CurrentOrgId, project_id, item_id)
149 149
 				range_value = reference.RangeMin + "," + reference.RangeMax
150
-
151 150
 			}
152
-
153 151
 		} else { //有配置
154
-
155 152
 			range_value = qcs.MinRange + "," + qcs.LargeRange
156
-
157 153
 		}
158 154
 
159 155
 	} else {
160
-
161 156
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
162 157
 		for _, item := range inspection {
163 158
 			if len(range_value) == 0 {
@@ -290,21 +285,16 @@ func (this *PCIndexEvaluationApiController) GetPatientInspectionBarChartData() {
290 285
 			if count <= 0 {                                                                   //不是,读系统参考值
291 286
 				reference, _ := statistics_service.FindProcjectInspectionReference(0, project_id, item_id)
292 287
 				range_value = reference.RangeMin + "," + reference.RangeMax
293
-
294 288
 			} else { //是,读集成过来的参考值
295 289
 				reference, _ := statistics_service.FindProcjectInspectionReference(adminUserInfo.CurrentOrgId, project_id, item_id)
296 290
 				range_value = reference.RangeMin + "," + reference.RangeMax
297
-
298 291
 			}
299 292
 
300 293
 		} else { //有配置
301
-
302 294
 			range_value = qcs.MinRange + "," + qcs.LargeRange
303
-
304 295
 		}
305 296
 
306 297
 	} else {
307
-
308 298
 		inspection, _ := statistics_service.FindOrgInspectionReferenceRangeTypeValue(adminUserInfo.CurrentOrgId, project_id, item_id)
309 299
 		for _, item := range inspection {
310 300
 			if len(range_value) == 0 {

+ 164 - 32
service/statistics_service/index_evaluation_service.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"XT_New/service"
6 6
 	"fmt"
7 7
 	"github.com/jinzhu/gorm"
8
+	"math"
8 9
 	"strconv"
9 10
 	"strings"
10 11
 )
@@ -122,8 +123,12 @@ func GetDialysisProcessIndexOtherChartData(user_org_id int64, patient_id int64,
122 123
 	db.Table("xt_dialysis_prescription as p").Where("p.user_org_id=? AND p.status = 1 AND p.patient_id = ? AND p.created_time >= ? and p.created_time <= ? ", user_org_id, patient_id, start_time, end_time).Count(&total)
123 124
 
124 125
 	for _, item := range items {
125
-		float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(item.Total)/float64(total)), 64)
126
-		item.Ratio = strconv.FormatInt(int64(float_value*100), 10)
126
+		if math.IsNaN(float64(item.Total) / float64(total)) {
127
+			item.Ratio = "0"
128
+		} else {
129
+			float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(total))*100), 64)
130
+			item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
131
+		}
127 132
 	}
128 133
 	if tempErr != nil {
129 134
 		return nil, err
@@ -304,9 +309,10 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
304 309
 	db := service.XTReadDB()
305 310
 	var items []*otherItemAmount
306 311
 	var tempErr error
307
-	//var total int64
312
+	var Total int64
308 313
 	switch statistics_type {
309 314
 	case 1:
315
+		db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).Count(&Total)
310 316
 		tempErr = db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).
311 317
 			Select("CASE WHEN dry_weight < 40 THEN '小于40kg'" +
312 318
 				" WHEN dry_weight >= 40 AND dry_weight < 50 THEN '40~50kg'" +
@@ -388,8 +394,19 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
388 394
 			items = append(items, newItem)
389 395
 		}
390 396
 
397
+		for _, item := range items {
398
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
399
+				item.Ratio = "0"
400
+			} else {
401
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
402
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
403
+			}
404
+		}
405
+
391 406
 		break
392 407
 	case 2:
408
+		db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).Count(&Total)
409
+
393 410
 		tempErr = db.Table("xt_assessment_before_dislysis").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).
394 411
 			Select("CASE WHEN weight_before < 40 THEN '小于40kg'" +
395 412
 				" WHEN weight_before >= 40 AND weight_before < 50 THEN '40~50kg'" +
@@ -470,8 +487,24 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
470 487
 			}
471 488
 			items = append(items, newItem)
472 489
 		}
490
+
491
+		for _, item := range items {
492
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
493
+				item.Ratio = "0"
494
+			} else {
495
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
496
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
497
+			}
498
+		}
499
+
473 500
 		break
474 501
 	case 3:
502
+
503
+		//db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).Count(&Total)
504
+
505
+		//db.Raw("Select count(*) from `xt_assessment_before_dislysis`   LEFT JOIN  `xt_assessment_after_dislysis`  On xt_assessment_before_dislysis.`patient_id` = xt_assessment_after_dislysis.`patient_id` AND xt_assessment_before_dislysis.assessment_date = xt_assessment_after_dislysis.assessment_date AND xt_assessment_after_dislysis.weight_after != 0   Where  xt_assessment_before_dislysis.user_org_id = ? AND xt_assessment_before_dislysis.created_time >= ? AND  xt_assessment_before_dislysis.created_time <= ? Order by xt_assessment_before_dislysis.assessment_date desc", user_org_id, start_time, end_time).Count(&Total)
506
+
507
+		var newTotal int64
475 508
 		type weight struct {
476 509
 			WeightAfter  float64 `json:"weight_after"`
477 510
 			WeightBefore float64 `json:"weight_before"`
@@ -497,35 +530,32 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
497 530
 		for _, item := range weightAdd {
498 531
 			if item < 1 {
499 532
 				total_one++
500
-				fmt.Println(total_one)
501 533
 
502 534
 			}
503 535
 
504 536
 			if item >= 1 && item < 2 {
505 537
 				total_two++
506
-				fmt.Println(total_two)
507 538
 
508 539
 			}
509 540
 
510 541
 			if item >= 2 && item < 3 {
511 542
 				total_three++
512
-				fmt.Println(total_three)
513 543
 
514 544
 			}
515 545
 
516 546
 			if item >= 3 && item <= 4 {
517 547
 				total_four++
518
-				fmt.Println(total_four)
519 548
 
520 549
 			}
521 550
 
522 551
 			if item > 4 {
523 552
 				total_five++
524
-				fmt.Println(total_five)
525 553
 
526 554
 			}
527 555
 		}
528 556
 
557
+		newTotal = total_one + total_two + total_three + total_four + total_five
558
+
529 559
 		newItem := &otherItemAmount{
530 560
 			Total: total_one,
531 561
 			Name:  "小于1kg",
@@ -558,8 +588,20 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
558 588
 		items = append(items, newItem3)
559 589
 		items = append(items, newItem4)
560 590
 
591
+		for _, item := range items {
592
+			if math.IsNaN(float64(item.Total) / float64(newTotal)) {
593
+				item.Ratio = "0"
594
+			} else {
595
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(newTotal))*100), 64)
596
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
597
+			}
598
+		}
599
+
561 600
 		break
562 601
 	case 4:
602
+
603
+		db.Table("xt_assessment_after_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).Count(&Total)
604
+
563 605
 		tempErr = db.Table("xt_assessment_after_dislysis").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?", user_org_id, start_time, end_time).
564 606
 			Select("CASE WHEN weight_after < 40 THEN '小于40kg'" +
565 607
 				" WHEN weight_after >= 40 AND weight_after < 50 THEN '40~50kg'" +
@@ -640,6 +682,16 @@ func GetDialysisWeightChartData(user_org_id int64, start_time int64, end_time in
640 682
 			}
641 683
 			items = append(items, newItem)
642 684
 		}
685
+
686
+		for _, item := range items {
687
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
688
+				item.Ratio = "0"
689
+			} else {
690
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
691
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
692
+			}
693
+		}
694
+
643 695
 		break
644 696
 	}
645 697
 	if tempErr != nil {
@@ -749,7 +801,10 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
749 801
 	db := service.XTReadDB()
750 802
 	var items []*otherItemAmount
751 803
 	var tempErr error
804
+	var TotalOne int64
805
+	var TotalTwo int64
752 806
 	var Total int64
807
+
753 808
 	switch statistics_type {
754 809
 	case 1:
755 810
 		type bp struct {
@@ -760,11 +815,22 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
760 815
 
761 816
 		if patient_id == 0 {
762 817
 			db.Raw("SELECT systolic_blood_pressure,diastolic_blood_pressure FROM xt_assessment_before_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ?   UNION ALL SELECT systolic_blood_pressure,diastolic_blood_pressure  FROM xt_assessment_after_dislysis Where user_org_id = ? AND created_time >= ? AND created_time <= ?  ", user_org_id, start_time, end_time, user_org_id, start_time, end_time).Scan(&bps)
763
-			//db.Raw("SELECT count(id) FROM xt_assessment_before_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ?   UNION ALL SELECT systolic_blood_pressure,diastolic_blood_pressure  FROM xt_assessment_after_dislysis Where user_org_id = ? AND created_time >= ? AND created_time <= ?  ", user_org_id, start_time, end_time, user_org_id, start_time, end_time).Count(&Total)
818
+			db.Raw("SELECT count(id) FROM xt_assessment_before_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ?     ", user_org_id, start_time, end_time).Count(&TotalOne)
819
+			db.Raw("SELECT count(id) FROM xt_assessment_after_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ?   ", user_org_id, start_time, end_time).Count(&TotalTwo)
820
+			Total = TotalOne + TotalTwo
821
+			fmt.Println("----Total-----")
822
+			fmt.Println(TotalOne)
823
+			fmt.Println(TotalTwo)
824
+			fmt.Println(Total)
764 825
 
765 826
 		} else {
766 827
 			db.Raw("SELECT systolic_blood_pressure,diastolic_blood_pressure FROM xt_assessment_before_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ? AND patient_id = ?  UNION ALL SELECT systolic_blood_pressure,diastolic_blood_pressure  FROM xt_assessment_after_dislysis Where user_org_id = ? AND created_time >= ? AND created_time <= ? AND patient_id = ?  ", user_org_id, start_time, end_time, patient_id, user_org_id, start_time, end_time, patient_id).Scan(&bps)
767
-			//db.Raw("SELECT  count(id) FROM xt_assessment_before_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ? AND patient_id = ?  UNION ALL SELECT systolic_blood_pressure,diastolic_blood_pressure  FROM xt_assessment_after_dislysis Where user_org_id = ? AND created_time >= ? AND created_time <= ? AND patient_id = ?  ", user_org_id, start_time, end_time, patient_id, user_org_id, start_time, end_time, patient_id).Count(&Total)
828
+			db.Raw("SELECT count(id) FROM xt_assessment_before_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ? AND patient_id = ?", user_org_id, start_time, end_time, patient_id).Count(&TotalOne)
829
+			db.Raw("SELECT count(id) FROM xt_assessment_after_dislysis Where user_org_id = ? AND  created_time >= ? AND created_time <= ? AND patient_id = ? ", user_org_id, start_time, end_time, patient_id).Count(&TotalTwo)
830
+			Total = TotalOne + TotalTwo
831
+			fmt.Println(TotalOne)
832
+			fmt.Println(TotalTwo)
833
+			fmt.Println(Total)
768 834
 
769 835
 		}
770 836
 
@@ -779,11 +845,9 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
779 845
 			} else if item.SystolicBloodPressure < 140 && item.DiastolicBloodPressure < 99 {
780 846
 				total_two++
781 847
 
782
-			} else if item.SystolicBloodPressure >= 100 && item.SystolicBloodPressure <= 160 && item.DiastolicBloodPressure >= 99 && item.DiastolicBloodPressure <= 140 {
848
+			} else if item.SystolicBloodPressure >= 140 && item.SystolicBloodPressure <= 160 && item.DiastolicBloodPressure >= 99 && item.DiastolicBloodPressure <= 100 {
783 849
 				total_three++
784 850
 			} else {
785
-				fmt.Println(item.SystolicBloodPressure)
786
-				fmt.Println(item.DiastolicBloodPressure)
787 851
 
788 852
 				total_four++
789 853
 			}
@@ -815,38 +879,42 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
815 879
 		items = append(items, newItem2)
816 880
 		items = append(items, newItem3)
817 881
 
818
-		//
819
-		//for _, item := range items {
820
-		//	float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(item.Total)/float64(Total)), 64)
821
-		//	item.Ratio = strconv.FormatInt(int64(float_value*100), 10)
822
-		//}
823
-
882
+		for _, item := range items {
883
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
884
+				item.Ratio = "0"
885
+			} else {
886
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
887
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
888
+			}
889
+		}
824 890
 		break
825 891
 	case 2:
826 892
 		if patient_id == 0 {
827 893
 			tempErr = db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?  ", user_org_id, start_time, end_time).
828 894
 				Select("CASE WHEN systolic_blood_pressure > 160 AND  diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
829 895
 					" WHEN systolic_blood_pressure < 140 AND  diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
830
-					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure >= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 140 THEN '140-160mmHg/90-100mmHg'" +
896
+					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure <= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 100 THEN '140-160mmHg/90-100mmHg'" +
831 897
 					" ELSE '其他' END AS name, COUNT(*) AS total",
832
-				).Scan(&items).Group("name").Error
898
+				).Group("name").Scan(&items).Error
899
+			db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? AND status = 1  AND created_time >= ? AND created_time <= ? ", user_org_id, start_time, end_time).Count(&Total)
833 900
 
834 901
 		} else {
835 902
 
836 903
 			tempErr = db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ?  and patient_id = ? ", user_org_id, start_time, end_time, patient_id).
837 904
 				Select("CASE WHEN systolic_blood_pressure > 160 AND  diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
838 905
 					" WHEN systolic_blood_pressure < 140 AND  diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
839
-					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure >= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 140 THEN '140-160mmHg/90-100mmHg'" +
906
+					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure <= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 100 THEN '140-160mmHg/90-100mmHg'" +
840 907
 					" ELSE '其他' END AS name, COUNT(*) AS total",
841
-				).Scan(&items).Group("name").Error
908
+				).Group("name").Scan(&items).Error
842 909
 
843
-		}
910
+			db.Table("xt_assessment_before_dislysis ").Where("user_org_id=? AND status = 1  AND created_time >= ? AND created_time <= ? AND patient_id = ?", user_org_id, start_time, end_time, patient_id).Count(&Total)
844 911
 
845
-		//db.Table("xt_assessment_before_dislysis as before").Where("before.user_org_id=? AND before.status = 1  AND before.created_time >= ? and before.created_time <= ? ", user_org_id, patient_id, start_time, end_time).Count(&total)
912
+		}
846 913
 
847 914
 		var isHasConditionOne bool = false
848 915
 		var isHasConditionTwo bool = false
849 916
 		var isHasConditionThree bool = false
917
+		var isHasConditionFour bool = false
850 918
 
851 919
 		for _, item := range items {
852 920
 			if item.Name == "大于160/100mmHg" {
@@ -859,6 +927,9 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
859 927
 			if item.Name == "140-160mmHg/90-100mmHg" {
860 928
 				isHasConditionThree = true
861 929
 			}
930
+			if item.Name == "其他" {
931
+				isHasConditionFour = true
932
+			}
862 933
 		}
863 934
 		if !isHasConditionOne {
864 935
 			newItem := &otherItemAmount{
@@ -886,7 +957,24 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
886 957
 				Ratio: "0",
887 958
 			}
888 959
 			items = append(items, newItem)
960
+		}
889 961
 
962
+		if !isHasConditionFour {
963
+			newItem := &otherItemAmount{
964
+				Total: 0,
965
+				Name:  "其他",
966
+				Ratio: "0",
967
+			}
968
+			items = append(items, newItem)
969
+		}
970
+
971
+		for _, item := range items {
972
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
973
+				item.Ratio = "0"
974
+			} else {
975
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
976
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
977
+			}
890 978
 		}
891 979
 		break
892 980
 	case 3:
@@ -894,21 +982,27 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
894 982
 			tempErr = db.Table("xt_assessment_after_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ? ", user_org_id, start_time, end_time).
895 983
 				Select("CASE WHEN systolic_blood_pressure > 160 AND  diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
896 984
 					" WHEN systolic_blood_pressure < 140 AND  diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
897
-					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure >= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 140 THEN '140-160mmHg/90-100mmHg'" +
985
+					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure <= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 100 THEN '140-160mmHg/90-100mmHg'" +
898 986
 					" ELSE '其他' END AS name, COUNT(*) AS total",
899
-				).Scan(&items).Group("name").Error
987
+				).Group("name").Scan(&items).Error
988
+			db.Table("xt_assessment_after_dislysis").Where("user_org_id=? AND status = 1  AND created_time >= ? AND created_time <= ? ", user_org_id, start_time, end_time).Count(&Total)
989
+
900 990
 		} else {
901 991
 			tempErr = db.Table("xt_assessment_after_dislysis ").Where("user_org_id=? and status=1 and  created_time >= ? and created_time <= ? and patient_id = ?", user_org_id, start_time, end_time, patient_id).
902 992
 				Select("CASE WHEN systolic_blood_pressure > 160 AND  diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
903 993
 					" WHEN systolic_blood_pressure < 140 AND  diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
904
-					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure >= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 140 THEN '140-160mmHg/90-100mmHg'" +
994
+					" WHEN systolic_blood_pressure >= 140 AND  systolic_blood_pressure <= 160   AND  diastolic_blood_pressure >= 99 AND  diastolic_blood_pressure <= 100 THEN '140-160mmHg/90-100mmHg'" +
905 995
 					" ELSE '其他' END AS name, COUNT(*) AS total",
906
-				).Scan(&items).Group("name").Error
996
+				).Group("name").Scan(&items).Error
997
+
998
+			db.Table("xt_assessment_after_dislysis ").Where("user_org_id=? AND status = 1  AND created_time >= ? AND created_time <= ? AND patient_id = ? ", user_org_id, start_time, end_time, patient_id).Count(&Total)
999
+
907 1000
 		}
908 1001
 
909 1002
 		var isHasConditionOne bool = false
910 1003
 		var isHasConditionTwo bool = false
911 1004
 		var isHasConditionThree bool = false
1005
+		var isHasConditionFour bool = false
912 1006
 
913 1007
 		for _, item := range items {
914 1008
 			if item.Name == "大于160/100mmHg" {
@@ -921,6 +1015,9 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
921 1015
 			if item.Name == "140-160mmHg/90-100mmHg" {
922 1016
 				isHasConditionThree = true
923 1017
 			}
1018
+			if item.Name == "其他" {
1019
+				isHasConditionFour = true
1020
+			}
924 1021
 		}
925 1022
 		if !isHasConditionOne {
926 1023
 			newItem := &otherItemAmount{
@@ -949,6 +1046,23 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
949 1046
 
950 1047
 		}
951 1048
 
1049
+		if !isHasConditionFour {
1050
+			newItem := &otherItemAmount{
1051
+				Total: 0,
1052
+				Name:  "其他",
1053
+				Ratio: "0",
1054
+			}
1055
+			items = append(items, newItem)
1056
+		}
1057
+
1058
+		for _, item := range items {
1059
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
1060
+				item.Ratio = "0"
1061
+			} else {
1062
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1063
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
1064
+			}
1065
+		}
952 1066
 		break
953 1067
 	}
954 1068
 	if tempErr != nil {
@@ -994,7 +1108,6 @@ type BPDataStruct struct {
994 1108
 }
995 1109
 
996 1110
 func GetPatientBloodPressureChartData(user_org_id int64, patient_id int64, start_time int64, end_time int64, statistics_type int) (datas []*BPDataStruct, err error) {
997
-	fmt.Println("8u8923u213u8129")
998 1111
 	db := service.XTReadDB()
999 1112
 	switch statistics_type {
1000 1113
 	case 1:
@@ -1207,10 +1320,11 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1207 1320
 	db := service.XTReadDB()
1208 1321
 	var items []*otherItemAmount
1209 1322
 	var tempErr error
1323
+	var Total int64
1210 1324
 	selectContent := "CASE"
1211 1325
 	range_value_arr := strings.Split(range_value, ",")
1212 1326
 
1213
-	fmt.Println(range_value_arr)
1327
+	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)
1214 1328
 
1215 1329
 	if range_type == 1 {
1216 1330
 		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).
@@ -1260,10 +1374,18 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1260 1374
 			}
1261 1375
 			items = append(items, newItem)
1262 1376
 		}
1377
+
1378
+		for _, item := range items {
1379
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
1380
+				item.Ratio = "0"
1381
+			} else {
1382
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1383
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
1384
+			}
1385
+		}
1263 1386
 		return items, tempErr
1264 1387
 
1265 1388
 	} else {
1266
-
1267 1389
 		for _, item := range range_value_arr {
1268 1390
 			//selectContent = selectContent + " WHEN inspect_value =" + item + " THEN " + "'" + item + "'"
1269 1391
 			selectContent = selectContent + " WHEN inspect_value =" + "'" + item + "'" + " THEN " + "'" + item + "'"
@@ -1273,6 +1395,16 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
1273 1395
 			Select(selectContent +
1274 1396
 				" ELSE '未知' END AS name, COUNT(*) AS total",
1275 1397
 			).Group("name").Scan(&items).Error
1398
+
1399
+		for _, item := range items {
1400
+			if math.IsNaN(float64(item.Total) / float64(Total)) {
1401
+				item.Ratio = "0"
1402
+			} else {
1403
+				float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.1f", (float64(item.Total)/float64(Total))*100), 64)
1404
+				item.Ratio = strconv.FormatFloat(float_value, 'f', 1, 32)
1405
+			}
1406
+		}
1407
+
1276 1408
 		return items, tempErr
1277 1409
 	}
1278 1410