Bladeren bron

三院诊后头部统计

wangzhinan 2 maanden geleden
bovenliggende
commit
1b4b6c33af

+ 125 - 0
business/es-service/src/main/java/com/yihu/jw/es/service/StatisticsEsService.java

@ -8572,4 +8572,129 @@ public class StatisticsEsService {
        System.out.println(JSON.toJSONString(re));
        return re;
    }
    /**
     * 诊后随访头部
     * @param startDate
     * @param endDate
     * @param flag
     * @param area
     * @return
     */
    public JSONObject getFollowUpHeaderTotal(String startDate,String endDate,Integer flag) {
        JSONObject jsonObject = new JSONObject();
        if (flag == 1) {
            startDate = DateUtil.getFirstMonthDay() + " 00:00:00";
            endDate = DateUtil.getLastMonthDay() + " 23:59:59";
        } else if (flag == 2) {
            startDate = DateUtil.getMonthDate(new Date(), -6) + " 00:00:00";
            endDate = DateUtil.getStringDateShort() + " 23:59:59";
        } else if (flag == 3) {
            startDate = DateUtil.getCurrentYearStartTime() + " 00:00:00";
            endDate = DateUtil.getCurrentYearEndTime() + " 23:59:59";
        }
        //开通详情
        String sql = "select dept_name,diagnosis_name from base_disease_hospital where status=1 and create_time>='"+startDate+"' and create_time <='"+endDate+"'";
        List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(sql);
        Set<String> deptSet = new HashSet<>();
        Set<String> diagnosisSet = new HashSet<>();
        for (Map<String,Object> map:diseaseList){
            String dept = map.get("dept_name").toString();
            String str[] = dept.split(",");
            for (int i=0;i<str.length;i++){
                deptSet.add(str[i]);
            }
            String diagnosisName = map.get("diagnosis_name").toString();
            String str1[] = diagnosisName.split(",");
            for (int i=0;i<str1.length;i++){
                diagnosisSet.add(str1[i]);
            }
        }
        jsonObject.put("dept",deptSet);//开通的科室
        jsonObject.put("diagnosisName",diagnosisSet);//开通的疾病
        //下转次数:
        String turnSql = "select count(1) as total  from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
        String turnTotal = "0";
        String shoudongTurnTotal = "0";
        String zidongTurnTotal = "0";
        Map<String,Object> turnMap = jdbcTemplate.queryForMap(turnSql);
        if (turnMap!=null){
            if (turnMap.get("total")!=null){
                turnTotal = turnMap.get("total").toString();
            }
        }
        String zidongTurnSql = turnSql+" and from_source =2 ";
        Map<String,Object> zidongTurnMap = jdbcTemplate.queryForMap(zidongTurnSql);
        if (zidongTurnMap!=null){
            if (zidongTurnMap.get("total")!=null){
                zidongTurnTotal = zidongTurnMap.get("total").toString();
            }
        }
        String shoudongTurnSql = turnSql+ " and from_source=1 ";
        Map<String,Object> shoudongTurnMap = jdbcTemplate.queryForMap(shoudongTurnSql);
        if (shoudongTurnMap!=null){
            if (shoudongTurnMap.get("total")!=null){
                shoudongTurnTotal = shoudongTurnMap.get("total").toString();
            }
        }
        jsonObject.put("zidongTurnTotal",zidongTurnTotal);//自动下转
        jsonObject.put("shoudongTurnTotal",shoudongTurnTotal);//手动下转
        jsonObject.put("turnTotal",turnTotal);//下转总数
        //下转人数
        String turnPersonTotal = "0";
        String turnPersonSql = "select count(DISTINCT patient) as total  from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
        Map<String,Object> turnPersonMap = jdbcTemplate.queryForMap(turnPersonSql);
        if (turnPersonMap!=null){
            if (turnPersonMap.get("total")!=null){
                turnPersonTotal = turnPersonMap.get("total").toString();
            }
        }
        //下转人数性别
        String turnSexSql = "SELECT\n" +
                "\tcount(DISTINCT patient) AS total,\n" +
                "\tsex\n" +
                "FROM\n" +
                "\twlyy_rehabilitation_patient_info\n" +
                "WHERE\n" +
                "\tcreate_time >= '"+startDate+"'\n" +
                "AND create_time <= '"+endDate+"'\n" +
                "GROUP BY\n" +
                "\tsex";
        List<Map<String,Object>> sexMapList = jdbcTemplate.queryForList(turnSexSql);
        for (Map<String,Object> map:sexMapList){
            if (map.get("sex")!=null){
                if (map.get("sex").toString().equalsIgnoreCase("1")){
                    map.put("sexName","男");
                }else if (map.get("sex").toString().equalsIgnoreCase("2")){
                    map.put("sexName","女");
                }else {
                    map.put("sexName","未知");
                }
            }
        }
        jsonObject.put("turnPersonTotal",turnPersonTotal);//下转人数
        jsonObject.put("sexMapList",sexMapList);//性别分布
        //随访次数
        String followUpTotal = "0";//随访总次数
        String followupSql = "select COUNT(1) total from wlyy_followup where followup_date >='"+startDate+"' and followup_date <='"+endDate+"'";
        Map<String,Object> followupMap = jdbcTemplate.queryForMap(followupSql);
        if (followupMap!=null){
            if (followupMap.get("total")!=null){
                followUpTotal = followupMap.get("total").toString();
            }
        }
        String followupCompleteTotal = "0";
        String followupCompleteSql = followupSql + " and status = 1 ";
        Map<String,Object> followupCompleteMap = jdbcTemplate.queryForMap(followupCompleteSql);
        if (followupCompleteMap!=null){
            if (followupCompleteMap.get("total")!=null){
                followupCompleteTotal = followupCompleteMap.get("total").toString();
            }
        }
        String rate = getTwoRange(Integer.parseInt(followupCompleteTotal),Integer.parseInt(followUpTotal),0);
        jsonObject.put("followupCompleteRate",rate);
        jsonObject.put("followupTotal",followUpTotal);
        return jsonObject;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationPatientInfoDO.java

@ -70,7 +70,7 @@ public class RehabilitationPatientInfoDO extends IdEntity {
    private String patient;    //居民code
    private Integer type;//1患者家签列表 2康复下转列表
    private Integer type;//1患者家签列表 2康复下转列表 3、出院下转4、门诊下转
    private Integer signStatus;//签约状态(1已家签 0 待家签)
    private String createUser;//创建code
    private String createUserName;//创建者

+ 17 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/statistics/EsStatisticsEndpoint.java

@ -2087,4 +2087,21 @@ class EsStatisticsEndpoint extends EnvelopRestEndpoint {
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "getFollowUpHeaderTotal")
    @ApiOperation(value = "诊后随访统计--头部")
    public ObjEnvelop getFollowUpHeaderTotal(@ApiParam(name = "startTime", value = "开始时间 YYYY-MM-DD HH:MM:SS")
                                           @RequestParam(value = "startTime", required = false) String startTime,
                                       @ApiParam(name = "endTime", value = "结束时间 YYYY-MM-DD HH:MM:SS")
                                           @RequestParam(value = "endTime", required = false) String endTime,
                                          @ApiParam(name = "flag", value = "1本月2近半年3近一年0自定义")
                                              @RequestParam(value = "flag", required = false) Integer flag) {
        try {
            return ObjEnvelop.getSuccess("查询成功",statisticsEsService.getFollowUpHeaderTotal(startTime,endTime,flag));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
}