zhengwei пре 6 година
родитељ
комит
f4d3d35707

+ 4 - 4
src/main/java/com/yihu/quota/controller/MedicalInsuranceController.java

@ -77,15 +77,15 @@ public class MedicalInsuranceController extends BaseController {
            @RequestParam(value = "start" , required = true) String start,
            @ApiParam(name = "end", value = "结束时间", required = true)
            @RequestParam(value = "end" , required = true) String end,
            @ApiParam(name = "drugCode", value = "药品代码")
            @RequestParam(value = "drugCode", required = false) String drugCode,
            @ApiParam(name = "drugName", value = "药品名称")
            @RequestParam(value = "drugName", required = false) String drugName,
            @ApiParam(name = "eventType", value = "就诊类型")
            @RequestParam(value = "eventType", required = true) String eventType,
            @RequestParam(value = "eventType") String eventType,
            @ApiParam(name = "size", value = "分页大小", defaultValue = "15")
            @RequestParam(value = "size", required = false) int size,
            @ApiParam(name = "page", value = "页码", defaultValue = "1")
            @RequestParam(value = "page", required = false) int page) throws Exception{
        Envelop envelop = new Envelop();
        Envelop envelop = medicalInsuranceService.drugAnalysis(start, end, eventType, drugName, size, page);
        return envelop;
    }
}

+ 77 - 1
src/main/java/com/yihu/quota/service/medicalInsurance/MedicalInsuranceService.java

@ -38,6 +38,7 @@ public class MedicalInsuranceService {
    @Autowired
    private HBaseDao hBaseDao;
    /**
     * 超高费用
     * @param month
@ -92,7 +93,7 @@ public class MedicalInsuranceService {
        }
        if(StringUtils.isNotEmpty(hosLevel)||StringUtils.isNotEmpty(hosHierarchy)){
            String orgCode=getOrgCode(hosLevel,hosHierarchy);
            sb.append(" AND org_code:(").append(orgCode).append(")");
            sb.append(" AND org_code:(").append(StringUtils.isNotEmpty(orgCode)? "null":orgCode).append(")");
        }
        String[] fields = {"rowkey","patient_name","patient_age","patient_sex","demographic_id","EHR_001211","event_date"};
        SolrDocumentList sublist = solrUtil.query(ResourceCore.SubTable,q,sb.toString(),null,(page-1)*size,size,subfields);
@ -243,4 +244,79 @@ public class MedicalInsuranceService {
        return sex;
    }
    /**
     * 用药分析
     * @param start
     * @param end
     * @param eventType
     * @param drugName
     * @param size
     * @param page
     * @return
     * @throws Exception
     */
    public Envelop drugAnalysis(String start,String end,String eventType,String drugName,int size, int page) throws Exception{
        Envelop result = new Envelop();
        String q = "";
        StringBuffer sb = new StringBuffer();
        if(StringUtils.isNotEmpty(drugName)){
            q = "EHR_000100:*"+drugName+"* OR EHR_000131:*"+drugName+"*";
        }else{
            q = "EHR_000100:* OR EHR_000131:*";
        }
        start = start+"T00:00:00Z";
        end = end+"T00:00:00Z";
        sb.append("event_date:[").append(start).append(" TO ").append(end).append("]");
        if(StringUtils.isNotEmpty(eventType)){
            sb.append(" AND event_type:"+eventType);
        }
        String[] subfields = new String[7];
        subfields[0]="EHR_000045";
        subfields[1]="EHR_000109_VALUE";
        subfields[2]="profile_id";
        subfields[3]="EHR_000175";
        subfields[4]="EHR_000293_VALUE";
        subfields[5]="event_type";
        subfields[6]="rowkey";
        String[] fi1elds = {"rowkey","patient_name","patient_age","patient_sex","demographic_id","EHR_001211","event_date"};
        SolrDocumentList sublist = solrUtil.query(ResourceCore.SubTable,q,sb.toString(),null,(page-1)*size,size,subfields);
        if(sublist!=null && sublist.getNumFound()>0){
            for (SolrDocument doc : sublist){
                String subRowkey = String.valueOf(doc.getFieldValue("rowkey"));
                Map<String, Object> map = hBaseDao.getResultMap(ResourceCore.SubTable, subRowkey);
                if(subRowkey.indexOf("HDSD00_84")!=-1){
                    doc.put("HDSD00_04_023",map.get("EHR_000100"));//西药名称
                }else{
                    doc.put("HDSD00_04_023",map.get("EHR_000131"));//中药名称
                }
                doc.put("HDSD00_04_021",map.get("EHR_000129"));//规格
                doc.put("HDSD00_04_027",map.get("HDSD00_04_027_VALUE")+" 每次"+ map.get("EHR_000101")+
                        map.get("EHR_000133")+" "+map.get("EHR_000134"));//用法
                doc.put("HDSD00_04_028",map.get("EHR_000104"));//总量
                if("0".equals(map.get("event_type"))){
                    doc.put("fee",doc.getFieldValue("EHR_000045"));//门诊费用
                    doc.put("diagnosis",doc.getFieldValue("EHR_000109_VALUE"));//门诊诊断
                }else if("1".equals(map.get("event_type"))){
                    doc.put("fee",doc.getFieldValue("EHR_000175"));
                    doc.put("diagnosis",doc.getFieldValue("EHR_000293_VALUE"));
                }
                String q1="rowkey:"+doc.getFieldValue("profile_id");
                SolrDocumentList list = solrUtil.query(ResourceCore.MasterTable,q1,null,null,0,1,fi1elds);
                doc.putAll(list.get(0));
            }
        }
        long count = solrUtil.count(ResourceCore.SubTable, q, sb.toString());
        result.setSuccessFlg(true);
        result.setDetailModelList(sublist);
        result.setTotalCount((int)count);
        result.setCurrPage(page);
        result.setPageSize(size);
        if (result.getTotalCount() % result.getPageSize() > 0) {
            result.setTotalPage(result.getTotalCount() / result.getPageSize() + 1);
        } else {
            result.setTotalPage(result.getTotalCount() / result.getPageSize());
        }
        return result;
    }
}