|
@@ -1964,20 +1964,15 @@ type InspectionCount struct {
|
1964
|
1964
|
}
|
1965
|
1965
|
|
1966
|
1966
|
func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
|
1967
|
|
- var count []*InspectionCount
|
|
1967
|
+ var count []*models.Inspection
|
1968
|
1968
|
err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1 WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ? and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid WHERE (xti.status = 1) AND (xti.org_id = ? and xti.item_name = ? and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
|
1969
|
|
- for _, items := range count {
|
1970
|
|
- total = total + items.Count
|
1971
|
|
- }
|
1972
|
|
- return total, err2
|
|
1969
|
+
|
|
1970
|
+ return int64(len(count)), err2
|
1973
|
1971
|
}
|
1974
|
1972
|
func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
|
1975
|
|
- var count []*InspectionCount
|
|
1973
|
+ var count []*models.Inspection
|
1976
|
1974
|
err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1 WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ? and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid WHERE (xti.status = 1 AND xti.org_id = ? and xti.item_name = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.item_name = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
|
1977
|
|
- for _, items := range count {
|
1978
|
|
- total = total + items.Count
|
1979
|
|
- }
|
1980
|
|
- return total, err2
|
|
1975
|
+ return int64(len(count)), err2
|
1981
|
1976
|
}
|
1982
|
1977
|
func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
|
1983
|
1978
|
err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Count(&total).Error
|