|
@@ -573,3 +573,40 @@ func GetSearchPatientInfo(orgid int64, keywords string, startime int64, endtime
|
573
|
573
|
err = db.Select("count(distinct x.inspect_date) as count,x.patient_id,x.project_id,r.project_name,t.inspection_frequency").Joins("left join xt_check_configuration as t on t.inspection_major = x.project_id").Joins("left join xt_inspection_reference as r on r.project_id = x.project_id").Joins("left join xt_patients as p on p.id = x.patient_id").Group("project_id,patient_id").Scan(&projectCounts).Error
|
574
|
574
|
return
|
575
|
575
|
}
|
|
576
|
+
|
|
577
|
+func GetMajorInspectionByOrgid(orgid int64) (checkconfiguration []*models.CheckConfiguration, err error) {
|
|
578
|
+
|
|
579
|
+ db := XTReadDB().Table("xt_check_configuration as x").Where("x.status =1")
|
|
580
|
+ table := XTReadDB().Table("xt_inspection_reference ar r")
|
|
581
|
+ fmt.Println(table)
|
|
582
|
+ err = db.Group("x.inspection_major").Select("x.id,x.inspection_major,x.inspection_frequency,x.sort,x.user_org_id,r.project_name").Where("x.user_org_id = ?", orgid).Joins("left join xt_inspection_reference as r on r.project_id = x.inspection_major").Scan(&checkconfiguration).Error
|
|
583
|
+ return checkconfiguration, err
|
|
584
|
+}
|
|
585
|
+
|
|
586
|
+func GetDefaultByOrgId(orgid int64) (checkconfiguration []*models.CheckConfiguration, err error) {
|
|
587
|
+
|
|
588
|
+ db := XTReadDB().Table("xt_check_configuration as x").Where("x.status =1")
|
|
589
|
+ table := XTReadDB().Table("xt_inspection_reference ar r")
|
|
590
|
+ fmt.Println(table)
|
|
591
|
+ err = db.Group("x.inspection_major").Select("x.id,x.inspection_major,x.inspection_frequency,x.sort,x.user_org_id,r.project_name").Where("x.user_org_id = ?", orgid).Joins("left join xt_inspection_reference as r on r.project_id = x.inspection_major").Scan(&checkconfiguration).Error
|
|
592
|
+ return checkconfiguration, err
|
|
593
|
+}
|
|
594
|
+
|
|
595
|
+func GetPatientListData(orgid int64, startime int64, endtime int64, limit int64, page int64) (inspection []*models.PatientsInspection, total int64, err error) {
|
|
596
|
+
|
|
597
|
+ db := XTReadDB().Table("xt_inspection as x").Where("x.status = 1")
|
|
598
|
+ table := XTReadDB().Table("xt_patients as s")
|
|
599
|
+ fmt.Println("table", table)
|
|
600
|
+ if orgid > 0 {
|
|
601
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
602
|
+ }
|
|
603
|
+ if startime > 0 {
|
|
604
|
+ db = db.Where("x.inspect_date >= ?", startime)
|
|
605
|
+ }
|
|
606
|
+ if endtime > 0 {
|
|
607
|
+ db = db.Where("x.inspect_date <=?", endtime)
|
|
608
|
+ }
|
|
609
|
+ offset := (page - 1) * limit
|
|
610
|
+ err = db.Group("x.patient_id").Select("x.id,x.patient_id,x.project_id,x.project_name,s.name").Joins("left join xt_patients as s on s.id = x.patient_id").Count(&total).Offset(offset).Limit(limit).Scan(&inspection).Error
|
|
611
|
+ return inspection, total, err
|
|
612
|
+}
|