|
@@ -1965,28 +1965,28 @@ type InspectionCount struct {
|
1965
|
1965
|
Count int64
|
1966
|
1966
|
}
|
1967
|
1967
|
|
1968
|
|
-func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
|
|
1968
|
+func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
|
1969
|
1969
|
var count []*InspectionCount
|
1970
|
|
- 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
|
|
1970
|
+ 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
|
1971
|
1971
|
for _, items := range count {
|
1972
|
1972
|
total = total + items.Count
|
1973
|
1973
|
}
|
1974
|
1974
|
return total, err2
|
1975
|
1975
|
}
|
1976
|
|
-func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64) (total int64, err error) {
|
|
1976
|
+func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
|
1977
|
1977
|
var count []*InspectionCount
|
1978
|
|
- 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
|
|
1978
|
+ 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
|
1979
|
1979
|
for _, items := range count {
|
1980
|
1980
|
total = total + items.Count
|
1981
|
1981
|
}
|
1982
|
1982
|
return total, err2
|
1983
|
1983
|
}
|
1984
|
|
-func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
|
1985
|
|
- 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
|
|
1984
|
+func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
|
|
1985
|
+ 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
|
1986
|
1986
|
return total, err
|
1987
|
1987
|
}
|
1988
|
1988
|
|
1989
|
|
-func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
|
|
1989
|
+func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patient_id int64, item_name string) (inspections []*models.Inspection, err error) {
|
1990
|
1990
|
db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
|
1991
|
1991
|
if startime > 0 {
|
1992
|
1992
|
db = db.Where("x.inspect_date >= ?", startime)
|
|
@@ -1998,11 +1998,9 @@ func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projec
|
1998
|
1998
|
if orgid > 0 {
|
1999
|
1999
|
db = db.Where("x.org_id = ?", orgid)
|
2000
|
2000
|
}
|
2001
|
|
- if projectid > 0 {
|
2002
|
|
- db = db.Where("x.reference_project_id = ?", projectid)
|
2003
|
|
- }
|
2004
|
|
- if item_id > 0 {
|
2005
|
|
- db = db.Where("x.reference_item_id = ?", item_id)
|
|
2001
|
+
|
|
2002
|
+ if len(item_name) > 0 {
|
|
2003
|
+ db = db.Where("x.item_name = ?", item_name)
|
2006
|
2004
|
}
|
2007
|
2005
|
if patient_id > 0 {
|
2008
|
2006
|
db = db.Where("x.patient_id = ?", patient_id)
|
|
@@ -2074,7 +2072,7 @@ func GetPatientURRByID(startime int64, endtime int64, orgid int64, patient_id in
|
2074
|
2072
|
return inspections, err
|
2075
|
2073
|
}
|
2076
|
2074
|
|
2077
|
|
-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) {
|
|
2075
|
+func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
2078
|
2076
|
db := XTReadDB().Table("xt_inspection as xti ")
|
2079
|
2077
|
if len(keyword) > 0 {
|
2080
|
2078
|
keyword = "%" + keyword + "%"
|
|
@@ -2082,10 +2080,10 @@ func GetNormalInspectionPatientList(startime int64, endtime int64, orgid int64,
|
2082
|
2080
|
} else {
|
2083
|
2081
|
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")
|
2084
|
2082
|
}
|
2085
|
|
- 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
|
|
2083
|
+ 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.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(&xti).Error
|
2086
|
2084
|
return xti, err2
|
2087
|
2085
|
}
|
2088
|
|
-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) {
|
|
2086
|
+func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
2089
|
2087
|
db := XTReadDB().Table("xt_inspection as xti ")
|
2090
|
2088
|
if len(keyword) > 0 {
|
2091
|
2089
|
keyword = "%" + keyword + "%"
|
|
@@ -2094,11 +2092,11 @@ func GetUnusualInspectionPatientList(startime int64, endtime int64, orgid int64,
|
2094
|
2092
|
|
2095
|
2093
|
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 ")
|
2096
|
2094
|
}
|
2097
|
|
- 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
|
|
2095
|
+ 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.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(&xti).Error
|
2098
|
2096
|
return xti, err2
|
2099
|
2097
|
}
|
2100
|
|
-func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient []*models.XtPatientsTen, err error) {
|
2101
|
|
- 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
|
|
2098
|
+func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int64, item_name string, keyword string) (patient []*models.XtPatientsTen, err error) {
|
|
2099
|
+ err = XTReadDB().Model(models.XtPatientsTen{}).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).Find(&patient).Error
|
2102
|
2100
|
return patient, err
|
2103
|
2101
|
}
|
2104
|
2102
|
|