Jelajahi Sumber

修改统计接口长处方总数上部

zd_123 7 tahun lalu
induk
melakukan
ea761ace88

+ 67 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/DiseaseConvert.java

@ -0,0 +1,67 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.HealthLable;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.PrescriptionDisease;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 长处方疾病
 * Created by zhangdan on 2017/10/26.
 */
public class DiseaseConvert implements Convert {
    @Override
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
        List<DataModel> returnList = new ArrayList<>();
        Map<String, List<String>> prescriptionDiseaseMap = new HashMap<>();//key是处方code value是处方标签 1高血压 2糖尿病
        //初始化标签Map
        initHealthLabesMap(jdbcTemplate, prescriptionDiseaseMap);
        //把标签Map设置到对应的维度里面
        for (DataModel dataModel : oneList) {
            List<String> healthProblems = prescriptionDiseaseMap.get(dataModel.getPrescriptionCode());
            if (healthProblems != null && healthProblems.size() > 0) {
                healthProblems.stream().forEach(str -> {
                    try {
                        DataModel dataModelTemp = new DataModel();
                        BeanUtils.copyProperties(dataModel, dataModelTemp);
                        DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, str);
                        returnList.add(dataModelTemp);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                });
            }
        }
        return returnList;
    }
    private void initHealthLabesMap(JdbcTemplate jdbcTemplate, Map<String, List<String>> prescriptionDiseaseMap) {
        //得到长处方的疾病标签(只要高血压 糖尿病)
        String sql = "SELECT " +
                "  health_problem ," +
                "  prescription_code " +
                "FROM " +
                "  wlyy_prescription_diagnosis " +
                "WHERE " +
                "  health_problem = 'HP0047' " +
                "OR health_problem = 'HP0093' ";
        List<PrescriptionDisease> prescriptionDiseases = jdbcTemplate.query(sql, new BeanPropertyRowMapper(PrescriptionDisease.class));
        prescriptionDiseases.stream().forEach(one -> {
            List<String> labels = prescriptionDiseaseMap.get(one.getPrescriptionCode());
            if (labels == null) {
                labels = new ArrayList<String>();
            }
            labels.add(one.getHealthProblem());
            prescriptionDiseaseMap.put(one.getPrescriptionCode(), labels);
        });
    }
}

+ 55 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/PrescriptionStatusConvert.java

@ -0,0 +1,55 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy;
import com.yihu.wlyy.entity.dimension.WlyyDimensionQuota;
import com.yihu.wlyy.statistics.etl.convert.Convert;
import com.yihu.wlyy.statistics.etl.convert.wlyy.model.PrescriptionDisease;
import com.yihu.wlyy.statistics.util.Contant;
import com.yihu.wlyy.statistics.vo.DataModel;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 长处方疾病
 * Created by zhangdan on 2017/10/26.
 */
public class PrescriptionStatusConvert implements Convert {
    public List<DataModel> convert(JdbcTemplate jdbcTemplate, List oneList, String slaveLevel, WlyyDimensionQuota temp ) {
        oneList.stream().forEach(one -> {
            try {
                Object value = DataModel.class.getMethod("get" + temp.getKey()).invoke(one);
                //获取到prescriptionCode,求长处方状态
                String sql ="SELECT status FROM wlyy_prescription WHERE code=?";
                //int status = jdbcTemplate.queryForObject(sql, Integer.class);
                Object[] args = {value};
                int status=jdbcTemplate.queryForObject(sql,args,Integer.class);
                String key = getStatusCode(status);
                DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        return oneList;
    }
    public String getStatusCode(Integer status) {
        if (status >= 0 && status <= 100) {
            return Contant.prescriptionStatus.status_1;
        } else if (status==100) {
            return Contant.prescriptionStatus.status_2;
        } else if (status==-2) {
            return Contant.prescriptionStatus.status_3;
        } else if (status==-1) {
            return Contant.prescriptionStatus.status_4;
        } else if (status==-3) {
            return Contant.prescriptionStatus.status_5;
        } else{
            return "0";
        }
    }
}

+ 26 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/model/PrescriptionDisease.java

@ -0,0 +1,26 @@
package com.yihu.wlyy.statistics.etl.convert.wlyy.model;
/**
 * Created by zhangdan on 2017/10/26.
 */
public class PrescriptionDisease {
    private String healthProblem;
    private String prescriptionCode;
    public String getHealthProblem() {
        return healthProblem;
    }
    public void setHealthProblem(String healthProblem) {
        this.healthProblem = healthProblem;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
}

+ 38 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/util/Contant.java

@ -139,4 +139,42 @@ public class Contant {
        public static String level_age_5_name="51~65";
        public static String level_age_6_name=">65";
    }
    public static class prescriptionStatus{
        public static String status_1="1";
        public static String status_2="2";
        public static String status_3="3";
        public static String status_4="4";
        public static String status_5="5";
        public static String status_6="6";
        public static String status_7="7";
        public static String status_8="8";
        public static String status_9="9";
        public static String status_10="10";
        public static String status_11="11";
        public static String status_12="12";
        public static String status_13="13";
//        public static String status_1_name="续方取消";
//        public static String status_2_name="审核不通过";
//        public static String status_3_name="审核中";
//        public static String status_4_name="药师审核中";
//        public static String status_5_name="药师审核失败";
//        public static String status_6_name="开方中/药师审核成功";
//        public static String status_7_name="开方失败/预结算失败";
//        public static String status_8_name="待支付";
//        public static String status_9_name="支付成功/待配药";
//        public static String status_10_name="等待领药";
//        public static String status_11_name="配送中";
//        public static String status_12_name="已完成";
//        public static String status_13_name="进行中";
        public static String status_1_name="进行中";//大于0小于100
        public static String status_2_name="已完成";//100
        public static String status_3_name="已取消";//患者取消,-2
        public static String status_4_name="审核不通过";//-1;
        public static String status_5_name="其他原因取消";//支付超时,-3;
    }
}

+ 8 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/vo/DataModel.java

@ -22,6 +22,8 @@ public class DataModel {
    private String serverType;//服务类型
    private String healthLable;//健康标签
    private Double num=1.0;//分数 如果是累加的计算 默认是1 如果是分数从数据库拿
    private String prescriptionCode;//处方code
    public String getHealthLable() {
        return healthLable;
@ -173,4 +175,10 @@ public class DataModel {
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPrescriptionCode() { return prescriptionCode; }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
}

+ 58 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.statistics.PopulationBase;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
@ -19,6 +20,7 @@ import io.searchbox.client.JestClient;
import io.searchbox.core.Bulk;
import io.searchbox.core.BulkResult;
import io.searchbox.core.Index;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -2299,4 +2301,60 @@ public class StatisticsESService {
            return new JSONArray();
        }
    }
    public Map<String,Object> getPrescriptionCount(int level,String area,String disease) throws Exception{
        String index ="58";
        Map<String,Object> rs = new HashedMap();
        //总数
        List<SaveModel> totalList =  elasticsearchUtil.findListDateQuotaLevel1(null,area,level,index,"2",null,disease);
        //进行中
        List<SaveModel> processingList =  elasticsearchUtil.findListDateQuotaLevel2(null,area,level,index,"2",null,disease,"1");
        //已完成
        List<SaveModel> finishedList =  elasticsearchUtil.findListDateQuotaLevel2(null,area,level,index,"2",null,disease,"2");
        //已经取消
        List<SaveModel> canceledList =  elasticsearchUtil.findListDateQuotaLevel2(null,area,level,index,"2",null,disease,"3");
        //审核不通过
        List<SaveModel> unPassList =  elasticsearchUtil.findListDateQuotaLevel2(null,area,level,index,"2",null,disease,"4");
        //其他原因取消
        List<SaveModel> otherList =  elasticsearchUtil.findListDateQuotaLevel2(null,area,level,index,"2",null,disease,"5");
        //总数
        if(totalList!=null && totalList.size()>0){
            rs.put("total",totalList.get(0).getResult2());
        }else{
            rs.put("total",0);
        }
        //进行中
        if(processingList!=null && processingList.size()>0){
            rs.put("processingCount",processingList.get(0).getResult2());
        }else {
            rs.put("processingCount", 0);
        }
        //已完成
        if(finishedList!=null && finishedList.size()>0){
            rs.put("finishCount",finishedList.get(0).getResult2());
        }else {
            rs.put("finishCount", 0);
        }
        //已取消
        if(canceledList!=null && canceledList.size()>0){
            rs.put("patientCancelCount",canceledList.get(0).getResult2());
        }else {
            rs.put("patientCancelCount", 0);
        }
        //审核不通过
        if(unPassList!=null && unPassList.size()>0){
            rs.put("noReviewedCount",unPassList.get(0).getResult2());
        }else {
            rs.put("noReviewedCount", 0);
        }
        //其他原因取消
        if(otherList!=null && otherList.size()>0){
            rs.put("payOuttimeCount",otherList.get(0).getResult2());
        }else {
            rs.put("payOuttimeCount", 0);
        }
        return rs;
    }
}

+ 17 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.util.ValueComparator;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.quota.vo.SaveModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -1587,4 +1588,20 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    //=================================长处方分析===============================================
    @RequestMapping("/getPrescriptionCount")
    @ResponseBody
    @ApiOperation("订单统计-顶部总数获取")
    public String getPrescriptionCount(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                       @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                       @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease){
        try{
            return write(200, "查询成功", "data", statisticsESService.getPrescriptionCount(elasticsearchUtil.changeLevel(Integer.valueOf(level)),area,disease));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -1670,6 +1670,7 @@ public class StatisticsController extends BaseController {
    @RequestMapping("/getPrescriptionCount")
    @ResponseBody
    @ApiOperation("订单统计-顶部总数获取")
    @Deprecated
    public String getPrescriptionCount(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                       @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                       @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease){