|
@@ -543,10 +543,10 @@ func GetAnticoagulantData(start_time int64, end_time int64, org_id int64) (map[s
|
543
|
543
|
Count int
|
544
|
544
|
}
|
545
|
545
|
|
546
|
|
- err := XTReadDB().Model(&models.DialysisPrescription{}).
|
547
|
|
- Select("anticoagulant, COUNT(*) as count").
|
548
|
|
- Where("status = 1 and record_date >= ? and record_date <= ? and user_org_id = ?", start_time, end_time, org_id).
|
549
|
|
- Group("anticoagulant").
|
|
546
|
+ err := XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").
|
|
547
|
+ Select("xt_dialysis_prescription.anticoagulant, COUNT(*) as count").
|
|
548
|
+ Where("xt_dialysis_prescription.status = 1 and xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ? and xt_dialysis_prescription.user_org_id = ?", start_time, end_time, org_id).
|
|
549
|
+ Group("xt_dialysis_prescription.anticoagulant").
|
550
|
550
|
Scan(&results).Error
|
551
|
551
|
if err != nil {
|
552
|
552
|
return nil, err
|
|
@@ -564,8 +564,8 @@ func GetAnticoagulantData(start_time int64, end_time int64, org_id int64) (map[s
|
564
|
564
|
return anticoagulantData, nil
|
565
|
565
|
}
|
566
|
566
|
func GetAnticoagulantTotal(start_time int64, end_time int64, org_id int64) (total int64, err error) {
|
567
|
|
- err = XTReadDB().Model(&models.DialysisPrescription{}).
|
568
|
|
- Where("record_date >= ? and record_date <= ? and user_org_id = ? and status = 1", start_time, end_time, org_id).
|
|
567
|
+ err = XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").
|
|
568
|
+ Where("xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ? and xt_dialysis_prescription.user_org_id = ? and xt_dialysis_prescription.status = 1", start_time, end_time, org_id).
|
569
|
569
|
Count(&total).Error
|
570
|
570
|
|
571
|
571
|
return
|
|
@@ -603,18 +603,18 @@ type DialyzerResult struct {
|
603
|
603
|
|
604
|
604
|
func GetDialyzerData(start_time int64, end_time int64, org_id int64) (dr []DialyzerResult, err error) {
|
605
|
605
|
err = XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").
|
606
|
|
- Select("dialysis_dialyszers as dialyzer, COUNT(*) as count").
|
607
|
|
- Where("record_date >= ? and record_date <= ? and user_org_id = ? and status = 1", start_time, end_time, org_id).
|
608
|
|
- Group("dialysis_dialyszers").
|
|
606
|
+ Select("xt_dialysis_prescription.dialysis_dialyszers as dialyzer, COUNT(*) as count").
|
|
607
|
+ Where("xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ? and xt_dialysis_prescription.user_org_id = ? and xt_dialysis_prescription.status = 1", start_time, end_time, org_id).
|
|
608
|
+ Group("xt_dialysis_prescription.dialysis_dialyszers").
|
609
|
609
|
Scan(&dr).Error
|
610
|
610
|
return
|
611
|
611
|
}
|
612
|
612
|
|
613
|
613
|
func GetDialysisIrrigationData(start_time int64, end_time int64, org_id int64) (dr []DialyzerResult, err error) {
|
614
|
614
|
err = XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").
|
615
|
|
- Select("dialysis_irrigation as dialysis_irrigation, COUNT(*) as count").
|
616
|
|
- Where("record_date >= ? and record_date <= ? and user_org_id = ? and status = 1", start_time, end_time, org_id).
|
617
|
|
- Group("dialysis_irrigation").
|
|
615
|
+ Select("xt_dialysis_prescription.dialysis_irrigation as dialysis_irrigation, COUNT(*) as count").
|
|
616
|
+ Where("xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ? and xt_dialysis_prescription.user_org_id = ? and xt_dialysis_prescription.status = 1", start_time, end_time, org_id).
|
|
617
|
+ Group("xt_dialysis_prescription.dialysis_irrigation").
|
618
|
618
|
Scan(&dr).Error
|
619
|
619
|
return
|
620
|
620
|
}
|
|
@@ -630,21 +630,21 @@ func GetIrrigationData(start_time int64, end_time int64, org_id int64) (dr []Dia
|
630
|
630
|
|
631
|
631
|
func GetDialyzerTotal(start_time int64, end_time int64, org_id int64) (total int64, err error) {
|
632
|
632
|
err = XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").
|
633
|
|
- Where("status = 1 and record_date >= ? and record_date <= ? and user_org_id = ?", start_time, end_time, org_id).
|
|
633
|
+ Where("xt_dialysis_prescription.status = 1 and xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ? and xt_dialysis_prescription.user_org_id = ?", start_time, end_time, org_id).
|
634
|
634
|
Count(&total).Error
|
635
|
635
|
return
|
636
|
636
|
}
|
637
|
637
|
|
638
|
638
|
func GetPrescriptionByAnticoagulant(page int64, limit int64, orgid int64, anticoagulant int64, start_time int64, end_time int64) (solution []*models.DialysisPrescription, total int64, err error) {
|
639
|
639
|
|
640
|
|
- db := XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").Preload("QCPatients", "status = 1 and user_org_id = ?", orgid).Where("status = 1")
|
|
640
|
+ db := XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and xt_dialysis_order.status = 1").Preload("QCPatients", "xt_patients.status = 1 and xt_patients.user_org_id = ?", orgid).Where("xt_dialysis_prescription.status = 1")
|
641
|
641
|
if anticoagulant > 0 {
|
642
|
|
- db = db.Where("anticoagulant = ?", anticoagulant)
|
|
642
|
+ db = db.Where("xt_dialysis_prescription.anticoagulant = ?", anticoagulant)
|
643
|
643
|
}
|
644
|
644
|
if orgid > 0 {
|
645
|
|
- db = db.Where("user_org_id = ?", orgid)
|
|
645
|
+ db = db.Where("xt_dialysis_prescription.user_org_id = ?", orgid)
|
646
|
646
|
}
|
647
|
|
- db = db.Where("record_date >= ? and record_date <= ?", start_time, end_time)
|
|
647
|
+ db = db.Where("xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ?", start_time, end_time)
|
648
|
648
|
|
649
|
649
|
offset := (page - 1) * limit
|
650
|
650
|
|
|
@@ -654,14 +654,14 @@ func GetPrescriptionByAnticoagulant(page int64, limit int64, orgid int64, antico
|
654
|
654
|
|
655
|
655
|
func GetPrescriptionByDialyzer(page int64, limit int64, orgid int64, dialyzer string, start_time int64, end_time int64) (solution []*models.DialysisPrescription, total int64, err error) {
|
656
|
656
|
|
657
|
|
- db := XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").Preload("QCPatients", "status = 1 and user_org_id = ?", orgid).Where("status = 1")
|
|
657
|
+ db := XTReadDB().Model(&models.DialysisPrescription{}).Joins("join xt_dialysis_order oo on oo.patient_id = xt_dialysis_prescription.patient_id and oo.dialysis_date = xt_dialysis_prescription.record_date and oo.status = 1").Preload("QCPatients", "xt_patients.status = 1 and xt_patients.user_org_id = ?", orgid).Where("xt_dialysis_prescription.status = 1")
|
658
|
658
|
if len(dialyzer) > 0 {
|
659
|
|
- db = db.Where("dialysis_dialyszers = ? or dialysis_irrigation = ?", dialyzer, dialyzer)
|
|
659
|
+ db = db.Where("xt_dialysis_prescription.dialysis_dialyszers = ? or xt_dialysis_prescription.dialysis_irrigation = ?", dialyzer, dialyzer)
|
660
|
660
|
}
|
661
|
661
|
if orgid > 0 {
|
662
|
|
- db = db.Where("user_org_id = ?", orgid)
|
|
662
|
+ db = db.Where("xt_dialysis_prescription.user_org_id = ?", orgid)
|
663
|
663
|
}
|
664
|
|
- db = db.Where("record_date >= ? and record_date <= ? and status = 1", start_time, end_time)
|
|
664
|
+ db = db.Where("xt_dialysis_prescription.record_date >= ? and xt_dialysis_prescription.record_date <= ? and xt_dialysis_prescription.status = 1", start_time, end_time)
|
665
|
665
|
|
666
|
666
|
offset := (page - 1) * limit
|
667
|
667
|
|