|
@ -137,35 +137,72 @@ public class MedicalInsuranceService {
|
|
|
Envelop envelop = new Envelop();
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd'T'23:59:59'Z'");
|
|
|
// idCardList用来存放最近7天就诊次数大于等于3的用户身份证号码
|
|
|
HashSet<String> idCardList = new HashSet<>();
|
|
|
|
|
|
// 时间
|
|
|
Date dateTime = DateUtil.strToDate(time);
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
calendar.setTime(dateTime);
|
|
|
String endDate = DateUtil.utcToDate(calendar.getTime());
|
|
|
calendar.add(Calendar.DATE, -6);
|
|
|
String startDate = dfs.format(calendar.getTime());
|
|
|
// 设置成本月第一天
|
|
|
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());
|
|
|
|
|
|
String fq = new StringBuffer().append("event_date:[").append(startDate).append(" TO ").append(endDate).append("]").toString();
|
|
|
String demographicId = "demographic_id";
|
|
|
String[] fields = {"rowkey","patient_name","patient_age","patient_sex","demographic_id","EHR_001211","event_date"};
|
|
|
|
|
|
Map<String, Long> groupMap = solrUtil.groupCountLte(ResourceCore.MasterTable, null, fq, demographicId, 0, -1, 3);
|
|
|
for (String key : groupMap.keySet()) {
|
|
|
Map<String, Object> mapInfo = new HashMap();
|
|
|
SolrDocumentList query = solrUtil.query(ResourceCore.MasterTable, "demographic_id:" + key, fq, null, 0, 1, fields);
|
|
|
// 设置成本月第一天
|
|
|
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();
|
|
|
|
|
|
Map<String, Long> groupMap = solrUtil.groupCountLte(ResourceCore.MasterTable, null, fq, demographicId, 0, -1, 3);
|
|
|
for (String key : groupMap.keySet()) {
|
|
|
idCardList.add(key);
|
|
|
}
|
|
|
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 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("demographic_id", key);
|
|
|
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("result", groupMap.get(key));
|
|
|
mapInfo.put("address", null != query.get(0).get("EHR_001211") ? query.get(0).get("EHR_001211") : "");
|
|
|
list.add(mapInfo);
|
|
|
Map<String, Long> groupMap = solrUtil.groupCountLte(ResourceCore.MasterTable, null, fqAll, demographicId, 0, -1, 3);
|
|
|
for (String idCard : idCardList) {
|
|
|
Map<String, Object> mapInfo = new HashMap();
|
|
|
SolrDocumentList query = solrUtil.query(ResourceCore.MasterTable, "demographic_id:" + idCard, 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("demographic_id", idCard);
|
|
|
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("result", null != groupMap.get(idCard) ? groupMap.get(idCard) : 3);
|
|
|
mapInfo.put("address", null != query.get(0).get("EHR_001211") ? query.get(0).get("EHR_001211") : "");
|
|
|
list.add(mapInfo);
|
|
|
}
|
|
|
}
|
|
|
// 获取总记录数
|
|
|
int totalCount = list.size();
|
|
|
// 根据就诊次数排序
|
|
|
list = baseStatistsService.sortResultList(list, null);
|
|
|
|
|
@ -181,7 +218,7 @@ public class MedicalInsuranceService {
|
|
|
});
|
|
|
envelop.setCurrPage(page);
|
|
|
envelop.setPageSize(size);
|
|
|
envelop.setTotalCount(groupMap.size());
|
|
|
envelop.setTotalCount(totalCount);
|
|
|
envelop.setDetailModelList(list);
|
|
|
// 设置总页码数
|
|
|
if (envelop.getTotalCount() % envelop.getPageSize() > 0) {
|
|
@ -244,6 +281,28 @@ public class MedicalInsuranceService {
|
|
|
return sex;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断是否在指定时间段内
|
|
|
* @param date
|
|
|
* @param beginTime
|
|
|
* @param endTime
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean belongCalendar(Calendar date, String beginTime, String endTime) {
|
|
|
Date start = DateUtil.strToDate(beginTime, DateUtil.utcDateTimePattern);
|
|
|
Calendar begin = Calendar.getInstance();
|
|
|
begin.setTime(start);
|
|
|
|
|
|
Calendar end = Calendar.getInstance();
|
|
|
Date finish = DateUtil.strToDate(endTime, DateUtil.utcDateTimePattern);
|
|
|
end.setTime(finish);
|
|
|
|
|
|
if (date.compareTo(begin) >= 0 && date.compareTo(end) <= 0) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 用药分析
|