Explorar el Código

完整性、及时性、准确性接收时间改成就诊时间

zhengwei hace 6 años
padre
commit
467e53e600

+ 4 - 4
src/main/java/com/yihu/ehr/analyze/service/dataQuality/DataCompleteService.java

@ -47,9 +47,9 @@ public class DataCompleteService extends DataQualityBaseService {
        double totalNum = 0;//平台总数
        double totalHospitalNum = 0;//医院总数
        //机构数据
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "create_date", startDate, end, null);
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "event_date", startDate, end, null);
        //平台接收数据量
        Map<String, Object> platformDataGroup = getPlatformDataGroup(dataLevel, "receive_date", startDate, endDate, null);
        Map<String, Object> platformDataGroup = getPlatformDataGroup(dataLevel, "event_date", startDate, endDate, null);
        // 计算
        for (Map<String, Object> map : groupList) {
            resMap = new HashMap<String, Object>();
@ -97,9 +97,9 @@ public class DataCompleteService extends DataQualityBaseService {
        double totalNum = 0;//平台总数
        double totalHospitalNum = 0;//医院总数
        //机构数据
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "create_date", startDate, end, areaCode);
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "event_date", startDate, end, areaCode);
        //平台接收数据量
        Map<String, Object> platformDataGroup = getPlatformDataGroup(dataLevel, "receive_date", startDate, endDate, areaCode);
        Map<String, Object> platformDataGroup = getPlatformDataGroup(dataLevel, "event_date", startDate, endDate, areaCode);
        // 计算
        for (Map<String, Object> map : groupList) {
            resMap = new HashMap<String, Object>();

+ 5 - 5
src/main/java/com/yihu/ehr/analyze/service/dataQuality/DataCorrectService.java

@ -255,7 +255,7 @@ public class DataCorrectService extends DataQualityBaseService {
        //准确性算法,由于之前算法依赖到  医院总数据量,   医院数据量经常未做上报,导致数据问题,先改成 根据接收总数计算
        List<Map<String,Object>> groupList = getReceiveMap(dataLevel,startDate,end,null);
        //平台接收错误数据量
        Map<String, Object> platformErrorGroup = getErrorPlatformData(dataLevel,"receive_date",startDate, endDate,null);
        Map<String, Object> platformErrorGroup = getErrorPlatformData(dataLevel,"event_date",startDate, endDate,null);
        // 计算
        for (Map<String,Object> map:groupList){
            resMap = new HashMap<String,Object>();
@ -307,7 +307,7 @@ public class DataCorrectService extends DataQualityBaseService {
        //准确性算法,由于之前算法依赖到  医院总数据量,   医院数据量经常未做上报,导致数据问题,先改成 根据接收总数计算
        List<Map<String,Object>> groupList = getReceiveMap(dataLevel,startDate,end,areaCode);
        //平台接收数据量
        Map<String, Object> platformDataGroup = getErrorPlatformData(dataLevel,"receive_date",startDate, endDate,areaCode);
        Map<String, Object> platformDataGroup = getErrorPlatformData(dataLevel,"event_date",startDate, endDate,areaCode);
        // 计算
        for (Map<String,Object> map:groupList){
            resMap = new HashMap<String,Object>();
@ -375,16 +375,16 @@ public class DataCorrectService extends DataQualityBaseService {
            String sql1 = "";
            if (StringUtils.isNotEmpty(orgArea)) {
                fields.add("org_code");
                sql1 = "SELECT org_code,count(distinct profile_id) as count from json_archives where org_area='" + orgArea + "' and receive_date>='" + start + "' and receive_date<='" + end + "' group by org_code";
                sql1 = "SELECT org_code,count(distinct profile_id) as count from json_archives where org_area='" + orgArea + "' and event_date>='" + start + "' and event_date<='" + end + "' group by org_code";
            } else {
                if (dataLevel == 0) {
                    fields.add("org_area");
                    sql1 = "SELECT org_area,count(distinct profile_id) as count from json_archives where " +
                            "receive_date >='" + start + "' and receive_date <='" + end + "' group by org_area";
                            "event_date >='" + start + "' and event_date <='" + end + "' group by org_area";
                }else {
                    fields.add("org_code");
                    sql1 = "SELECT org_code,count(distinct profile_id) as count from json_archives where " +
                            "receive_date >='" + start + "' and receive_date <='" + end + "' group by org_code";
                            "event_date >='" + start + "' and event_date <='" + end + "' group by org_code";
                }
            }

+ 4 - 4
src/main/java/com/yihu/ehr/analyze/service/dataQuality/DataInTimeService.java

@ -147,9 +147,9 @@ public class DataInTimeService extends DataQualityBaseService {
        double totalNum = 0;//平台总数
        double totalHospitalNum = 0;//医院总数
        //机构数据
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "create_date", startDate, end, null);
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "event_date", startDate, end, null);
        //平台接收数据量
        Map<String, Object> platformDataGroup = getInTimeDataMap(dataLevel, "receive_date", startDate, endDate, null);
        Map<String, Object> platformDataGroup = getInTimeDataMap(dataLevel, "event_date", startDate, endDate, null);
        // 计算
        for (Map<String, Object> map : groupList) {
            resMap = new HashMap<String, Object>();
@ -195,9 +195,9 @@ public class DataInTimeService extends DataQualityBaseService {
        double totalNum = 0;//平台总数
        double totalHospitalNum = 0;//医院总数
        //机构数据
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "create_date", startDate, end, areaCode);
        List<Map<String, Object>> groupList = dataCorrectService.getOrgDataMap(dataLevel, "event_date", startDate, end, areaCode);
        //平台接收数据量
        Map<String, Object> platformDataGroup = getInTimeDataMap(dataLevel, "receive_date", startDate, endDate, areaCode);
        Map<String, Object> platformDataGroup = getInTimeDataMap(dataLevel, "event_date", startDate, endDate, areaCode);
        // 计算
        for (Map<String, Object> map : groupList) {
            resMap = new HashMap<String, Object>();

+ 32 - 32
src/main/java/com/yihu/ehr/analyze/service/dataQuality/DataQualityHomeService.java

@ -204,7 +204,7 @@ public class DataQualityHomeService extends BaseJpaService {
        double totalCorrect = 0;//总准确数
        //1. 获取医院档案量;
        Envelop envelop = packQcReportService.dailyReport("create_date", start + "T00:00:00Z", end + "T23:59:59Z", null);
        Envelop envelop = packQcReportService.dailyReport("event_date", start + "T00:00:00Z", end + "T23:59:59Z", null);
        Map<String, Object> hospitalDataMap = (Map<String, Object>) envelop.getDetailModelList().get(0);
        //医院总数据量
        totalHospitalNum = (int) hospitalDataMap.get("total");
@ -213,12 +213,12 @@ public class DataQualityHomeService extends BaseJpaService {
        hospitalExamNum = (int) hospitalDataMap.get("physical");
        Map<String, Object> dataMap = new HashMap<>();
        //2. 平台就诊完整数
        getPatientCount("receive_date",start, end, null, dataMap);
        getPatientCount("event_date",start, end, null, dataMap);
        totalVisitNum = Double.valueOf(dataMap.get("visitIntegrity").toString());//就诊完整数
        //3. 及时数
        totalInTime = getInTimeNum("receive_date" ,start, end);
        totalInTime = getInTimeNum("event_date" ,start, end);
        // 3. 去重准确数【】
        totalCorrect = getErrorDataSetData("receive_date",start, end, null);
        totalCorrect = getErrorDataSetData("event_date",start, end, null);
        //4. 数据集总量
        double dataSetsMun = getDataSetsMap(start, end, null);
@ -267,13 +267,13 @@ public class DataQualityHomeService extends BaseJpaService {
        double totalVisitNum = 0;//总完整数(平台总就诊数)
        //1. 获取医院档案量;
        Envelop envelop = packQcReportService.dailyReport("create_date", start + "T00:00:00Z", end + "T23:59:59Z", null);
        Envelop envelop = packQcReportService.dailyReport("event_date", start + "T00:00:00Z", end + "T23:59:59Z", null);
        Map<String, Object> hospitalDataMap = (Map<String, Object>) envelop.getDetailModelList().get(0);
        //医院总数据量
        totalHospitalNum = (int) hospitalDataMap.get("total");
        Map<String, Object> dataMap = new HashMap<>();
        //2. 平台就诊完整数
        getPatientCount("receive_date",start, end, null, dataMap);
        getPatientCount("event_date",start, end, null, dataMap);
        totalVisitNum = Double.valueOf(dataMap.get("visitIntegrity").toString());
        totalMap.put("totalComplete", totalVisitNum);//总就诊完整数
        totalMap.put("totalHospital", totalHospitalNum);//医院总就诊数
@ -302,7 +302,7 @@ public class DataQualityHomeService extends BaseJpaService {
        double totalCorrect = 0;//总准确数
        long starttime1 = System.currentTimeMillis();
        //1. 去重准确数
        totalCorrect = getErrorDataSetData("receive_date",start, end, null);
        totalCorrect = getErrorDataSetData("event_date",start, end, null);
        long endTime1 = System.currentTimeMillis();
        logger.info("去重准确数耗时:"+ (endTime1-starttime1));
        //2. 数据集总量
@ -337,13 +337,13 @@ public class DataQualityHomeService extends BaseJpaService {
        int totalHospitalNum = 0;//医院总就诊数
        double totalInTime = 0;//总及时数
        //1. 获取医院档案量;
        Envelop envelop = packQcReportService.dailyReport("create_date", start + "T00:00:00Z", end + "T23:59:59Z", null);
        Envelop envelop = packQcReportService.dailyReport("event_date", start + "T00:00:00Z", end + "T23:59:59Z", null);
        Map<String, Object> hospitalDataMap = (Map<String, Object>) envelop.getDetailModelList().get(0);
        //医院总数据量
        totalHospitalNum = (int) hospitalDataMap.get("total");
        Map<String, Object> dataMap = new HashMap<>();
        //2. 及时数
        totalInTime = getInTimeNum("receive_date" ,start, end);
        totalInTime = getInTimeNum("event_date" ,start, end);
        totalMap.put("totalInTime", totalInTime);//及时数
        totalMap.put("totalHospital", totalHospitalNum);//医院总就诊数
        //3 计算及时率
@ -379,8 +379,8 @@ public class DataQualityHomeService extends BaseJpaService {
            // 原生es
            TransportClient transportClient = elasticSearchPool.getClient();
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("receive_date>=" + start + " 00:00:00;");
            stringBuilder.append("receive_date<=" + end + " 23:59:59;");
            stringBuilder.append("event_date>=" + start + " 00:00:00;");
            stringBuilder.append("event_date<=" + end + " 23:59:59;");
            stringBuilder.append("qc_step=1||qc_step=2;");
            if (StringUtils.isNotEmpty(orgCode)) {
                stringBuilder.append("org_code=" + orgCode);
@ -439,8 +439,8 @@ public class DataQualityHomeService extends BaseJpaService {
        TransportClient transportClient = elasticSearchPool.getClient();
        //  条件设置
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("receive_date>=" + start + " 00:00:00;");
        stringBuilder.append("receive_date<=" + end + " 23:59:59;");
        stringBuilder.append("event_date>=" + start + " 00:00:00;");
        stringBuilder.append("event_date<=" + end + " 23:59:59;");
        if (StringUtils.isNotEmpty(orgCode)) {
            stringBuilder.append("org_code=" + orgCode);
        }
@ -606,8 +606,8 @@ public class DataQualityHomeService extends BaseJpaService {
        fileds.add("count");
        fileds.add("version");
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT dataset,COUNT(dataset) count ,version FROM json_archives_qc/qc_metadata_info ");
        sql.append(" WHERE receive_date>='" + start + " 00:00:00' and (qc_step=1 or qc_step=2) and  receive_date<='" + end + " 23:59:59'");
        sql.append("SELECT dataset,COUNT(DISTINCT pack_id) count ,version FROM json_archives_qc/qc_metadata_info ");
        sql.append(" WHERE event_date>='" + start + " 00:00:00' and (qc_step=1 or qc_step=2) and  event_date<='" + end + " 23:59:59' ");
        if(StringUtils.isNotEmpty(orgArea)){
            sql.append(" AND org_area = '"+orgArea+"'");
@ -649,7 +649,7 @@ public class DataQualityHomeService extends BaseJpaService {
        fileds.add("version");
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT dataset, metadata,COUNT(metadata) count ,version FROM json_archives_qc/qc_metadata_info ");
        sql.append(" WHERE receive_date>='" + start + " 00:00:00' and (qc_step=1 or qc_step=2) and receive_date<='" + end + " 23:59:59'");
        sql.append(" WHERE event_date>='" + start + " 00:00:00' and (qc_step=1 or qc_step=2) and event_date<='" + end + " 23:59:59'");
        if(StringUtils.isNotEmpty(orgArea)){
            sql.append(" AND org_area = '"+orgArea+"'");
        }
@ -715,7 +715,7 @@ public class DataQualityHomeService extends BaseJpaService {
                    start=name.get(i);
                    end=name.get(i);
                }
                double totalInTime = getInTimeNum("receive_date" ,start, end);
                double totalInTime = getInTimeNum("event_date" ,start, end);
                if(hospitalDataMap.get(name.get(i))!=null&&Double.parseDouble(hospitalDataMap.get(name.get(i))+"")!=0){
                    double rate = totalInTime/(double)hospitalDataMap.get(name.get(i))*100;
                    data.add((double) Math.round(rate * 100) / 100);
@ -881,7 +881,7 @@ public class DataQualityHomeService extends BaseJpaService {
        if("10".equals(flag)){//按月
            start =  DateUtil.formatDate(DateUtil.addMonth(-6, DateUtil.formatCharDateYMD(month+"-01")), "yyyy-MM") + "-01";
            end =  DateUtil.getLastDate (month + "-01", "yyyy-MM-dd", "yyyy-MM-dd");
            aggregation = AggregationBuilders.dateHistogram("agg").field("receive_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.MONTH).format("yyyy-MM");
        }else{//按日
@ -893,21 +893,21 @@ public class DataQualityHomeService extends BaseJpaService {
                start = month+"-01";
                end =  DateUtil.getLastDate (month+"-01", "yyyy-MM-dd", "yyyy-MM-dd");
            }
            aggregation = AggregationBuilders.dateHistogram("agg").field("receive_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.DAY).format("yyyy-MM-dd");
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("pack_type=1;");
        stringBuilder.append("receive_date>=" + start + " 00:00:00;");
        stringBuilder.append("receive_date<" + end + " 23:59:59;");
        stringBuilder.append("event_date>=" + start + " 00:00:00;");
        stringBuilder.append("event_date<" + end + " 23:59:59;");
        CardinalityBuilder childTerms = AggregationBuilders.cardinality("count").field("event_no").precisionThreshold(40000);
        SearchRequestBuilder requestBuilder = transportClient.prepareSearch("json_archives")
                .setTypes("info");
        requestBuilder.setQuery(elasticSearchUtil.getQueryBuilder(stringBuilder.toString()));
        requestBuilder.addAggregation(aggregation.subAggregation(childTerms));
        requestBuilder.addSort("receive_date", SortOrder.DESC);
        requestBuilder.addSort("event_date", SortOrder.DESC);
        SearchResponse response = requestBuilder.execute().actionGet();
        Histogram agg = response.getAggregations().get("agg");
@ -935,7 +935,7 @@ public class DataQualityHomeService extends BaseJpaService {
        if("10".equals(flag)){//按月
            start =  DateUtil.formatDate(DateUtil.addMonth(-6, DateUtil.formatCharDateYMD(month+"-01")), "yyyy-MM") + "-01";
            end =  DateUtil.getLastDate (month + "-01", "yyyy-MM-dd", "yyyy-MM-dd");
            aggregation = AggregationBuilders.dateHistogram("agg").field("receive_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.MONTH).format("yyyy-MM");
        }else{//按日
@ -947,20 +947,20 @@ public class DataQualityHomeService extends BaseJpaService {
                start = month+"-01";
                end =  DateUtil.getLastDate (month+"-01", "yyyy-MM-dd", "yyyy-MM-dd");
            }
            aggregation = AggregationBuilders.dateHistogram("agg").field("receive_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.DAY).format("yyyy-MM-dd");
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("receive_date>=" + start + " 00:00:00;");
        stringBuilder.append("receive_date<=" + end + " 23:59:59;");
        stringBuilder.append("event_date>=" + start + " 00:00:00;");
        stringBuilder.append("event_date<=" + end + " 23:59:59;");
        SumBuilder terms = AggregationBuilders.sum("sumCount").field("count");
        SearchRequestBuilder requestBuilder = transportClient.prepareSearch("json_archives_qc")
                .setTypes("qc_dataset_detail");
        requestBuilder.setQuery(elasticSearchUtil.getQueryBuilder(stringBuilder.toString()));
        requestBuilder.addAggregation(aggregation.subAggregation(terms));
        requestBuilder.addSort("receive_date", SortOrder.DESC);
        requestBuilder.addSort("event_date", SortOrder.DESC);
        SearchResponse response = requestBuilder.execute().actionGet();
        Histogram agg = response.getAggregations().get("agg");
@ -986,7 +986,7 @@ public class DataQualityHomeService extends BaseJpaService {
        if("10".equals(flag)){//按月
            start =  DateUtil.formatDate(DateUtil.addMonth(-6, DateUtil.formatCharDateYMD(month+"-01")), "yyyy-MM") + "-01";
            end =  DateUtil.getLastDate (month + "-01", "yyyy-MM-dd", "yyyy-MM-dd");
            aggregation = AggregationBuilders.dateHistogram("agg").field("receive_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.MONTH).format("yyyy-MM");
        }else{//按日
@ -998,13 +998,13 @@ public class DataQualityHomeService extends BaseJpaService {
                start = month+"-01";
                end =  DateUtil.getLastDate (month+"-01", "yyyy-MM-dd", "yyyy-MM-dd");
            }
            aggregation = AggregationBuilders.dateHistogram("agg").field("receive_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.DAY).format("yyyy-MM-dd");
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("receive_date>=" + start + " 00:00:00;");
        stringBuilder.append("receive_date<=" + end + " 23:59:59;");
        stringBuilder.append("event_date>=" + start + " 00:00:00;");
        stringBuilder.append("event_date<=" + end + " 23:59:59;");
        stringBuilder.append("qc_step=1||qc_step=2;");
        AggregationBuilder terms = AggregationBuilders.terms("dataset").field("dataset").size(200);
        CardinalityBuilder childTerms = AggregationBuilders.cardinality("count").field("pack_id").precisionThreshold(40000);
@ -1014,7 +1014,7 @@ public class DataQualityHomeService extends BaseJpaService {
                .setTypes("qc_metadata_info");
        requestBuilder.setQuery(elasticSearchUtil.getQueryBuilder(stringBuilder.toString()));
        requestBuilder.addAggregation(aggregation.subAggregation(terms));
        requestBuilder.addSort("receive_date", SortOrder.DESC);
        requestBuilder.addSort("event_date", SortOrder.DESC);
        SearchResponse response = requestBuilder.execute().actionGet();
        Histogram agg = response.getAggregations().get("agg");

+ 9 - 9
src/main/java/com/yihu/ehr/analyze/service/pack/PackQcReportService.java

@ -103,15 +103,15 @@ public class PackQcReportService extends BaseJpaService {
        List<Map<String, Object>> res = elasticSearchUtil.list("qc","daily_report", boolQueryBuilder);
        if(res!=null && res.size()>0){
            for(Map<String,Object> report : res){
//                total+=Integer.parseInt(report.get("HSI07_01_001").toString());
                total+=Integer.parseInt(report.get("HSI07_01_001").toString());
                inpatient+=Integer.parseInt(report.get("HSI07_01_012").toString());
                oupatient+=Integer.parseInt(report.get("HSI07_01_002").toString());
                physical+=Integer.parseInt(report.get("HSI07_01_004").toString());
            }
        }
        total +=inpatient;
        total +=oupatient;
        total +=physical;
//        total +=inpatient;
//        total +=oupatient;
//        total +=physical;
        resMap.put("total",total);
        resMap.put("inpatient",inpatient);
        resMap.put("oupatient",oupatient);
@ -139,7 +139,7 @@ public class PackQcReportService extends BaseJpaService {
        if("10".equals(flag)){//按月
            start =  DateUtil.formatDate(DateUtil.addMonth(-6, DateUtil.formatCharDateYMD(month+"-01")), "yyyy-MM") + "-01";
            end =  DateUtil.getLastDate (month + "-01", "yyyy-MM-dd", "yyyy-MM-dd");
            aggregation = AggregationBuilders.dateHistogram("agg").field("create_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.MONTH).format("yyyy-MM");
        }else{//按日
@ -151,17 +151,17 @@ public class PackQcReportService extends BaseJpaService {
                start = month+"-01";
                end =  DateUtil.getLastDate (month+"-01", "yyyy-MM-dd", "yyyy-MM-dd");
            }
            aggregation = AggregationBuilders.dateHistogram("agg").field("create_date")
            aggregation = AggregationBuilders.dateHistogram("agg").field("event_date")
                    .interval(DateHistogramInterval.DAY).format("yyyy-MM-dd");
        }
        // 声明where 条件
        BoolQueryBuilder qbs = QueryBuilders.boolQuery();
        RangeQueryBuilder startRange = QueryBuilders.rangeQuery("create_date");
        RangeQueryBuilder startRange = QueryBuilders.rangeQuery("event_date");
        startRange.gte(start + "T00:00:00Z");
        qbs.must(startRange);
        RangeQueryBuilder endRange = QueryBuilders.rangeQuery("create_date");
        RangeQueryBuilder endRange = QueryBuilders.rangeQuery("event_date");
        endRange.lt(end+"T23:59:59Z");
        qbs.must(endRange);
@ -171,7 +171,7 @@ public class PackQcReportService extends BaseJpaService {
                .setTypes("daily_report");
        requestBuilder.setQuery(qbs);
        requestBuilder.addAggregation(aggregation.subAggregation(terms));
        requestBuilder.addSort("create_date", SortOrder.DESC);
        requestBuilder.addSort("event_date", SortOrder.DESC);
        SearchResponse response = requestBuilder.execute().actionGet();
        Histogram agg = response.getAggregations().get("agg");