|
@ -9,6 +9,8 @@ import com.yihu.ehr.util.rest.Envelop;
|
|
|
import com.yihu.quota.controller.QuotaReportController;
|
|
|
import com.yihu.quota.service.quota.BaseStatistsService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.solr.client.solrj.response.PivotField;
|
|
|
import org.apache.solr.client.solrj.response.RangeFacet;
|
|
|
import org.apache.solr.common.SolrDocument;
|
|
|
import org.apache.solr.common.SolrDocumentList;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -304,6 +306,114 @@ public class MedicalInsuranceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 超高费用
|
|
|
* @param month
|
|
|
* @param inspect
|
|
|
* @param size
|
|
|
* @param page
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Envelop repeateInspect(String month, String inspect,int size, int page) throws Exception{
|
|
|
Envelop envelop = new Envelop();
|
|
|
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd'T'23:59:59'Z'");
|
|
|
String q = "";
|
|
|
if(StringUtils.isNotEmpty(inspect)){
|
|
|
q="EHR_000333:"+inspect;
|
|
|
}else{
|
|
|
q="EHR_000333:*";
|
|
|
}
|
|
|
List<Map<String,Object>> res = new ArrayList<>();
|
|
|
// 时间
|
|
|
Date dateTime = DateUtil.strToDate(month+"-01");
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
calendar.setTime(dateTime);
|
|
|
// 设置成本月第一天
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
String startDate = DateUtil.utcToDate(calendar.getTime());
|
|
|
// 设置成本月最后一天
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
String endDate = dfs.format(calendar.getTime());
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
// 遍历一个月
|
|
|
while (belongCalendar(calendar, startDate, endDate)) {
|
|
|
Calendar innerCalendar = Calendar.getInstance();
|
|
|
innerCalendar.setTime(calendar.getTime());
|
|
|
// 获取该月份下每天前后3天的就诊记录, 共7天
|
|
|
innerCalendar.add(Calendar.DATE, -3);
|
|
|
String preDate = DateUtil.utcToDate(innerCalendar.getTime());
|
|
|
innerCalendar.add(Calendar.DATE, 6);
|
|
|
String sufDate = dfs.format(innerCalendar.getTime());
|
|
|
String fq = new StringBuffer().append("event_date:[").append(preDate).append(" TO ").append(sufDate).append("]").toString();
|
|
|
List<PivotField> list = solrUtil.groupCountMult(ResourceCore.SubTable,q,fq,"EHR_000017,EHR_000333",0,-1);
|
|
|
for(PivotField pivotField:list){
|
|
|
for(PivotField child:pivotField.getPivot()){
|
|
|
if(child.getCount()>=3){
|
|
|
checkIdCard(res, pivotField.getValue()+"", child.getValue()+"", child.getCount());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
calendar.add(Calendar.DATE, 1);
|
|
|
}
|
|
|
|
|
|
// 设置查询的时间段
|
|
|
calendar.add(Calendar.DATE, 2);
|
|
|
String end = dfs.format(calendar.getTime());
|
|
|
calendar.add(Calendar.DATE, -3);
|
|
|
// 设置成本月第一天
|
|
|
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
calendar.add(Calendar.DATE, -3);
|
|
|
String start = DateUtil.utcToDate(calendar.getTime());
|
|
|
String fqAll = new StringBuffer().append("event_date:[").append(start).append(" TO ").append(end).append("]").toString();
|
|
|
String[] fields = {"rowkey","patient_name","patient_age","patient_sex","demographic_id","EHR_001211","event_date"};
|
|
|
for(Map<String,Object> mapInfo:res){
|
|
|
SolrDocumentList query = solrUtil.query(ResourceCore.MasterTable, "demographic_id:" + mapInfo.get("demographic_id"), fqAll, null, 0, 1, fields);
|
|
|
if (null != query && query.size() > 0) {
|
|
|
String rowKey = null != query.get(0).get("rowkey") ? query.get(0).get("rowkey") + "" : "";
|
|
|
String sex = null != query.get(0).get("patient_sex") ? query.get(0).get("patient_sex") + "" : "";
|
|
|
mapInfo.put("rowkey", rowKey);
|
|
|
mapInfo.put("patient_name", null != query.get(0).get("patient_name") ? query.get(0).get("patient_name") : "");
|
|
|
mapInfo.put("patient_age", null != query.get(0).get("patient_age") ? query.get(0).get("patient_age") : "");
|
|
|
mapInfo.put("patient_sex", sexExchangeByCode(sex));
|
|
|
mapInfo.put("address", null != query.get(0).get("EHR_001211") ? query.get(0).get("EHR_001211") : "");
|
|
|
}
|
|
|
}
|
|
|
// 获取总记录数
|
|
|
int totalCount = res.size();
|
|
|
|
|
|
res = res.subList((page - 1) * size, ((page - 1) * size + size) > res.size() ? res.size() : (page - 1) * size + size);
|
|
|
envelop.setCurrPage(page);
|
|
|
envelop.setPageSize(size);
|
|
|
envelop.setTotalCount(totalCount);
|
|
|
envelop.setDetailModelList(res);
|
|
|
// 设置总页码数
|
|
|
if (envelop.getTotalCount() % envelop.getPageSize() > 0) {
|
|
|
envelop.setTotalPage(envelop.getTotalCount() / envelop.getPageSize() + 1);
|
|
|
} else {
|
|
|
envelop.setTotalPage(envelop.getTotalCount() / envelop.getPageSize());
|
|
|
}
|
|
|
envelop.setSuccessFlg(true);
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
public void checkIdCard(List<Map<String,Object>> list ,String idCard, String inspectCode, int count){
|
|
|
boolean flag = false;
|
|
|
for(Map<String,Object> map: list){
|
|
|
if(idCard.equals(map.get("demographic_id"))&&inspectCode.equals(map.get("inspectCode"))){
|
|
|
map.put("result",Integer.parseInt(map.get("result")+"")+count);
|
|
|
flag=true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if(!flag){
|
|
|
Map<String,Object> resMap = new HashMap<>();
|
|
|
resMap.put("demographic_id",idCard);
|
|
|
resMap.put("inspectCode",inspectCode);
|
|
|
resMap.put("result",count);
|
|
|
list.add(resMap);
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
* 用药分析
|
|
|
* @param start
|