|
@@ -1975,7 +1975,6 @@ func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, p
|
1975
|
1975
|
}
|
1976
|
1976
|
return total, err2
|
1977
|
1977
|
}
|
1978
|
|
-
|
1979
|
1978
|
func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
|
1980
|
1979
|
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
|
1980
|
return total, err
|
|
@@ -2006,6 +2005,69 @@ func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, projec
|
2006
|
2005
|
return inspections, err
|
2007
|
2006
|
}
|
2008
|
2007
|
|
|
2008
|
+func GetPatientKTVORURRInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
|
|
2009
|
+ 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")
|
|
2010
|
+ if startime > 0 {
|
|
2011
|
+ db = db.Where("x.inspect_date >= ?", startime)
|
|
2012
|
+ }
|
|
2013
|
+ if endtime > 0 {
|
|
2014
|
+ db = db.Where("x.inspect_date<=?", endtime)
|
|
2015
|
+ }
|
|
2016
|
+
|
|
2017
|
+ if orgid > 0 {
|
|
2018
|
+ db = db.Where("x.org_id = ?", orgid)
|
|
2019
|
+ }
|
|
2020
|
+ if projectid > 0 {
|
|
2021
|
+ db = db.Where("x.project_id = ?", projectid)
|
|
2022
|
+ }
|
|
2023
|
+ if item_id > 0 {
|
|
2024
|
+ db = db.Where("x.item_id = ?", item_id)
|
|
2025
|
+ }
|
|
2026
|
+ if patient_id > 0 {
|
|
2027
|
+ db = db.Where("x.patient_id = ?", patient_id)
|
|
2028
|
+ }
|
|
2029
|
+ err = db.Find(&inspections).Error
|
|
2030
|
+ return inspections, err
|
|
2031
|
+}
|
|
2032
|
+
|
|
2033
|
+func GetPatientKTVByID(startime int64, endtime int64, orgid int64, patient_id int64) (inspections []*models.Inspection, err error) {
|
|
2034
|
+ db := XTReadDB().Table("xt_assessment_after_dislysis as x").Select("patient_id as patient_id,assessment_date as inspect_date,ktv as 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")
|
|
2035
|
+ if startime > 0 {
|
|
2036
|
+ db = db.Where("x.assessment_date >= ?", startime)
|
|
2037
|
+ }
|
|
2038
|
+ if endtime > 0 {
|
|
2039
|
+ db = db.Where("x.assessment_date<=?", endtime)
|
|
2040
|
+ }
|
|
2041
|
+
|
|
2042
|
+ if orgid > 0 {
|
|
2043
|
+ db = db.Where("x.user_org_id = ?", orgid)
|
|
2044
|
+ }
|
|
2045
|
+ if patient_id > 0 {
|
|
2046
|
+ db = db.Where("x.patient_id = ?", patient_id)
|
|
2047
|
+ }
|
|
2048
|
+ err = db.Find(&inspections).Error
|
|
2049
|
+ return inspections, err
|
|
2050
|
+}
|
|
2051
|
+
|
|
2052
|
+func GetPatientURRByID(startime int64, endtime int64, orgid int64, patient_id int64) (inspections []*models.Inspection, err error) {
|
|
2053
|
+ db := XTReadDB().Table("xt_assessment_after_dislysis as x").Select("patient_id as patient_id,assessment_date as inspect_date,urr as 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")
|
|
2054
|
+ if startime > 0 {
|
|
2055
|
+ db = db.Where("x.assessment_date >= ?", startime)
|
|
2056
|
+ }
|
|
2057
|
+ if endtime > 0 {
|
|
2058
|
+ db = db.Where("x.assessment_date<=?", endtime)
|
|
2059
|
+ }
|
|
2060
|
+
|
|
2061
|
+ if orgid > 0 {
|
|
2062
|
+ db = db.Where("x.user_org_id = ?", orgid)
|
|
2063
|
+ }
|
|
2064
|
+ if patient_id > 0 {
|
|
2065
|
+ db = db.Where("x.patient_id = ?", patient_id)
|
|
2066
|
+ }
|
|
2067
|
+ err = db.Find(&inspections).Error
|
|
2068
|
+ return inspections, err
|
|
2069
|
+}
|
|
2070
|
+
|
2009
|
2071
|
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
|
2072
|
db := XTReadDB().Table("xt_inspection as xti ")
|
2011
|
2073
|
if len(keyword) > 0 {
|
|
@@ -2033,3 +2095,168 @@ func GetPatientNotInspectionPatientList(startime int64, endtime int64, orgid int
|
2033
|
2095
|
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
|
2034
|
2096
|
return patient, err
|
2035
|
2097
|
}
|
|
2098
|
+
|
|
2099
|
+func GetUnusualKTVPatientList(startime int64, endtime int64, orgid int64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2100
|
+ db := XTReadDB().Table("xt_assessment_after_dislysis as xti ")
|
|
2101
|
+ if len(keyword) > 0 {
|
|
2102
|
+ keyword = "%" + keyword + "%"
|
|
2103
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,xti.ktv 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)
|
|
2104
|
+ } else {
|
|
2105
|
+
|
|
2106
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,xti.ktv 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 ")
|
|
2107
|
+ }
|
|
2108
|
+ err2 := db.Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis as x WHERE (x.status = 1) AND (x.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.ktv <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1 AND xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date <= ? and xti.ktv +'0' < ?) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&xti).Error
|
|
2109
|
+ return xti, err2
|
|
2110
|
+}
|
|
2111
|
+
|
|
2112
|
+func GetUnusualKTVORURRInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2113
|
+ db := XTReadDB().Table("xt_inspection as xti ")
|
|
2114
|
+ if len(keyword) > 0 {
|
|
2115
|
+ keyword = "%" + keyword + "%"
|
|
2116
|
+ 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)
|
|
2117
|
+ } else {
|
|
2118
|
+
|
|
2119
|
+ 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 ")
|
|
2120
|
+ }
|
|
2121
|
+ 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.project_id = ? and x.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.project_id = ? and xti.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, min_value).Scan(&xti).Error
|
|
2122
|
+ return xti, err2
|
|
2123
|
+}
|
|
2124
|
+
|
|
2125
|
+func GetNormalKTVORURRInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, max_value float64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2126
|
+ db := XTReadDB().Table("xt_inspection as xti ")
|
|
2127
|
+ if len(keyword) > 0 {
|
|
2128
|
+ keyword = "%" + keyword + "%"
|
|
2129
|
+ 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)
|
|
2130
|
+ } else {
|
|
2131
|
+ 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")
|
|
2132
|
+ }
|
|
2133
|
+ 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.project_id = ? and x.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.project_id = ? and xti.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, min_value).Scan(&xti).Error
|
|
2134
|
+ return xti, err2
|
|
2135
|
+}
|
|
2136
|
+
|
|
2137
|
+func GetPatientNotKTVORURRInspectionPatientList(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, keyword string) (patient []*models.XtPatientsTen, err error) {
|
|
2138
|
+ err = XTReadDB().Model(models.XtPatientsTen{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.project_id = ? and pd.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
|
|
2139
|
+ return patient, err
|
|
2140
|
+}
|
|
2141
|
+
|
|
2142
|
+func GetNormalKTVPatientList(startime int64, endtime int64, orgid int64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2143
|
+ db := XTReadDB().Table("xt_assessment_after_dislysis as xti ")
|
|
2144
|
+ if len(keyword) > 0 {
|
|
2145
|
+ keyword = "%" + keyword + "%"
|
|
2146
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,xti.ktv 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)
|
|
2147
|
+ } else {
|
|
2148
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,xti.ktv 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")
|
|
2149
|
+ }
|
|
2150
|
+ err2 := db.Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis as x WHERE (x.status = 1) AND (x.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.ktv <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1) AND (xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date<= ? and xti.ktv + '0' >= ? ) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&xti).Error
|
|
2151
|
+ return xti, err2
|
|
2152
|
+}
|
|
2153
|
+func GetPatientNotKTVPatientList(startime int64, endtime int64, orgid int64) (patient []*models.XtPatientsTen, err error) {
|
|
2154
|
+ err = XTReadDB().Model(models.XtPatientsTen{}).Joins("LEFT JOIN xt_assessment_after_dislysis pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.ktv <> '' and pd.assessment_date >= ? and pd.assessment_date<=? ", orgid, 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
|
|
2155
|
+ return patient, err
|
|
2156
|
+}
|
|
2157
|
+
|
|
2158
|
+func GetNormalURRPatientList(startime int64, endtime int64, orgid int64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2159
|
+ db := XTReadDB().Table("xt_assessment_after_dislysis as xti ")
|
|
2160
|
+ if len(keyword) > 0 {
|
|
2161
|
+ keyword = "%" + keyword + "%"
|
|
2162
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,REPLACE(xti.urr, '%', '') + 0 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)
|
|
2163
|
+ } else {
|
|
2164
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,REPLACE(xti.urr, '%', '') + 0 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")
|
|
2165
|
+ }
|
|
2166
|
+ err2 := db.Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis as x WHERE (x.status = 1) AND (x.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.urr <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1) AND (xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date<= ? and REPLACE(xti.urr, '%', '') + 0 >= ? ) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&xti).Error
|
|
2167
|
+ return xti, err2
|
|
2168
|
+}
|
|
2169
|
+func GetUnusualURRPatientList(startime int64, endtime int64, orgid int64, min_value float64, keyword string) (xti []*models.Inspection, err error) {
|
|
2170
|
+ db := XTReadDB().Table("xt_assessment_after_dislysis as xti ")
|
|
2171
|
+ if len(keyword) > 0 {
|
|
2172
|
+ keyword = "%" + keyword + "%"
|
|
2173
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,REPLACE(xti.urr, '%', '') + 0 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)
|
|
2174
|
+ } else {
|
|
2175
|
+
|
|
2176
|
+ db = db.Select("xti.patient_id as patient_id,FROM_UNIXTIME(xti.assessment_date,'%Y-%m-%d') as date,REPLACE(xti.urr, '%', '') + 0 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 ")
|
|
2177
|
+ }
|
|
2178
|
+ err2 := db.Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis as x WHERE (x.status = 1) AND (x.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ?) group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1 AND xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date <= ? and REPLACE(xti.urr, '%', '') + 0 < ?) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&xti).Error
|
|
2179
|
+ return xti, err2
|
|
2180
|
+}
|
|
2181
|
+func GetPatientNotURRPatientList(startime int64, endtime int64, orgid int64) (patient []*models.XtPatientsTen, err error) {
|
|
2182
|
+ err = XTReadDB().Model(models.XtPatientsTen{}).Joins("LEFT JOIN xt_assessment_after_dislysis pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and xti.urr <> '' and pd.assessment_date >= ? and pd.assessment_date<=? ", orgid, 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
|
|
2183
|
+ return patient, err
|
|
2184
|
+}
|
|
2185
|
+
|
|
2186
|
+func GetNormalKTVTotalByID(startime int64, endtime int64, orgid int64, min_value float64) (total int64, err error) {
|
|
2187
|
+ var count []*InspectionCount
|
|
2188
|
+ err2 := XTReadDB().Table("xt_assessment_after_dislysis as xti").Select("count(*) as count").Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1 WHERE (x.status = 1) AND (x.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.ktv <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1) AND (xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date <= ? and xti.ktv + '0' >= ? ) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&count).Error
|
|
2189
|
+ for _, items := range count {
|
|
2190
|
+ total = total + items.Count
|
|
2191
|
+ }
|
|
2192
|
+ return total, err2
|
|
2193
|
+}
|
|
2194
|
+func GetUnusualKTVTotalByID(startime int64, endtime int64, orgid int64, min_value float64) (total int64, err error) {
|
|
2195
|
+ var count []*InspectionCount
|
|
2196
|
+ err2 := XTReadDB().Table("xt_assessment_after_dislysis as xti ").Select("count(*) as count").Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis 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.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.ktv <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1 AND xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date <= ? and xti.ktv + '0'< ?) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&count).Error
|
|
2197
|
+ for _, items := range count {
|
|
2198
|
+ total = total + items.Count
|
|
2199
|
+ }
|
|
2200
|
+ return total, err2
|
|
2201
|
+}
|
|
2202
|
+func GetPatientNotKTVTotal(startime int64, endtime int64, orgid int64) (total int64, err error) {
|
|
2203
|
+ err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_assessment_after_dislysis pd ON xt_patients.id = pd.patient_id and pd.user_org_id = ? and pd.assessment_date >= ? and pd.assessment_date<=? and pd.ktv <> ''", orgid, 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
|
|
2204
|
+ return total, err
|
|
2205
|
+}
|
|
2206
|
+
|
|
2207
|
+func GetNormalURRTotalByID(startime int64, endtime int64, orgid int64, min_value float64) (total int64, err error) {
|
|
2208
|
+ var count []*InspectionCount
|
|
2209
|
+ err2 := XTReadDB().Table("xt_assessment_after_dislysis as xti").Select("count(*) as count").Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1 WHERE (x.status = 1) AND (x.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.urr <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1) AND (xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date <= ? and REPLACE(xti.urr, '%', '') + 0 >= ? ) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&count).Error
|
|
2210
|
+ for _, items := range count {
|
|
2211
|
+ total = total + items.Count
|
|
2212
|
+ }
|
|
2213
|
+ return total, err2
|
|
2214
|
+}
|
|
2215
|
+func GetUnusualURRTotalByID(startime int64, endtime int64, orgid int64, min_value float64) (total int64, err error) {
|
|
2216
|
+ var count []*InspectionCount
|
|
2217
|
+ err2 := XTReadDB().Table("xt_assessment_after_dislysis as xti ").Select("count(*) as count").Joins("join (SELECT max(assessment_date) as ind, patient_id as pid FROM xt_assessment_after_dislysis 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.user_org_id = ? and x.assessment_date >= ? and x.assessment_date <= ? and x.urr <> '') group by patient_id) as ta on ta.ind = xti.`assessment_date` and xti.patient_id = ta.pid WHERE (xti.status = 1 AND xti.user_org_id = ? and xti.assessment_date >= ? and xti.assessment_date <= ? and REPLACE(xti.urr, '%', '')+ 0 < ?) Group by xti.patient_id", orgid, startime, endtime, orgid, startime, endtime, min_value).Scan(&count).Error
|
|
2218
|
+ for _, items := range count {
|
|
2219
|
+ total = total + items.Count
|
|
2220
|
+ }
|
|
2221
|
+ return total, err2
|
|
2222
|
+}
|
|
2223
|
+func GetPatientNotURRTotal(startime int64, endtime int64, orgid int64) (total int64, err error) {
|
|
2224
|
+ err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_assessment_after_dislysis pd ON xt_patients.id = pd.patient_id and pd.user_org_id = ? and pd.assessment_date >= ? and pd.assessment_date<=? and pd.urr <> ''", orgid, 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
|
|
2225
|
+ return total, err
|
|
2226
|
+}
|
|
2227
|
+
|
|
2228
|
+func GetNormalKTVORURRInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, min_value float64) (total int64, err error) {
|
|
2229
|
+ var count []*InspectionCount
|
|
2230
|
+ 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.project_id = ? and x.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.project_id = ? and xti.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, min_value).Scan(&count).Error
|
|
2231
|
+ for _, items := range count {
|
|
2232
|
+ total = total + items.Count
|
|
2233
|
+ }
|
|
2234
|
+ return total, err2
|
|
2235
|
+}
|
|
2236
|
+func GetUnusualKTVORURRInspectionTotalByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, min_value float64) (total int64, err error) {
|
|
2237
|
+ var count []*InspectionCount
|
|
2238
|
+ 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.project_id = ? and x.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.project_id = ? and xti.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, min_value).Scan(&count).Error
|
|
2239
|
+ for _, items := range count {
|
|
2240
|
+ total = total + items.Count
|
|
2241
|
+ }
|
|
2242
|
+ return total, err2
|
|
2243
|
+}
|
|
2244
|
+
|
|
2245
|
+func GetPatientNotKTVORURRInspectionTotal(startime int64, endtime int64, orgid int64, projectid int64, item_id int64) (total int64, err error) {
|
|
2246
|
+ err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.project_id = ? and pd.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
|
|
2247
|
+ return total, err
|
|
2248
|
+}
|
|
2249
|
+
|
|
2250
|
+func GetFiveInspectionPatientList(orgid int64, keyword string) (xti []*models.XtPatientsTenOne, err error) {
|
|
2251
|
+ keyword = "%" + keyword + "%"
|
|
2252
|
+ err = XTReadDB().Model(models.XtPatientsTenOne{}).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and xt_patients.lapseto = 1 and xt.patients.name like ?", orgid, keyword).Find(&xti).Error
|
|
2253
|
+ return
|
|
2254
|
+}
|
|
2255
|
+
|
|
2256
|
+func GetPatientFiveInspectionByID(startime int64, endtime int64, orgid int64, keyword string) (inspections []models.InspectionTen, err error) {
|
|
2257
|
+ keyword = "%" + keyword + "%"
|
|
2258
|
+
|
|
2259
|
+ db := XTReadDB().Table("xt_patients as p").Select("p.id as patient_id, p.name as name, IFNULL(a.inspect_value, '') AS 'ipth',IFNULL(b.inspect_value, '') AS 'xuejia',IFNULL(c.inspect_value, '') AS 'xuelin',IFNULL(d.inspect_value, '') AS 'bdb',IFNULL(e.inspect_value, '') AS 'xhdb'").Joins("LEFT JOIN `xt_inspection` a ON p.id = a.patient_id AND a.org_id = ? and a.`reference_item_id` = 171 and a.`reference_project_id` = 20 and a.`inspect_date` >= ? and a.`inspect_date` <= ? LEFT JOIN xt_inspection b ON p.id = b.patient_id AND b.org_id = ? and b.`reference_item_id` = 48 and b.`reference_project_id` = 4 and b.`inspect_date` >= ? and b.`inspect_date` <= ? LEFT JOIN xt_inspection c ON p.id = c.patient_id AND c.org_id = ? and c.`reference_item_id` = 169 and c.`reference_project_id` = 4 and c.`inspect_date` >= ? and c.`inspect_date` <= ? LEFT JOIN xt_inspection d ON p.id = d.patient_id AND d.org_id = ? and d.`reference_item_id` = 35 and d.`reference_project_id` = 2 and d.`inspect_date` >= ? and d.`inspect_date` <= ? LEFT JOIN xt_inspection e ON p.id = e.patient_id AND e.org_id = ? and e.`reference_item_id` = 17 and e.`reference_project_id` = 1 and e.`inspect_date` >= ? and e.`inspect_date` <= ?", orgid, startime, endtime, orgid, startime, endtime, orgid, startime, endtime, orgid, startime, endtime, orgid, startime, endtime).Where("p.name like ? and p.user_org_id = ? and p.status = 1 and p.lapseto = 1 ", keyword, orgid).Group("p.id")
|
|
2260
|
+ err = db.Find(&inspections).Error
|
|
2261
|
+ return inspections, err
|
|
2262
|
+}
|