|
@@ -1961,7 +1961,7 @@ type InspectionCount struct {
|
1961
|
1961
|
|
1962
|
1962
|
func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
|
1963
|
1963
|
var count []*InspectionCount
|
1964
|
|
- 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 WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&count).Error
|
|
1964
|
+ 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.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&count).Error
|
1965
|
1965
|
for _, items := range count {
|
1966
|
1966
|
total = total + items.Count
|
1967
|
1967
|
}
|
|
@@ -1969,7 +1969,7 @@ func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, pr
|
1969
|
1969
|
}
|
1970
|
1970
|
func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
|
1971
|
1971
|
var count []*InspectionCount
|
1972
|
|
- 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 WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&count).Error
|
|
1972
|
+ 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.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&count).Error
|
1973
|
1973
|
for _, items := range count {
|
1974
|
1974
|
total = total + items.Count
|
1975
|
1975
|
}
|
|
@@ -1977,12 +1977,12 @@ func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, p
|
1977
|
1977
|
}
|
1978
|
1978
|
|
1979
|
1979
|
func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
|
1980
|
|
- err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL", orgid).Count(&total).Error
|
|
1980
|
+ err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, 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
|
1981
|
1981
|
return total, err
|
1982
|
1982
|
}
|
1983
|
1983
|
|
1984
|
1984
|
func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
|
1985
|
|
- db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Where("x.status = 1")
|
|
1985
|
+ db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("xt_patient p On p.id = xt_inspection.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
|
1986
|
1986
|
if startime > 0 {
|
1987
|
1987
|
db = db.Where("x.inspect_date >= ?", startime)
|
1988
|
1988
|
}
|
|
@@ -2006,15 +2006,30 @@ func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projec
|
2006
|
2006
|
return inspections, err
|
2007
|
2007
|
}
|
2008
|
2008
|
|
2009
|
|
-func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, order_type int64, keyword string) (xti []*models.Inspection, err error) {
|
2010
|
|
- err2 := XTReadDB().Table("xt_inspection as xti ").Select("xti.patient_id as patient_id,xti.inspect_date as inspect_date,xti.inspect_value as value").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid FROM xt_inspection as x WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&xti).Error
|
|
2009
|
+func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2010
|
+ db := XTReadDB().Table("xt_inspection as xti ")
|
|
2011
|
+ if len(keyword) > 0 {
|
|
2012
|
+ keyword = "%" + keyword + "%"
|
|
2013
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1 and name like ?", keyword)
|
|
2014
|
+ } else {
|
|
2015
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1")
|
|
2016
|
+ }
|
|
2017
|
+ err2 := db.Joins("join (SELECT max(inspect_date) as ind, patient_id as pid FROM xt_inspection as x WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` < ? and xti.inspect_value > ? ) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, min_value).Scan(&xti).Error
|
2011
|
2018
|
return xti, err2
|
2012
|
2019
|
}
|
2013
|
|
-func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, order_type int64, keyword string) (xti []*models.Inspection, err error) {
|
2014
|
|
- err2 := XTReadDB().Table("xt_inspection as xti ").Select("xti.patient_id as patient_id,xti.inspect_date as inspect_date,xti.inspect_value as value").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid FROM xt_inspection as x WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&xti).Error
|
|
2020
|
+func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2021
|
+ db := XTReadDB().Table("xt_inspection as xti ")
|
|
2022
|
+ if len(keyword) > 0 {
|
|
2023
|
+ keyword = "%" + keyword + "%"
|
|
2024
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1 and name like ?", keyword)
|
|
2025
|
+ } else {
|
|
2026
|
+
|
|
2027
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.inspect_date,'%Y-%m-%d') as date,xti.inspect_value as inspect_value,pp.name as name, pp.dialysis_no as dialysis_no").Joins("join xt_patients pp On pp.id = xti.patient_id and pp.status = 1 and pp.lapseto = 1 ")
|
|
2028
|
+ }
|
|
2029
|
+ err2 := db.Joins("join (SELECT max(inspect_date) as ind, patient_id as pid FROM xt_inspection as x WHERE (x.status = 1) AND (x.org_id = ? and x.reference_project_id = ? and x.reference_item_id = ? 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.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ? and xti.reference_project_id = ? and xti.reference_item_id = ? and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, projectid, item_id, startime, endtime, orgid, projectid, item_id, startime, endtime, max_value, orgid, projectid, item_id, startime, endtime, min_value).Scan(&xti).Error
|
2015
|
2030
|
return xti, err2
|
2016
|
2031
|
}
|
2017
|
|
-func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient models.XtPatients, err error) {
|
2018
|
|
- err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL", orgid).Find(&patient).Error
|
|
2032
|
+func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient []*models.XtPatientsTen, err error) {
|
|
2033
|
+ err = XTReadDB().Model(models.XtPatientsTen{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.reference_project_id = ? and pd.reference_item_id = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, projectid, item_id, 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).Find(&patient).Error
|
2019
|
2034
|
return patient, err
|
2020
|
2035
|
}
|