فهرست منبع

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 7 سال پیش
والد
کامیت
42a73d52bf
1فایلهای تغییر یافته به همراه96 افزوده شده و 15 حذف شده
  1. 96 15
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

+ 96 - 15
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -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;
    }
@ -1352,7 +1344,7 @@ public class DoctorSchemeService extends BaseService{
        }
        //餐前血糖达标数
        String xtSql = "SELECT " +
                " COUNT(1) AS dbCount " +
                " tt.`user` " +
                " FROM " +
                " ( " +
                "  SELECT " +
@ -1402,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 " +