|
@@ -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,8 +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
|
753
|
|
- fmt.Println(Total)
|
|
807
|
+
|
754
|
808
|
switch statistics_type {
|
755
|
809
|
case 1:
|
756
|
810
|
type bp struct {
|
|
@@ -761,11 +815,22 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
761
|
815
|
|
762
|
816
|
if patient_id == 0 {
|
763
|
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)
|
764
|
|
- //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)
|
765
|
825
|
|
766
|
826
|
} else {
|
767
|
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)
|
768
|
|
- //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)
|
769
|
834
|
|
770
|
835
|
}
|
771
|
836
|
|
|
@@ -780,11 +845,9 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
780
|
845
|
} else if item.SystolicBloodPressure < 140 && item.DiastolicBloodPressure < 99 {
|
781
|
846
|
total_two++
|
782
|
847
|
|
783
|
|
- } 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 {
|
784
|
849
|
total_three++
|
785
|
850
|
} else {
|
786
|
|
- fmt.Println(item.SystolicBloodPressure)
|
787
|
|
- fmt.Println(item.DiastolicBloodPressure)
|
788
|
851
|
|
789
|
852
|
total_four++
|
790
|
853
|
}
|
|
@@ -816,38 +879,42 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
816
|
879
|
items = append(items, newItem2)
|
817
|
880
|
items = append(items, newItem3)
|
818
|
881
|
|
819
|
|
- //
|
820
|
|
- //for _, item := range items {
|
821
|
|
- // float_value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(item.Total)/float64(Total)), 64)
|
822
|
|
- // item.Ratio = strconv.FormatInt(int64(float_value*100), 10)
|
823
|
|
- //}
|
824
|
|
-
|
|
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
|
+ }
|
825
|
890
|
break
|
826
|
891
|
case 2:
|
827
|
892
|
if patient_id == 0 {
|
828
|
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).
|
829
|
894
|
Select("CASE WHEN systolic_blood_pressure > 160 AND diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
|
830
|
895
|
" WHEN systolic_blood_pressure < 140 AND diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
|
831
|
|
- " 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'" +
|
832
|
897
|
" ELSE '其他' END AS name, COUNT(*) AS total",
|
833
|
|
- ).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)
|
834
|
900
|
|
835
|
901
|
} else {
|
836
|
902
|
|
837
|
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).
|
838
|
904
|
Select("CASE WHEN systolic_blood_pressure > 160 AND diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
|
839
|
905
|
" WHEN systolic_blood_pressure < 140 AND diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
|
840
|
|
- " 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'" +
|
841
|
907
|
" ELSE '其他' END AS name, COUNT(*) AS total",
|
842
|
|
- ).Scan(&items).Group("name").Error
|
|
908
|
+ ).Group("name").Scan(&items).Error
|
843
|
909
|
|
844
|
|
- }
|
|
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)
|
845
|
911
|
|
846
|
|
- //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
|
+ }
|
847
|
913
|
|
848
|
914
|
var isHasConditionOne bool = false
|
849
|
915
|
var isHasConditionTwo bool = false
|
850
|
916
|
var isHasConditionThree bool = false
|
|
917
|
+ var isHasConditionFour bool = false
|
851
|
918
|
|
852
|
919
|
for _, item := range items {
|
853
|
920
|
if item.Name == "大于160/100mmHg" {
|
|
@@ -860,6 +927,9 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
860
|
927
|
if item.Name == "140-160mmHg/90-100mmHg" {
|
861
|
928
|
isHasConditionThree = true
|
862
|
929
|
}
|
|
930
|
+ if item.Name == "其他" {
|
|
931
|
+ isHasConditionFour = true
|
|
932
|
+ }
|
863
|
933
|
}
|
864
|
934
|
if !isHasConditionOne {
|
865
|
935
|
newItem := &otherItemAmount{
|
|
@@ -887,7 +957,24 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
887
|
957
|
Ratio: "0",
|
888
|
958
|
}
|
889
|
959
|
items = append(items, newItem)
|
|
960
|
+ }
|
890
|
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
|
+ }
|
891
|
978
|
}
|
892
|
979
|
break
|
893
|
980
|
case 3:
|
|
@@ -895,21 +982,27 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
895
|
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).
|
896
|
983
|
Select("CASE WHEN systolic_blood_pressure > 160 AND diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
|
897
|
984
|
" WHEN systolic_blood_pressure < 140 AND diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
|
898
|
|
- " 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'" +
|
899
|
986
|
" ELSE '其他' END AS name, COUNT(*) AS total",
|
900
|
|
- ).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
|
+
|
901
|
990
|
} else {
|
902
|
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).
|
903
|
992
|
Select("CASE WHEN systolic_blood_pressure > 160 AND diastolic_blood_pressure > 100 THEN '大于160/100mmHg'" +
|
904
|
993
|
" WHEN systolic_blood_pressure < 140 AND diastolic_blood_pressure < 99 THEN '小于140/99mmHg'" +
|
905
|
|
- " 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'" +
|
906
|
995
|
" ELSE '其他' END AS name, COUNT(*) AS total",
|
907
|
|
- ).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
|
+
|
908
|
1000
|
}
|
909
|
1001
|
|
910
|
1002
|
var isHasConditionOne bool = false
|
911
|
1003
|
var isHasConditionTwo bool = false
|
912
|
1004
|
var isHasConditionThree bool = false
|
|
1005
|
+ var isHasConditionFour bool = false
|
913
|
1006
|
|
914
|
1007
|
for _, item := range items {
|
915
|
1008
|
if item.Name == "大于160/100mmHg" {
|
|
@@ -922,6 +1015,9 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
922
|
1015
|
if item.Name == "140-160mmHg/90-100mmHg" {
|
923
|
1016
|
isHasConditionThree = true
|
924
|
1017
|
}
|
|
1018
|
+ if item.Name == "其他" {
|
|
1019
|
+ isHasConditionFour = true
|
|
1020
|
+ }
|
925
|
1021
|
}
|
926
|
1022
|
if !isHasConditionOne {
|
927
|
1023
|
newItem := &otherItemAmount{
|
|
@@ -950,6 +1046,23 @@ func GetBloodPressureChartData(user_org_id int64, start_time int64, end_time int
|
950
|
1046
|
|
951
|
1047
|
}
|
952
|
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
|
+ }
|
953
|
1066
|
break
|
954
|
1067
|
}
|
955
|
1068
|
if tempErr != nil {
|
|
@@ -995,7 +1108,6 @@ type BPDataStruct struct {
|
995
|
1108
|
}
|
996
|
1109
|
|
997
|
1110
|
func GetPatientBloodPressureChartData(user_org_id int64, patient_id int64, start_time int64, end_time int64, statistics_type int) (datas []*BPDataStruct, err error) {
|
998
|
|
- fmt.Println("8u8923u213u8129")
|
999
|
1111
|
db := service.XTReadDB()
|
1000
|
1112
|
switch statistics_type {
|
1001
|
1113
|
case 1:
|
|
@@ -1208,10 +1320,11 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
|
1208
|
1320
|
db := service.XTReadDB()
|
1209
|
1321
|
var items []*otherItemAmount
|
1210
|
1322
|
var tempErr error
|
|
1323
|
+ var Total int64
|
1211
|
1324
|
selectContent := "CASE"
|
1212
|
1325
|
range_value_arr := strings.Split(range_value, ",")
|
1213
|
1326
|
|
1214
|
|
- 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)
|
1215
|
1328
|
|
1216
|
1329
|
if range_type == 1 {
|
1217
|
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).
|
|
@@ -1261,10 +1374,18 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
|
1261
|
1374
|
}
|
1262
|
1375
|
items = append(items, newItem)
|
1263
|
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
|
+ }
|
1264
|
1386
|
return items, tempErr
|
1265
|
1387
|
|
1266
|
1388
|
} else {
|
1267
|
|
-
|
1268
|
1389
|
for _, item := range range_value_arr {
|
1269
|
1390
|
//selectContent = selectContent + " WHEN inspect_value =" + item + " THEN " + "'" + item + "'"
|
1270
|
1391
|
selectContent = selectContent + " WHEN inspect_value =" + "'" + item + "'" + " THEN " + "'" + item + "'"
|
|
@@ -1274,6 +1395,16 @@ func GetInspectionChartData(user_org_id int64, start_time int64, end_time int64,
|
1274
|
1395
|
Select(selectContent +
|
1275
|
1396
|
" ELSE '未知' END AS name, COUNT(*) AS total",
|
1276
|
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
|
+
|
1277
|
1408
|
return items, tempErr
|
1278
|
1409
|
}
|
1279
|
1410
|
|