zhengwei 6 rokov pred
rodič
commit
a19240381f

+ 56 - 7
src/main/java/com/yihu/quota/service/medicalInsurance/MedicalInsuranceService.java

@ -5,7 +5,9 @@ import com.yihu.ehr.profile.core.ResourceCore;
import com.yihu.ehr.solr.SolrUtil;
import com.yihu.ehr.util.datetime.DateUtil;
import com.yihu.ehr.util.rest.Envelop;
import com.yihu.quota.controller.QuotaReportController;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,6 +15,10 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * @Author: zhengwei
 * @Date: 2018/9/19 20:35
@ -26,7 +32,8 @@ public class MedicalInsuranceService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private QuotaReportController quotaReportController;
    /**
     * 超高费用
     * @param month
@ -46,28 +53,50 @@ public class MedicalInsuranceService {
        String start = month+"-01T00:00:00Z";
        String end = DateUtil.getLastDate(month+"-01","yyyy-MM-dd","yyyy-MM-dd")+"T23:59:59Z";
        String[] subfields = new String[3];
        if("0".equals(eventType)){
            fee=3000;
        String endDate = DateUtil.getLastDateOfLashMonth(month+"-01","yyyy-MM-dd","yyyy-MM-dd");
        String lastmonth=endDate.substring(0,7);//上月
        String startDate=lastmonth+"-01";
        String filters = "quotaDate >='"+startDate+"' and quotaDate <='"+endDate+"'";
        if("0".equals(eventType)){//门诊
            //获取门诊次均费用
            List<Map<String, Object>> ls= quotaReportController.getQuotaReportTwoDimensionalTable("HC_07_1001",filters,"month","");
            for(Map<String, Object> map:ls){
                if(lastmonth.equals(map.get("month"))){
                    fee=Double.parseDouble(map.get("HC_07_1001")+"")*5;
                    break;
                }
            }
            sb.append("EHR_000045:[").append(fee).append(" TO *]").append(" AND event_date:[")
                    .append(start).append(" TO ").append(end).append("]");
            subfields[0]="EHR_000045";
            subfields[1]="EHR_000109_VALUE";
            subfields[2]="profile_id";
        }else{
            fee=20000;
        }else{//住院
            //获取住院次均费用
            List<Map<String, Object>> ls= quotaReportController.getQuotaReportTwoDimensionalTable("HC_07_1002",filters,"month","");
            for(Map<String, Object> map:ls){
                if(lastmonth.equals(map.get("month"))){
                    fee=Double.parseDouble(map.get("HC_07_1002")+"")*5;
                    break;
                }
            }
            sb.append("EHR_000175:[").append(fee).append(" TO *]").append(" AND event_date:[")
                    .append(start).append(" TO ").append(end).append("]");
            subfields[0]="EHR_000175";
            subfields[1]="EHR_000293_VALUE";
            subfields[2]="profile_id";
        }
        if(StringUtils.isNotEmpty(hosLevel)||StringUtils.isNotEmpty(hosHierarchy)){
            String orgCode=getOrgCode(hosLevel,hosHierarchy);
            sb.append(" AND org_code:(").append(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);
        if(sublist!=null && sublist.getNumFound()>0){
            for (SolrDocument doc : sublist){
                if("0".equals(eventType)){
                    doc.put("fee",doc.getFieldValue("EHR_000045"));
                    doc.put("diagnosis",doc.getFieldValue("EHR_000109_VALUE"));
                    doc.put("fee",doc.getFieldValue("EHR_000045"));//门诊费用
                    doc.put("diagnosis",doc.getFieldValue("EHR_000109_VALUE"));//门诊诊断
                }else{
                    doc.put("fee",doc.getFieldValue("EHR_000175"));
                    doc.put("diagnosis",doc.getFieldValue("EHR_000293_VALUE"));
@ -91,4 +120,24 @@ public class MedicalInsuranceService {
        return result;
    }
    private String getOrgCode(String hosLevel, String hosHierarchy){
        String orgCode="";
        StringBuffer sql = new StringBuffer();
        sql.append("select org_code from organizations where org_type='Hospital' ");
        if(StringUtils.isNotEmpty(hosLevel)){
            sql.append(" and level_id ="+hosLevel);
        }
        if(StringUtils.isNotEmpty(hosHierarchy)){
            sql.append(" and hos_hierarchy ="+hosHierarchy);
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql.toString());
        if(!list.isEmpty()){
            for(Map<String, Object> map:list){
                orgCode+=map.get("ORG_CODE")+" ";
            }
            orgCode=orgCode.substring(0,orgCode.length()-1);
        }
        return orgCode;
    }
}