|
@ -62,14 +62,16 @@ public class OutPatientCostScheduler {
|
|
|
String q = "EHR_000109:*"; // 查询条件 诊断代码(门诊)
|
|
|
String sQuery = "EHR_000045:* AND profile_id:";
|
|
|
String sQuery2 = "EHR_000109:* AND profile_id:";
|
|
|
String sQuery3 = "EHR_000051:* AND profile_id:";
|
|
|
|
|
|
String keyEventDate = "event_date";
|
|
|
String keyArea = "org_area"; // 行政区划代码 EHR_001225
|
|
|
String keyDisease = "EHR_000109"; // 诊断代码(门诊)
|
|
|
String keyDiseaseName = "EHR_000112"; // 诊断名称(门诊)
|
|
|
String keyPayCode = "EHR_000051"; // 支付代码
|
|
|
String keyCost = "EHR_000045"; // 门诊费用金额(元)
|
|
|
// 抽取并保存到ES
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyCost, 1);
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, sQuery3, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyPayCode, keyCost, 1);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@ -88,14 +90,16 @@ public class OutPatientCostScheduler {
|
|
|
String q = "EHR_000293:*"; // 查询条件 诊断代码(住院)
|
|
|
String sQuery = "EHR_000175:* AND profile_id:";
|
|
|
String sQuery2 = "EHR_000293:* AND profile_id:";
|
|
|
String sQuery3 = "EHR_000180:* AND profile_id:";
|
|
|
|
|
|
String keyEventDate = "event_date";
|
|
|
String keyArea = "org_area"; // 行政区划代码
|
|
|
String keyDisease = "EHR_000293"; // 诊断代码(住院)
|
|
|
String keyDiseaseName = "EHR_000295"; // 诊断名称(住院)
|
|
|
String keyPayCode = "EHR_000180"; // 支付代码
|
|
|
String keyCost = "EHR_000175"; // 门诊费用金额(元)
|
|
|
// 抽取并保存到ES
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyCost, 3);
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, sQuery3, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyPayCode, keyCost, 3);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
@ -115,14 +119,16 @@ public class OutPatientCostScheduler {
|
|
|
String q = "EHR_000293:*"; // 查询条件 诊断代码(住院)
|
|
|
String sQuery = "EHR_000175:* AND profile_id:";
|
|
|
String sQuery2 = "EHR_000293:* AND profile_id:";
|
|
|
String sQuery3 = "EHR_000180:* AND profile_id:";
|
|
|
|
|
|
String keyEventDate = "event_date";
|
|
|
String keyArea = "org_area"; // 行政区划代码
|
|
|
String keyDisease = "EHR_000293"; // 诊断代码(住院)
|
|
|
String keyDiseaseName = "EHR_000295"; // 诊断名称(住院)
|
|
|
String keyPayCode = "EHR_000180"; // 支付代码
|
|
|
String keyCost = "EHR_000175"; // 门诊费用金额(元)
|
|
|
// 抽取并保存到ES
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyCost, 3);
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, sQuery3, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyPayCode, keyCost, 3);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
envelop.setSuccessFlg(false);
|
|
@ -145,14 +151,16 @@ public class OutPatientCostScheduler {
|
|
|
String q = "EHR_000109:*"; // 查询条件 诊断代码(门诊)
|
|
|
String sQuery = "EHR_000045:* AND profile_id:";
|
|
|
String sQuery2 = "EHR_000109:* AND profile_id:";
|
|
|
String sQuery3 = "EHR_000051:* AND profile_id:";
|
|
|
|
|
|
String keyEventDate = "event_date";
|
|
|
String keyArea = "org_area"; // 行政区划代码 EHR_001225
|
|
|
String keyDisease = "EHR_000109"; // 诊断代码(门诊)
|
|
|
String keyDiseaseName = "EHR_000112"; // 诊断名称(门诊)
|
|
|
String keyPayCode = "EHR_000051"; // 支付代码
|
|
|
String keyCost = "EHR_000045"; // 门诊费用金额(元)
|
|
|
// 抽取并保存到ES
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyCost, 1);
|
|
|
saveDiseaseExpenseData(fq, q, sQuery, sQuery2, sQuery3, keyEventDate, keyArea, keyDisease, keyDiseaseName, keyPayCode, keyCost, 1);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
envelop.setSuccessFlg(false);
|
|
@ -161,18 +169,36 @@ public class OutPatientCostScheduler {
|
|
|
return envelop;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 存储到es, index:hospitalCost(别名)
|
|
|
*
|
|
|
* @param costInfo
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveToEs(Map<String, Object> costInfo) throws Exception {
|
|
|
String index = "hospitalCost";
|
|
|
String type = "cost_info";
|
|
|
long start = System.currentTimeMillis();
|
|
|
log.info("开始保存时间 = {}", costInfo, start);
|
|
|
elasticSearchUtil.index(index, type, costInfo);
|
|
|
long end = System.currentTimeMillis();
|
|
|
log.info("用时 = {}毫秒", end - start);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 抽取疾病费用并保存到ES
|
|
|
*
|
|
|
* @param fq
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
private void saveDiseaseExpenseData(String fq, String q, String sQuery, String sQuery2, String keyEventDate, String keyArea,
|
|
|
String keyDisease, String keyDiseaseName, String keyCost, Integer type) throws Exception {
|
|
|
private void saveDiseaseExpenseData(String fq, String q, String sQuery, String sQuery2, String sQuery3, String keyEventDate, String keyArea,
|
|
|
String keyDisease, String keyDiseaseName, String keyPayCode, String keyCost, Integer type) throws Exception {
|
|
|
|
|
|
String sq = "";
|
|
|
String sq2 = "";
|
|
|
String sq3 = "";
|
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
|
|
List<String> profileIdList = new ArrayList<>() ;
|
|
|
List<String> profileIdList = new ArrayList<>();
|
|
|
|
|
|
profileIdList.clear();
|
|
|
|
|
@ -181,30 +207,32 @@ public class OutPatientCostScheduler {
|
|
|
long count = solrUtil.count(ResourceCore.SubTable, q, fq);
|
|
|
// 细表中查询EHR_000109:* 的记录, 返回细表的profile_id
|
|
|
profileIdList = selectSubProfileId(ResourceCore.SubTable, q, fq, count < 1000 ? 1000 : count);
|
|
|
if(profileIdList != null && profileIdList.size() > 0) {
|
|
|
if (profileIdList != null && profileIdList.size() > 0) {
|
|
|
for (String profileId : profileIdList) {
|
|
|
sq = sQuery + profileId; // EHR_000045:* AND profile_id:xx
|
|
|
sq2 = sQuery2 + profileId; // 查询疾病编码
|
|
|
sq3 = sQuery3 + profileId;
|
|
|
List<String> keyList = healthArchiveSchedulerService.selectSubRowKey(ResourceCore.SubTable, sq2, fq, count < 1000 ? 1000 : count);
|
|
|
if (keyList != null && keyList.size() > 0) {
|
|
|
Double value = 0.0;
|
|
|
Map<String, String> diseaseName = new HashMap<>();
|
|
|
Map<String, String> rowKeyName = new HashMap<>();
|
|
|
Map<String, String> payWayCode = new HashMap<>();
|
|
|
List<Map<String, Object>> dataList = healthArchiveSchedulerService.selectHbaseData(ResourceCore.SubTable, keyList);
|
|
|
if (dataList != null && dataList.size() > 0) {
|
|
|
for(Map<String, Object> map : dataList) {
|
|
|
for (Map<String, Object> map : dataList) {
|
|
|
diseaseName.put(map.get(keyDisease) + "", map.get(keyDiseaseName) + "");
|
|
|
rowKeyName.put(map.get(keyDisease) + "", map.get("rowkey") + "");
|
|
|
}
|
|
|
List<String> rowKeyList = healthArchiveSchedulerService.selectSubRowKey(ResourceCore.SubTable, sq, fq, count < 1000 ? 1000 : count);
|
|
|
if(rowKeyList != null && rowKeyList.size() > 0) {
|
|
|
if (rowKeyList != null && rowKeyList.size() > 0) {
|
|
|
String town = "";
|
|
|
String org = "";
|
|
|
String dept = "";
|
|
|
String eventDate = "";
|
|
|
List<Map<String,Object>> hbaseDataList = healthArchiveSchedulerService.selectHbaseData(ResourceCore.SubTable, rowKeyList);
|
|
|
if( hbaseDataList != null && hbaseDataList.size() > 0 ) {
|
|
|
for(Map<String,Object> map : hbaseDataList) {
|
|
|
List<Map<String, Object>> hbaseDataList = healthArchiveSchedulerService.selectHbaseData(ResourceCore.SubTable, rowKeyList);
|
|
|
if (hbaseDataList != null && hbaseDataList.size() > 0) {
|
|
|
for (Map<String, Object> map : hbaseDataList) {
|
|
|
if (StringUtils.isEmpty(town) && null != map.get(keyArea)) {
|
|
|
town = map.get(keyArea).toString();
|
|
|
}
|
|
@ -220,6 +248,13 @@ public class OutPatientCostScheduler {
|
|
|
value += Double.parseDouble(null != map.get(keyCost) ? map.get(keyCost) + "" : "0");
|
|
|
}
|
|
|
}
|
|
|
List<String> payWayList = healthArchiveSchedulerService.selectSubRowKey(ResourceCore.SubTable, sq3, fq, count < 1000 ? 1000 : count);
|
|
|
if (null != payWayList && payWayList.size() > 0) {
|
|
|
List<Map<String, Object>> payWayHList = healthArchiveSchedulerService.selectHbaseData(ResourceCore.SubTable, payWayList);
|
|
|
if (null != payWayHList && payWayHList.size() > 0) {
|
|
|
payWayCode.put(profileId, payWayHList.get(0).get(keyPayCode) + "");
|
|
|
}
|
|
|
}
|
|
|
String valueStr = value == 0 ? value.toString() : df.format(value);
|
|
|
for (Map.Entry<String, String> m : diseaseName.entrySet()) {
|
|
|
Map<String, Object> costInfo = new HashMap<>();
|
|
@ -231,6 +266,7 @@ public class OutPatientCostScheduler {
|
|
|
costInfo.put("town", town);
|
|
|
costInfo.put("org", org);
|
|
|
costInfo.put("dept", dept);
|
|
|
costInfo.put("payCode", payWayCode.get(profileId));
|
|
|
costInfo.put("eventDate", DateUtil.formatCharDate(eventDate, DateUtil.DATE_WORLD_FORMAT));
|
|
|
costInfo.put("createTime", new Date());
|
|
|
|
|
@ -244,28 +280,13 @@ public class OutPatientCostScheduler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 存储到es, index:hospitalCost(别名)
|
|
|
* @param costInfo
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveToEs(Map<String, Object> costInfo) throws Exception {
|
|
|
String index = "hospitalCost";
|
|
|
String type = "cost_info";
|
|
|
long start = System.currentTimeMillis();
|
|
|
log.info("开始保存时间 = {}", costInfo, start);
|
|
|
elasticSearchUtil.index(index, type, costInfo);
|
|
|
long end = System.currentTimeMillis();
|
|
|
log.info("用时 = {}毫秒", end - start);
|
|
|
}
|
|
|
|
|
|
// 获取查询结果中的profile_id
|
|
|
private List<String> selectSubProfileId(String core , String q, String fq, long count) throws Exception {
|
|
|
private List<String> selectSubProfileId(String core, String q, String fq, long count) throws Exception {
|
|
|
List<String> data = new ArrayList<>();
|
|
|
/***** Solr查询 ********/
|
|
|
SolrDocumentList solrList = solrUtil.query(core, q , fq, null, 0, count);
|
|
|
if(solrList != null && solrList.getNumFound() > 0) {
|
|
|
for (SolrDocument doc : solrList){
|
|
|
SolrDocumentList solrList = solrUtil.query(core, q, fq, null, 0, count);
|
|
|
if (solrList != null && solrList.getNumFound() > 0) {
|
|
|
for (SolrDocument doc : solrList) {
|
|
|
String rowkey = String.valueOf(doc.getFieldValue("profile_id"));
|
|
|
data.add(rowkey);
|
|
|
}
|
|
@ -274,7 +295,7 @@ public class OutPatientCostScheduler {
|
|
|
data.clear();
|
|
|
data.addAll(hashSet);
|
|
|
}
|
|
|
return data;
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
}
|