|
@ -22,46 +22,77 @@ public class DiseaseConvert implements Convert {
|
|
|
@Override
|
|
|
public List<DataModel> convert(JdbcTemplate jdbcTemplate, List<DataModel> oneList, String slaveLevel, WlyyDimensionQuota temp) {
|
|
|
List<DataModel> returnList = new ArrayList<>();
|
|
|
Map<String, List<String>> prescriptionDiseaseMap = new HashMap<>();//key是处方code value是处方标签 1高血压 2糖尿病
|
|
|
//初始化标签Map
|
|
|
initHealthLabesMap(jdbcTemplate, prescriptionDiseaseMap);
|
|
|
// Map<String, Object> map = initHealthLabesMap(jdbcTemplate, temp);
|
|
|
//把标签Map设置到对应的维度里面
|
|
|
for (DataModel dataModel : oneList) {
|
|
|
List<String> healthProblems = prescriptionDiseaseMap.get(dataModel.getPrescriptionCode());
|
|
|
if (healthProblems != null && healthProblems.size() > 0) {
|
|
|
healthProblems.stream().forEach(str -> {
|
|
|
try {
|
|
|
DataModel dataModelTemp = new DataModel();
|
|
|
BeanUtils.copyProperties(dataModel, dataModelTemp);
|
|
|
DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, str);
|
|
|
returnList.add(dataModelTemp);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
});
|
|
|
List<String> keyList = null;
|
|
|
for(DataModel one:oneList){
|
|
|
try {
|
|
|
keyList = initHealthLabesMap(jdbcTemplate, temp, one);
|
|
|
for(String key:keyList){
|
|
|
DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(one, key);
|
|
|
returnList.add(one);
|
|
|
}
|
|
|
}catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
|
|
|
// List<String> healthProblems = prescriptionDiseaseMap.get(dataModel.getPrescriptionCode());
|
|
|
// if (healthProblems != null && healthProblems.size() > 0) {
|
|
|
// healthProblems.stream().forEach(str -> {
|
|
|
// try {
|
|
|
// DataModel dataModelTemp = new DataModel();
|
|
|
// BeanUtils.copyProperties(dataModel, dataModelTemp);
|
|
|
// DataModel.class.getMethod("setSlaveKey" + slaveLevel, String.class).invoke(dataModelTemp, str);
|
|
|
// returnList.add(dataModelTemp);
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// });
|
|
|
// }
|
|
|
}
|
|
|
return returnList;
|
|
|
return oneList;
|
|
|
}
|
|
|
|
|
|
private void initHealthLabesMap(JdbcTemplate jdbcTemplate, Map<String, List<String>> prescriptionDiseaseMap) {
|
|
|
//得到长处方的疾病标签(只要高血压 糖尿病)
|
|
|
private List<String> initHealthLabesMap(JdbcTemplate jdbcTemplate, WlyyDimensionQuota temp,DataModel dataModel) {
|
|
|
// //得到长处方的疾病标签(只要高血压 糖尿病)
|
|
|
// String sql = "SELECT " +
|
|
|
// " health_problem ," +
|
|
|
// " prescription_code " +
|
|
|
// "FROM " +
|
|
|
// " wlyy_prescription_diagnosis " +
|
|
|
// "WHERE " +
|
|
|
// " health_problem = 'HP0047' " +
|
|
|
// "OR health_problem = 'HP0093' ";
|
|
|
// List<PrescriptionDisease> prescriptionDiseases = jdbcTemplate.query(sql, new BeanPropertyRowMapper(PrescriptionDisease.class));
|
|
|
// prescriptionDiseases.stream().forEach(one -> {
|
|
|
// List<String> labels = prescriptionDiseaseMap.get(one.getPrescriptionCode());
|
|
|
// if (labels == null) {
|
|
|
// labels = new ArrayList<String>();
|
|
|
// }
|
|
|
// labels.add(one.getHealthProblem());
|
|
|
// prescriptionDiseaseMap.put(one.getPrescriptionCode(), labels);
|
|
|
// });
|
|
|
List<String> key = new ArrayList<>();
|
|
|
String sql = "SELECT " +
|
|
|
" health_problem ," +
|
|
|
" prescription_code " +
|
|
|
"FROM " +
|
|
|
" health_problem AS healthProblem ," +
|
|
|
" prescription_code AS prescriptionCode " +
|
|
|
" FROM " +
|
|
|
" wlyy_prescription_diagnosis " +
|
|
|
"WHERE " +
|
|
|
" health_problem = 'HP0047' " +
|
|
|
"OR health_problem = 'HP0093' ";
|
|
|
List<PrescriptionDisease> prescriptionDiseases = jdbcTemplate.query(sql, new BeanPropertyRowMapper(PrescriptionDisease.class));
|
|
|
prescriptionDiseases.stream().forEach(one -> {
|
|
|
List<String> labels = prescriptionDiseaseMap.get(one.getPrescriptionCode());
|
|
|
if (labels == null) {
|
|
|
labels = new ArrayList<String>();
|
|
|
}
|
|
|
labels.add(one.getHealthProblem());
|
|
|
prescriptionDiseaseMap.put(one.getPrescriptionCode(), labels);
|
|
|
});
|
|
|
" WHERE " +
|
|
|
" prescription_code = '"+dataModel.getPrescriptionCode() +"'";
|
|
|
List<Map<String, Object>> diagnosisList =jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String, Object>> dictList = jdbcTemplate.queryForList(temp.getDictSql());
|
|
|
for (Map<String, Object> map:diagnosisList){
|
|
|
// String diagnosis = map.get("healthProblem")+"";
|
|
|
// for(Map<String, Object> dict:dictList){
|
|
|
// if(diagnosis.equals(dict.get("code"))){
|
|
|
// key.add()
|
|
|
// }
|
|
|
// }
|
|
|
key.add(map.get("healthProblem").toString());
|
|
|
}
|
|
|
return key;
|
|
|
}
|
|
|
}
|