|
@@ -497,8 +497,6 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
|
497
|
497
|
|
498
|
498
|
db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
499
|
499
|
|
500
|
|
- d := XTReadDB().Table("xt_patients as p")
|
501
|
|
- fmt.Println(d)
|
502
|
500
|
if orgid > 0 {
|
503
|
501
|
db = db.Where("o.user_org_id = ?", orgid)
|
504
|
502
|
}
|
|
@@ -509,7 +507,7 @@ func GetDialysisList(startime int64, endtime int64, page int64, limit int64, org
|
509
|
507
|
db = db.Where("o.dialysis_date<=?", endtime)
|
510
|
508
|
}
|
511
|
509
|
offset := (page - 1) * limit
|
512
|
|
- err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.status = 1").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
|
|
510
|
+ err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("join xt_patients as p on p.id = o.patient_id").Where("s.status = 1").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
|
513
|
511
|
return order, total, err
|
514
|
512
|
|
515
|
513
|
}
|
|
@@ -526,16 +524,14 @@ func GetAllDialysisList(startime int64, endtime int64, orgid int64) (order []*mo
|
526
|
524
|
if endtime > 0 {
|
527
|
525
|
db = db.Where("o.dialysis_date<=?", endtime)
|
528
|
526
|
}
|
529
|
|
- err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.status = 1 ").Scan(&order).Error
|
|
527
|
+ err = db.Group("s.patient_id,s.mode_id").Select("s.mode_id,s.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("join xt_patients as p on p.id = o.patient_id").Where("s.status = 1 ").Scan(&order).Error
|
530
|
528
|
return order, err
|
531
|
529
|
}
|
532
|
530
|
|
533
|
531
|
func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int64, orgid int64) (order []*models.BloodDialysisOrder, total int64, err error) {
|
534
|
532
|
|
535
|
533
|
db := XTReadDB().Table("xt_dialysis_order as o").Where("o.status = 1")
|
536
|
|
- if orgid > 0 {
|
537
|
|
- db = db.Where("o.user_org_id = ?", orgid)
|
538
|
|
- }
|
|
534
|
+ db = db.Where("o.user_org_id = ?", orgid)
|
539
|
535
|
if startime > 0 {
|
540
|
536
|
db = db.Where("o.dialysis_date>=?", startime)
|
541
|
537
|
}
|
|
@@ -543,7 +539,7 @@ func GetDialysisPatientList(startime int64, endtime int64, page int64, limit int
|
543
|
539
|
db = db.Where("o.dialysis_date<=?", endtime)
|
544
|
540
|
}
|
545
|
541
|
offset := (page - 1) * limit
|
546
|
|
- err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("left join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0").Joins("left join xt_patients as p on p.id = o.patient_id").Where("s.status =1 ").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
|
|
542
|
+ err = db.Group("s.patient_id").Select("s.mode_id,o.patient_id,p.name,p.id_card_no,p.dialysis_no,p.total_dialysis,p.user_sys_before_count").Joins("join xt_dialysis_prescription as s on s.patient_id = o.patient_id AND s.record_date = o.dialysis_date AND s.mode_id > 0 AND s.status =1").Joins("join xt_patients as p on p.id = o.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&order).Error
|
547
|
543
|
return order, total, err
|
548
|
544
|
}
|
549
|
545
|
|
|
@@ -644,9 +640,9 @@ func GetTreatList(orgid int64, startime int64, endtime int64, lapseto int64) (tt
|
644
|
640
|
if endtime > 0 {
|
645
|
641
|
db = db.Where("o.dialysis_date<=?", endtime)
|
646
|
642
|
}
|
647
|
|
- if lapseto == 0 {
|
648
|
|
- db = db.Where("p.lapseto = 1 or p.lapseto = 2")
|
649
|
|
- }
|
|
643
|
+ //if lapseto == 0 {
|
|
644
|
+ // db = db.Where("p.lapseto = 1 or p.lapseto = 2")
|
|
645
|
+ //}
|
650
|
646
|
if lapseto > 0 {
|
651
|
647
|
db = db.Where("p.lapseto = ?", lapseto)
|
652
|
648
|
}
|
|
@@ -659,7 +655,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
|
659
|
655
|
sql := "s.mode_id,from_unixtime(o.dialysis_date, '%Y%m%d') as date, count(o.dialysis_date) as number"
|
660
|
656
|
datesql := " o.dialysis_date as date"
|
661
|
657
|
group := "from_unixtime(o.dialysis_date, '%Y%m%d')"
|
662
|
|
- db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id AND s.mode_id > 0").Where("s.record_date = o.dialysis_date and s.status =1")
|
|
658
|
+ db = db.Table(" xt_dialysis_order AS o").Joins("join xt_dialysis_prescription as s on o.patient_id = s.patient_id AND o.dialysis_date = s.record_date AND s.mode_id > 0")
|
663
|
659
|
if orgID > 0 {
|
664
|
660
|
db = db.Where("o.user_org_id = ?", orgID)
|
665
|
661
|
}
|
|
@@ -674,7 +670,7 @@ func GetStatistics(orgID int64, startime int64, endtime int64, modeID int64) (dt
|
674
|
670
|
}
|
675
|
671
|
db = db.Where("o.status=1")
|
676
|
672
|
|
677
|
|
- err = db.Select("s.mode_id, count(s.mode_id) as number").Group("s.mode_id").Order("s.mode_id asc").Find(&ttd).Error
|
|
673
|
+ err = db.Select("s.mode_id, count(s.mode_id) as number").Order("s.mode_id asc").Find(&ttd).Error
|
678
|
674
|
if err != nil {
|
679
|
675
|
return
|
680
|
676
|
}
|
|
@@ -871,12 +867,6 @@ func GetPatientListInfo(orgid int64, startime int64, endtime int64, limit int64,
|
871
|
867
|
func GetPatientDetailCheck(id int64, orgid int64, startime int64, endtime int64) (projectCounts []*models.PatientInspectionProjectCount, err error) {
|
872
|
868
|
|
873
|
869
|
db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
|
874
|
|
- table := XTReadDB().Table("xt_inspection_reference as r")
|
875
|
|
- fmt.Println(table)
|
876
|
|
- d := XTReadDB().Table("xt_check_configuration as t").Where("t.status = 1")
|
877
|
|
- pa := XTReadDB().Table("xt_patients as s")
|
878
|
|
- fmt.Println(pa)
|
879
|
|
- fmt.Println(d)
|
880
|
870
|
if id > 0 {
|
881
|
871
|
db = db.Where("s.id = ?", id)
|
882
|
872
|
}
|
|
@@ -983,15 +973,10 @@ func GetFirstQuarter(orgid int64, startime int64, endtime int64) (inspection []*
|
983
|
973
|
return inspection, err
|
984
|
974
|
}
|
985
|
975
|
|
986
|
|
-func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
|
|
976
|
+func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
|
987
|
977
|
fmt.Println(lapseto)
|
|
978
|
+ fmt.Println(origin)
|
988
|
979
|
db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
|
989
|
|
- table := XTReadDB().Table("xt_inspection_reference as r")
|
990
|
|
- fmt.Println(table)
|
991
|
|
- //d := XTReadDB().Table("xt_patients as s")
|
992
|
|
- //fmt.Println(d)
|
993
|
|
- q := XTReadDB().Table("x.xt_quality_control_standard as q")
|
994
|
|
- fmt.Println(q)
|
995
|
980
|
if orgid > 0 {
|
996
|
981
|
db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and r.range_type = 1 and q.user_org_id = ? and q.is_status = 1", orgid, orgid)
|
997
|
982
|
}
|
|
@@ -1001,23 +986,21 @@ func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto in
|
1001
|
986
|
if endtime > 0 {
|
1002
|
987
|
db = db.Where("x.inspect_date <=?", endtime)
|
1003
|
988
|
}
|
1004
|
|
- //if lapseto == 0 {
|
1005
|
|
- // db = db.Where("s.lapseto = 1 or s.lapseto = 2")
|
1006
|
|
- //}
|
1007
|
|
- //if lapseto > 0 {
|
1008
|
|
- // db = db.Where("s.lapseto = ?", lapseto)
|
1009
|
|
- //}
|
|
989
|
+ if lapseto > 0 {
|
|
990
|
+ fmt.Println("11111")
|
|
991
|
+ db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.lapseto = ?", lapseto)
|
|
992
|
+ }
|
|
993
|
+ if origin > 0 {
|
|
994
|
+ fmt.Println("22222")
|
|
995
|
+
|
|
996
|
+ db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.source = ?", origin)
|
|
997
|
+ }
|
1010
|
998
|
err = db.Group("x.item_id").Select("sum(case when x.inspect_date >=? and x.inspect_date<=? then 1 else 0 end) as total,sum(case when x.inspect_value+0>=q.min_range+0 and x.inspect_value +0 <= q.large_range+0 and x.inspect_date >=? and x.inspect_date <=? then 1 else 0 end) as count,x.item_id,q.sort", startime, endtime, startime, endtime).Joins("left join xt_inspection_reference as r on ( r.item_id = x.item_id AND r.org_id > 0) OR ( x.item_id = r.id AND r.org_id = 0 ) ").Joins("left join xt_quality_control_standard as q on q.inspection_minor = x.item_id").Scan(&inspection).Error
|
1011
|
999
|
return inspection, err
|
1012
|
1000
|
}
|
1013
|
1001
|
|
1014
|
|
-func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto int64) (inspection []*models.VmPatientInspectionTwo, err error) {
|
1015
|
|
- fmt.Println(lapseto)
|
|
1002
|
+func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
|
1016
|
1003
|
db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
|
1017
|
|
- table := XTReadDB().Table("xt_inspection_reference as r")
|
1018
|
|
- fmt.Println(table)
|
1019
|
|
- //d := XTReadDB().Table("xt_patients as s")
|
1020
|
|
- //fmt.Println(d)
|
1021
|
1004
|
q := XTReadDB().Table("x.xt_quality_control_standard as q")
|
1022
|
1005
|
fmt.Println(q)
|
1023
|
1006
|
if orgid > 0 {
|
|
@@ -1029,6 +1012,13 @@ func GetQuarterTotalCountTwo(orgid int64, startime int64, endtime int64, lapseto
|
1029
|
1012
|
if endtime > 0 {
|
1030
|
1013
|
db = db.Where("x.inspect_date <=?", endtime)
|
1031
|
1014
|
}
|
|
1015
|
+
|
|
1016
|
+ if lapseto > 0 {
|
|
1017
|
+ db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.lapseto = ?", lapseto)
|
|
1018
|
+ }
|
|
1019
|
+ if origin > 0 {
|
|
1020
|
+ db = db.Joins("join xt_patients as p On p.id = x.patient_id AND p.source = ?", origin)
|
|
1021
|
+ }
|
1032
|
1022
|
//if lapseto == 0 {
|
1033
|
1023
|
// db = db.Where("s.lapseto = 1 or s.lapseto = 2")
|
1034
|
1024
|
//}
|
|
@@ -2858,7 +2848,20 @@ func GetSystolicBloodPressure(orgid int64, startime int64, endtime int64) (recor
|
2858
|
2848
|
return record, total, err
|
2859
|
2849
|
}
|
2860
|
2850
|
|
2861
|
|
-func GetStandSystolicBloodPressure(orgid int64, startime int64, endtime int64) (record []*models.XTMonitoringRecord, total int64, err error) {
|
|
2851
|
+func GetSystolicBloodPressureTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.VmMonitoringRecord, total int64, err error) {
|
|
2852
|
+
|
|
2853
|
+ db := XTReadDB().Table("xt_monitoring_record as x")
|
|
2854
|
+ if lapseto > 0 {
|
|
2855
|
+ db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.lapseto = ?", lapseto)
|
|
2856
|
+ }
|
|
2857
|
+ if origin > 0 {
|
|
2858
|
+ db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.source = ?", origin)
|
|
2859
|
+ }
|
|
2860
|
+ err = db.Select("x.id,x.systolic_blood_pressure").Where("x.user_org_id = ? and x.monitoring_date >=? and x.monitoring_date<=? and x.status = 1 and x.systolic_blood_pressure <> 0", orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
|
|
2861
|
+ return record, total, err
|
|
2862
|
+}
|
|
2863
|
+
|
|
2864
|
+func GetStandSystolicBloodPressure(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.XTMonitoringRecord, total int64, err error) {
|
2862
|
2865
|
|
2863
|
2866
|
db := XTReadDB().Table("xt_monitoring_record as x").Where("x.status = 1")
|
2864
|
2867
|
err = db.Select("x.id,s.sort").Joins("left join xt_quality_control_standard as s on s.user_org_id = x.user_org_id").Where("s.status = 1 and s.is_status = 0 and s.user_org_id = ? and x.user_org_id =? and x.monitoring_date>=? and x.monitoring_date <=? and s.inspection_minor = -1 and s.inspection_major = 0 and x.systolic_blood_pressure <> 0 and x.systolic_blood_pressure +0 >= s.min_range +0 and x.systolic_blood_pressure +0 <= s.large_range +0", orgid, orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
|
|
@@ -2872,6 +2875,18 @@ func GetDiastolicBloodPressure(orgid int64, startime int64, endtime int64) (reco
|
2872
|
2875
|
return record, total, err
|
2873
|
2876
|
}
|
2874
|
2877
|
|
|
2878
|
+func GetDiastolicBloodPressureTwo(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (record []*models.VmMonitoringRecord, total int64, err error) {
|
|
2879
|
+ db := XTReadDB().Table("xt_monitoring_record as x")
|
|
2880
|
+ if lapseto > 0 {
|
|
2881
|
+ db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.lapseto = ?", lapseto)
|
|
2882
|
+ }
|
|
2883
|
+ if origin > 0 {
|
|
2884
|
+ db = db.Joins("join xt_patients as p on p.id = x.patient_id AND p.source = ?", origin)
|
|
2885
|
+ }
|
|
2886
|
+ err = db.Select("x.id,x.diastolic_blood_pressure").Where("x.user_org_id = ? and x.monitoring_date >=? and x.monitoring_date<=? and x.status = 1 and x.diastolic_blood_pressure <> 0", orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
|
|
2887
|
+ return record, total, err
|
|
2888
|
+}
|
|
2889
|
+
|
2875
|
2890
|
func GetDiastolicStandPressure(orgid int64, startime int64, endtime int64) (record []*models.XTMonitoringRecord, total int64, err error) {
|
2876
|
2891
|
db := XTReadDB().Table("xt_monitoring_record as x").Where("x.status = 1")
|
2877
|
2892
|
err = db.Select("x.id,s.sort").Joins("left join xt_quality_control_standard as s on s.user_org_id = x.user_org_id").Where("s.status = 1 and s.is_status = 0 and s.user_org_id = ? and x.user_org_id =? and x.monitoring_date>=? and x.monitoring_date <=? and s.inspection_minor = -2 and s.inspection_major = 0 and x.diastolic_blood_pressure <> 0 and x.diastolic_blood_pressure +0 >= s.min_range +0 and x.diastolic_blood_pressure +0 <= s.large_range +0", orgid, orgid, startime, endtime).Group("x.monitoring_date,x.patient_id").Count(&total).Scan(&record).Error
|
|
@@ -3526,3 +3541,41 @@ func GetCountRollout(orgid int64, startime int64, endtime int64, lapsetotype int
|
3526
|
3541
|
}
|
3527
|
3542
|
return lapseto, err
|
3528
|
3543
|
}
|
|
3544
|
+
|
|
3545
|
+func GetCheckExaminePercent(start_time int64, end_time int64, org_id int64, name_type int64) (total int64) {
|
|
3546
|
+
|
|
3547
|
+ switch name_type {
|
|
3548
|
+ case 1:
|
|
3549
|
+ key := "%" + "血常规" + "%"
|
|
3550
|
+ readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND (item_name Like ? Or project_name Like ?)", start_time, end_time, org_id, key).Group("patient_id").Count(&total)
|
|
3551
|
+
|
|
3552
|
+ break
|
|
3553
|
+ case 2:
|
|
3554
|
+ //key := "%" + "肝功能" + "%"
|
|
3555
|
+ //key1 := "%" + "肾功能" + "%"
|
|
3556
|
+ //key2 := "%" + "电解质" + "%"
|
|
3557
|
+ //key3 := "%" + "血脂" + "%"
|
|
3558
|
+ //readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND ((item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?))", start_time, end_time, org_id, key, key, key1, key1, key2, key2, key3, key3).Group("patient_id").Count(&total)
|
|
3559
|
+
|
|
3560
|
+ break
|
|
3561
|
+ case 3:
|
|
3562
|
+ //key := "%" + "肝功能" + "%"
|
|
3563
|
+ //readDb.Model(&models.Inspection{}).Where("inspect_date >= ? AND inspect_date <= ? AND user_org_id = ? AND status = 1 AND ((item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?) Or (item_name Like ? Or project_name Like ?))", start_time, end_time, org_id, key, key, key1, key1, key2, key2, key3, key3).Group("patient_id").Count(&total)
|
|
3564
|
+
|
|
3565
|
+ break
|
|
3566
|
+ case 4:
|
|
3567
|
+ break
|
|
3568
|
+ case 5:
|
|
3569
|
+ break
|
|
3570
|
+ case 6:
|
|
3571
|
+ break
|
|
3572
|
+
|
|
3573
|
+ }
|
|
3574
|
+
|
|
3575
|
+ return
|
|
3576
|
+}
|
|
3577
|
+
|
|
3578
|
+func GetAllPatientCount(orgid int64) (total int64, err error) {
|
|
3579
|
+ err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Count(&total).Error
|
|
3580
|
+ return
|
|
3581
|
+}
|