|
@ -1310,24 +1310,16 @@ public class DoctorSchemeService extends BaseService{
|
|
|
rs.put("dbPresCount",0);
|
|
|
}
|
|
|
|
|
|
//餐前达标数量
|
|
|
List<Map<String,Object>> cqXT = jdbcTemplate.queryForList(getXTSql( doctor , teamCode, startDate, endDate, "0"));
|
|
|
Long cqtotal;
|
|
|
//血糖达标数量
|
|
|
List<Map<String,Object>> cqXT = jdbcTemplate.queryForList(getXTAimSQL( doctor , teamCode, startDate, endDate));
|
|
|
Long dbSuggerCount;
|
|
|
if(cqXT!=null&&cqXT.size()>0){
|
|
|
cqtotal = (Long)cqXT.get(0).get("dbCount");
|
|
|
dbSuggerCount = (Long)cqXT.get(0).get("total");
|
|
|
}else{
|
|
|
cqtotal = 0L;
|
|
|
}
|
|
|
//餐后达标数量
|
|
|
List<Map<String,Object>> chXT = jdbcTemplate.queryForList(getXTSql( doctor , teamCode, startDate, endDate, "1"));
|
|
|
Long chtotal;
|
|
|
if(chXT!=null&&chXT.size()>0){
|
|
|
chtotal = (Long)chXT.get(0).get("dbCount");
|
|
|
}else{
|
|
|
chtotal = 0L;
|
|
|
dbSuggerCount = 0L;
|
|
|
}
|
|
|
|
|
|
rs.put("dbSuggerCount",chtotal+cqtotal);
|
|
|
rs.put("dbSuggerCount",dbSuggerCount);
|
|
|
return rs;
|
|
|
|
|
|
}
|
|
@ -1338,17 +1330,21 @@ public class DoctorSchemeService extends BaseService{
|
|
|
* @param teamCode
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param state 0 餐前,1餐后
|
|
|
* @param state 0 餐前,1餐_后
|
|
|
* @return
|
|
|
*/
|
|
|
public String getXTSql(String doctor ,Long teamCode,String startDate,String endDate,String state){
|
|
|
String value1 ="cast(p.fbg as SIGNED INTEGER)";
|
|
|
String value1min ="cast(p.fbg_min as SIGNED INTEGER)";
|
|
|
String value2 ="1,3,5,7";
|
|
|
if("1".equals(state)){
|
|
|
value2 = "2,4,6";
|
|
|
value1 = "cast(p.hpg AS SIGNED INTEGER)";
|
|
|
value1min ="cast(p.hpg_min AS SIGNED INTEGER)";
|
|
|
}
|
|
|
//餐前血糖达标数
|
|
|
String xtSql = "SELECT " +
|
|
|
" COUNT(1) AS dbCount " +
|
|
|
" tt.`user` " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
@ -1362,6 +1358,7 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" ) " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.value2 in("+value2+") " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
@ -1382,9 +1379,9 @@ public class DoctorSchemeService extends BaseService{
|
|
|
" SELECT p.patient_code AS `user` FROM wlyy_track_patient p WHERE p.del='1' AND p.doctor_code='"+doctor+"' AND p.team_code =" +teamCode+
|
|
|
" ) " +
|
|
|
" AND " +
|
|
|
" i.value1 <= cast(p.fbg as SIGNED INTEGER) " +
|
|
|
" i.value1 <= " +value1+
|
|
|
" AND " +
|
|
|
" i.value1 >= cast(p.fbg_min as SIGNED INTEGER) " +
|
|
|
" i.value1 >= " +value1min +
|
|
|
" AND i.value2 in("+value2+") " +
|
|
|
" AND i.del ='1' " +
|
|
|
" AND i.type = 1 " +
|
|
@ -1397,6 +1394,95 @@ public class DoctorSchemeService extends BaseService{
|
|
|
return xtSql;
|
|
|
}
|
|
|
|
|
|
public String getXTAimSQL(String doctor ,Long teamCode,String startDate,String endDate){
|
|
|
String sql = "SELECT " +
|
|
|
" COUNT(1) total " +
|
|
|
" FROM " +
|
|
|
" ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS total " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" WHERE " +
|
|
|
" i.`user` IN ( " +
|
|
|
" SELECT " +
|
|
|
" p.patient_code AS `user` " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient p " +
|
|
|
" WHERE " +
|
|
|
" p.del = '1' " +
|
|
|
" AND p.doctor_code = '"+doctor+"' " +
|
|
|
" AND p.team_code = " +teamCode+
|
|
|
" ) " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) tt " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS dbtotal " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" JOIN wlyy_patient_aim_blood_sugger p ON p.patientcode = i.`user` " +
|
|
|
" WHERE " +
|
|
|
" i.`user` IN ( " +
|
|
|
" SELECT " +
|
|
|
" p.patient_code AS `user` " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient p " +
|
|
|
" WHERE " +
|
|
|
" p.del = '1' " +
|
|
|
" AND p.doctor_code = '"+doctor+"' " +
|
|
|
" AND p.team_code = " +teamCode+
|
|
|
" ) " +
|
|
|
" AND i.value1 <= cast(p.fbg AS SIGNED INTEGER) " +
|
|
|
" AND i.value1 >= cast(p.fbg_min AS SIGNED INTEGER) " +
|
|
|
" AND i.value2 IN (1,3,5,7) " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) dbt ON tt.`user` = dbt.`user` " +
|
|
|
" LEFT JOIN ( " +
|
|
|
" SELECT " +
|
|
|
" i.`user`, " +
|
|
|
" COUNT(1) AS dbtotal " +
|
|
|
" FROM " +
|
|
|
" device.wlyy_patient_health_index i " +
|
|
|
" JOIN wlyy_patient_aim_blood_sugger p ON p.patientcode = i.`user` " +
|
|
|
" WHERE " +
|
|
|
" i.`user` IN ( " +
|
|
|
" SELECT " +
|
|
|
" p.patient_code AS `user` " +
|
|
|
" FROM " +
|
|
|
" wlyy_track_patient p " +
|
|
|
" WHERE " +
|
|
|
" p.del = '1' " +
|
|
|
" AND p.doctor_code = '"+doctor+"' " +
|
|
|
" AND p.team_code = " +teamCode +
|
|
|
" ) " +
|
|
|
" AND i.value1 <= cast(p.hpg AS SIGNED INTEGER) " +
|
|
|
" AND i.value1 >= cast(p.hpg_min AS SIGNED INTEGER) " +
|
|
|
" AND i.value2 IN (2,4,6) " +
|
|
|
" AND i.del = '1' " +
|
|
|
" AND i.type = 1 " +
|
|
|
" AND i.record_date >= '"+startDate+"' " +
|
|
|
" AND i.record_date <= '"+endDate+"' " +
|
|
|
" GROUP BY " +
|
|
|
" i.`user` " +
|
|
|
" ) cht ON tt.`user` = cht.`user` " +
|
|
|
" WHERE " +
|
|
|
" (IFNULL(dbt.dbtotal,0)+IFNULL(cht.dbtotal,0))/ tt.total > 0.7";
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
public Map<String,Object> getDeviceStateByTeam(String doctor ,Long teamCode){
|
|
|
String sql ="SELECT " +
|
|
|
" COUNT(1) AS total " +
|