package com.diagbot.facade; import com.diagbot.biz.push.entity.Item; import com.diagbot.biz.push.entity.Lis; import com.diagbot.client.CRFServiceClient; import com.diagbot.client.StandConvertServiceClient; import com.diagbot.dto.*; import com.diagbot.enums.ConceptTypeEnum; import com.diagbot.enums.LexiconEnum; import com.diagbot.enums.RedisEnum; import com.diagbot.enums.StandConvertEnum; import com.diagbot.exception.CommonErrorCode; import com.diagbot.exception.CommonException; import com.diagbot.model.ai.AIAnalyze; import com.diagbot.model.entity.Operation; import com.diagbot.model.entity.*; import com.diagbot.model.label.*; import com.diagbot.rule.CommonRule; import com.diagbot.util.*; import com.diagbot.vo.*; import com.diagbot.vo.neoPushEntity.Diag; import com.diagbot.vo.neoPushEntity.Drug; import com.diagbot.vo.neoPushEntity.*; import com.google.common.collect.Lists; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.lang.reflect.Method; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; /** * @Description: 通过业务facade * @author: zhoutg * @time: 2018/8/6 9:11 */ @Component public class CommonFacade { @Autowired CRFServiceClient crfServiceClient; @Autowired MappingConfigFacade mappingConfigFacade; @Autowired TranOperationConfigFacade tranOperationConfigFacade; @Autowired CommonRule commonRule; @Autowired RedisUtil redisUtil; @Autowired NLPFacade nlpFacade; @Autowired StandConvertServiceClient standConvertServiceClient; @Value("${StandConvert.rate}") String standConvertRate; /** * 组装好label * * @param searchData * @param participleFlag * @return */ public WordCrfDTO crf_process(SearchData searchData, Boolean participleFlag) { AIAnalyze aiAnalyze = new AIAnalyze(crfServiceClient); // 合并既往史:既往史+传染病史+手术外伤史+过敏史+接种史 String unionPasts = searchData.getPasts(); if (StringUtil.isNotBlank(searchData.getInfectious())) { // 传染病史 unionPasts = unionPasts + "。" + searchData.getInfectious(); } if (StringUtil.isNotBlank(searchData.getSurgical())) { // 手术外伤史 unionPasts = unionPasts + "。" + searchData.getSurgical(); } if (StringUtil.isNotBlank(searchData.getAllergy())) { // 过敏史 unionPasts = unionPasts + "。" + searchData.getAllergy(); } if (StringUtil.isNotBlank(searchData.getVaccination())) { // 接种史 unionPasts = unionPasts + "。" + searchData.getVaccination(); } searchData.setPasts(unionPasts); WordCrfDTO wordCrfDTO = new WordCrfDTO(); wordCrfDTO.setHospitalId(searchData.getHospitalId()); // 年龄容错处理 if (searchData.getAgeNum() != null) { wordCrfDTO.setAgeNum(searchData.getAgeNum()); } else { wordCrfDTO.setAgeNum(CoreUtil.convertAge(searchData.getAge())); } wordCrfDTO.setAge(searchData.getAge()); wordCrfDTO.setSex(searchData.getSex()); wordCrfDTO.setDept(searchData.getDept()); if (searchData.getDiseaseName() != null && StringUtils.isNotBlank(searchData.getDiseaseName().getName())) { wordCrfDTO.setDiseaseName(searchData.getDiseaseName()); } if (searchData.getOperationName() != null && StringUtils.isNotBlank(searchData.getOperationName().getName())) { wordCrfDTO.setOperationName(searchData.getOperationName()); } if (ListUtil.isNotEmpty(searchData.getLis())) { wordCrfDTO.setLis(searchData.getLis()); } if (ListUtil.isNotEmpty(searchData.getPacs())) { wordCrfDTO.setPacs(searchData.getPacs()); } if (ListUtil.isNotEmpty(searchData.getDrug())) { wordCrfDTO.setDrug(searchData.getDrug()); } if (ListUtil.isNotEmpty(searchData.getTransfusion())) { wordCrfDTO.setTransfusion(searchData.getTransfusion()); } if (ListUtil.isNotEmpty(searchData.getOperation())) { wordCrfDTO.setOperation(searchData.getOperation()); } if (ListUtil.isNotEmpty(searchData.getLisOrder())) { wordCrfDTO.setLisOrder(searchData.getLisOrder()); } if (ListUtil.isNotEmpty(searchData.getPacsOrder())) { wordCrfDTO.setPacsOrder(searchData.getPacsOrder()); } if (ListUtil.isNotEmpty(searchData.getDrugOrder())) { wordCrfDTO.setDrugOrder(searchData.getDrugOrder()); } if (ListUtil.isNotEmpty(searchData.getOperationOrder())) { wordCrfDTO.setOperationOrder(searchData.getOperationOrder()); } if (ListUtil.isNotEmpty(searchData.getDiagOrder())) { wordCrfDTO.setDiagOrder(searchData.getDiagOrder()); } if (ListUtil.isNotEmpty(searchData.getDiag())) { wordCrfDTO.setDiag(searchData.getDiag()); } if (ListUtil.isNotEmpty(searchData.getTransfusionOrder())) { wordCrfDTO.setTransfusionOrder(searchData.getTransfusionOrder()); } if (StringUtil.isNotBlank(searchData.getSymptom())) { wordCrfDTO.setSymptom(searchData.getSymptom()); } if (StringUtil.isNotBlank(searchData.getChief())) { wordCrfDTO.setChief(searchData.getChief()); } if (StringUtil.isNotBlank(unionPasts)) { wordCrfDTO.setPasts(unionPasts); } if (StringUtil.isNotBlank(searchData.getMenstrual())) { wordCrfDTO.setMenstrual(searchData.getMenstrual()); } if (StringUtil.isNotBlank(searchData.getFamily())) { wordCrfDTO.setFamily(searchData.getFamily()); } if (StringUtil.isNotBlank(searchData.getMarital())) { wordCrfDTO.setMarital(searchData.getMarital()); } if (StringUtil.isNotBlank(searchData.getMarriage())) { wordCrfDTO.setMarriage(searchData.getMarriage()); } if (StringUtil.isNotBlank(searchData.getPersonal())) { wordCrfDTO.setPersonal(searchData.getPersonal()); } if (StringUtil.isNotBlank(searchData.getVital())) { wordCrfDTO.setVital(searchData.getVital()); } // 模型处理数据 aiAnalyze.aiProcess(searchData, wordCrfDTO); // 统一处理化验、辅检、诊断,放入结构化 processLisPacsDiag(wordCrfDTO); // 现病史的体征内容放入体征标签 processPresentVital(wordCrfDTO); // 加入分词 if (participleFlag) { participle(wordCrfDTO); } return wordCrfDTO; } /** * 分词 * * @param wordCrfDTO */ public void participle(WordCrfDTO wordCrfDTO) { // 主诉症状分词 participleByType(wordCrfDTO.getChiefLabel().getClinicals(), String.valueOf(LexiconEnum.Symptom.getKey())); // 现病史症状分词 participleByType(wordCrfDTO.getPresentLabel().getClinicals(), String.valueOf(LexiconEnum.Symptom.getKey())); } /** * 根据类型分词,通用方法 * * @param tList * @param type * @param */ public void participleByType(List tList, String type) { List participleList = Lists.newArrayList(); if (ListUtil.isNotEmpty(tList)) { for (T t : tList) { String val = ReflectUtil.getProperty(t, "name"); List list = nlpFacade.getByType(val, type); if (ListUtil.isNotEmpty(list)) { for (String s : list) { if (!s.equals(val)) { // 去除自身 try { T tNew = (T) tList.get(0).getClass().newInstance(); // 泛型不能直接创建对象 BeanUtil.copyProperties(t, tNew); ReflectUtil.setProperty(tNew, "name", s); ReflectUtil.setProperty(tNew, "standName", s); participleList.add(tNew); } catch (Exception e) { e.printStackTrace(); } } } } } if (ListUtil.isNotEmpty(participleList)) { tList.addAll(participleList); } } } /** * 同义词转换 * * @param wordCrfDTO */ public void wordStandConvert(WordCrfDTO wordCrfDTO) { StandConvert standConvert = dataTypeGet(wordCrfDTO); Map> standConvertMap = standConvertCrf(standConvert); dataTypeSet(wordCrfDTO, standConvertMap); } /** * 获取所有需要转标准词的词 * * @param wordCrfDTO * @return */ public StandConvert dataTypeGet(WordCrfDTO wordCrfDTO) { StandConvert standConvert = new StandConvert(); // 【所有症状】(主诉、现病史) List clinicalList = new ArrayList<>(); ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel(); CoreUtil.addList(clinicalList, CoreUtil.getPropertyList(chiefLabel.getClinicals())); PresentLabel presentLabel = wordCrfDTO.getPresentLabel(); CoreUtil.addList(clinicalList, CoreUtil.getPropertyList(presentLabel.getClinicals())); standConvert.setClinicalList(clinicalList); // 【所有疾病】 DiagLabel diagLabel = wordCrfDTO.getDiagLabel(); PastLabel pastLabel = wordCrfDTO.getPastLabel(); List diagList = new ArrayList<>(); // 1、主诉诊断 CoreUtil.addList(diagList, CoreUtil.getPropertyList(chiefLabel.getDiags())); // 2、现病史诊断 CoreUtil.addList(diagList, CoreUtil.getPropertyList(presentLabel.getDiags())); // 3、文本诊断 CoreUtil.addList(diagList, CoreUtil.getPropertyList(diagLabel.getDiags())); // 4、既往史诊断 CoreUtil.addList(diagList, CoreUtil.getPropertyList(pastLabel.getDiags())); // 5、开单项诊断 CoreUtil.addList(diagList, CoreUtil.filterUniqueList(wordCrfDTO.getDiagOrder())); // 6、结构化诊断 CoreUtil.addList(diagList, CoreUtil.filterUniqueList(wordCrfDTO.getDiag())); // 7、选中诊断 if (wordCrfDTO.getDiseaseName() != null && StringUtils.isBlank(wordCrfDTO.getDiseaseName().getUniqueName())) { diagList.add(wordCrfDTO.getDiseaseName().getName()); } standConvert.setDiaglList(diagList); // // 【所有化验】 // List allLis = new ArrayList<>(); // // 1、普通化验——取明细 // CoreUtil.addList(allLis, CoreUtil.filterUniqueList(wordCrfDTO.getLis(), "detailName")); // // 2、开单化验——取套餐 // CoreUtil.addList(allLis, CoreUtil.filterUniqueList(wordCrfDTO.getLisOrder())); // standConvert.setLisList(allLis); // // // 【所有辅助项目】 // List allPacs = new ArrayList<>(); // // 1、模型解析辅检项目 // CoreUtil.addList(allPacs, CoreUtil.filterUniqueList(wordCrfDTO.getPacsLabel().getItem())); // // 2、结构化辅检项目 // CoreUtil.addList(allPacs, CoreUtil.filterUniqueList(wordCrfDTO.getPacs())); // // 3、开单辅检项目 // CoreUtil.addList(allPacs, CoreUtil.filterUniqueList(wordCrfDTO.getPacsOrder())); // standConvert.setPacsList(allPacs); // 【所有药品】 List drugList = new ArrayList<>(); // 1、主诉药品 CoreUtil.addList(drugList, CoreUtil.getPropertyList(chiefLabel.getMedicines())); // 2、现病史药品 CoreUtil.addList(drugList, CoreUtil.getPropertyList(presentLabel.getMedicines())); // 3、既往史(药物过敏) CoreUtil.addList(drugList, CoreUtil.getPropertyList(pastLabel.getAllergyMedicines())); // 4、既往史(药物) CoreUtil.addList(drugList, CoreUtil.getPropertyList(pastLabel.getMedicines())); // 5、开单药品 CoreUtil.addList(drugList, CoreUtil.filterUniqueList(wordCrfDTO.getDrugOrder())); // 6、结构化药品 CoreUtil.addList(drugList, CoreUtil.filterUniqueList(wordCrfDTO.getDrug())); standConvert.setDrugList(drugList); // // 【所有手术】 // List operationList = new ArrayList<>(); // // 1、主诉手术 // CoreUtil.addList(operationList, CoreUtil.getPropertyList(chiefLabel.getOperations())); // // 2、现病史手术 // CoreUtil.addList(operationList, CoreUtil.getPropertyList(presentLabel.getOperations())); // // 3、既往史手术 // CoreUtil.addList(operationList, CoreUtil.getPropertyList(pastLabel.getOperations())); // // 4、开单手术 // CoreUtil.addList(operationList, CoreUtil.filterUniqueList(wordCrfDTO.getOperationOrder())); // // 5、结构化手术 // CoreUtil.addList(operationList, CoreUtil.filterUniqueList(wordCrfDTO.getOperation())); // // 6、选中手术 // if (wordCrfDTO.getOperationName() != null && StringUtils.isBlank(wordCrfDTO.getOperationName().getUniqueName())) { // operationList.add(wordCrfDTO.getOperationName().getName()); // } // standConvert.setOperationList(operationList); // 【所有体征】(临床表现、体征结果) List vitalList = new ArrayList<>(); VitalLabel vitalLabel = wordCrfDTO.getVitalLabel(); CoreUtil.addList(vitalList, CoreUtil.getPropertyList(vitalLabel.getVitals())); CoreUtil.addList(vitalList, CoreUtil.getPropertyList(vitalLabel.getClinicals())); standConvert.setVitalList(vitalList); // 【输血】 List transfusionList = new ArrayList<>(); CoreUtil.addList(transfusionList, CoreUtil.filterUniqueList(wordCrfDTO.getTransfusionOrder())); standConvert.setTransfusionList(transfusionList); return standConvert; } /** * 标准词set到label中 * * @param wordCrfDTO * @param map */ public void dataTypeSet(WordCrfDTO wordCrfDTO, Map> map) { ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel(); PresentLabel presentLabel = wordCrfDTO.getPresentLabel(); PastLabel pastLabel = wordCrfDTO.getPastLabel(); DiagLabel diagLabel = wordCrfDTO.getDiagLabel(); List lis = wordCrfDTO.getLis(); List pacsList = wordCrfDTO.getPacsLabel().getItem(); VitalLabel vitalLabel = wordCrfDTO.getVitalLabel(); // 【症状回填】 // CoreUtil.setPropertyList(chiefLabel.getClinicals(), map.get(StandConvertEnum.symptom.toString())); // CoreUtil.setPropertyList(presentLabel.getClinicals(), map.get(StandConvertEnum.symptom.toString())); // 【诊断回填】 // 1、主诉诊断 CoreUtil.setPropertyList(chiefLabel.getDiags(), map.get(StandConvertEnum.disease.toString())); // 2、现病史诊断 CoreUtil.setPropertyList(presentLabel.getDiags(), map.get(StandConvertEnum.disease.toString())); // 3、文本诊断 CoreUtil.setPropertyList(diagLabel.getDiags(), map.get(StandConvertEnum.disease.toString())); // 4、既往史诊断 CoreUtil.setPropertyList(pastLabel.getDiags(), map.get(StandConvertEnum.disease.toString())); // 5、开单项诊断 CoreUtil.setPropertyList(wordCrfDTO.getDiagOrder(), "name", "uniqueName", map.get(StandConvertEnum.disease.toString())); // 6、结构化诊断 CoreUtil.setPropertyList(wordCrfDTO.getDiag(), "name", "uniqueName", map.get(StandConvertEnum.disease.toString())); // 7、选中诊断 CoreUtil.setPropertyList(wordCrfDTO.getDiseaseName(), "name", "uniqueName", map.get(StandConvertEnum.disease.toString())); // 【药品回填】 // 1、主诉药品 CoreUtil.setPropertyList(chiefLabel.getMedicines(), map.get(StandConvertEnum.drug.toString())); // 2、现病史药品 CoreUtil.setPropertyList(presentLabel.getMedicines(), map.get(StandConvertEnum.drug.toString())); // 3、既往史(药物过敏) CoreUtil.setPropertyList(pastLabel.getAllergyMedicines(), map.get(StandConvertEnum.drug.toString())); // 4、既往史(药物) CoreUtil.setPropertyList(pastLabel.getMedicines(), map.get(StandConvertEnum.drug.toString())); // 5、开单药品 CoreUtil.setPropertyList(wordCrfDTO.getDrugOrder(), "name", "uniqueName", map.get(StandConvertEnum.drug.toString())); // 6、结构化药品 CoreUtil.setPropertyList(wordCrfDTO.getDrug(), "name", "uniqueName", map.get(StandConvertEnum.drug.toString())); // // 【化验回填】 // // 1、普通化验 // CoreUtil.setPropertyList(lis, "detailName", "uniqueName", map.get(StandConvertEnum.lis.toString())); // // 2、开单化验——取套餐 // CoreUtil.setPropertyList(wordCrfDTO.getLisOrder(), "name", "uniqueName", map.get(StandConvertEnum.lis.toString())); // // // 【辅助项目回填】 // // 1、模型解析辅检项目 // CoreUtil.setPropertyList(pacsList, "name", "uniqueName", map.get(StandConvertEnum.pacs.toString())); // // 2、结构化辅检项目 // CoreUtil.setPropertyList(wordCrfDTO.getPacs(), "name", "uniqueName", map.get(StandConvertEnum.pacs.toString())); // // 3、开单辅检项目 // CoreUtil.setPropertyList(wordCrfDTO.getPacsOrder(), "name", "uniqueName", map.get(StandConvertEnum.pacs.toString())); // CoreUtil.setUninameFromDetail(wordCrfDTO.getLis(), "detailName"); // CoreUtil.setUninameFromDetail(wordCrfDTO.getLisOrder(), "name"); lisGetAndSet(wordCrfDTO); pacsGetAndSet(wordCrfDTO); // 【体征回填】 // CoreUtil.setPropertyList(vitalLabel.getVitals(), map.get(StandConvertEnum.vital.toString())); // CoreUtil.setPropertyList(vitalLabel.getClinicals(), map.get(StandConvertEnum.vital.toString())); // 【手术回填】 // 1、主诉手术 // CoreUtil.setPropertyList(chiefLabel.getOperations(), map.get(StandConvertEnum.operation.toString())); // // 2、现病史手术 // CoreUtil.setPropertyList(presentLabel.getOperations(), map.get(StandConvertEnum.operation.toString())); // // 3、既往史手术 // CoreUtil.setPropertyList(pastLabel.getOperations(), map.get(StandConvertEnum.operation.toString())); // // 4、开单手术 // CoreUtil.setPropertyList(wordCrfDTO.getOperationOrder(), "name", "uniqueName", map.get(StandConvertEnum.operation.toString())); // // 5、结构化手术 // CoreUtil.setPropertyList(wordCrfDTO.getOperation(), "name", "uniqueName", map.get(StandConvertEnum.operation.toString())); // // 6、选中手术 // CoreUtil.setPropertyList(wordCrfDTO.getOperationName(), "name", "uniqueName", map.get(StandConvertEnum.operation.toString())); operateGetAndSet(wordCrfDTO); //【输血回填】 CoreUtil.setPropertyList(wordCrfDTO.getTransfusionOrder(), "name", "uniqueName", map.get(StandConvertEnum.transfusion.toString())); } /** * 标准词转换 * 类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 辅助检查:vital" * * @param standConvert * @return Map> -->Map<类型, Map<原始词, 标准词>> */ public Map> standConvertCrf(StandConvert standConvert) { Map> map = new LinkedHashMap<>(); List standConvertCrfVOList = new ArrayList<>(); List clinicalConList = getConvertList(standConvert.getClinicalList(), StandConvertEnum.symptom.toString(), standConvertCrfVOList); // List operationConList = getConvertList(standConvert.getOperationList(), StandConvertEnum.operation.toString(), standConvertCrfVOList); List drugConList = getConvertList(standConvert.getDrugList(), StandConvertEnum.drug.toString(), standConvertCrfVOList); List vitallConList = getConvertList(standConvert.getVitalList(), StandConvertEnum.vital.toString(), standConvertCrfVOList); List diseaseConList = getConvertList(standConvert.getDiaglList(), StandConvertEnum.disease.toString(), standConvertCrfVOList); // List pacsConList = getConvertList(standConvert.getPacsList(), StandConvertEnum.pacs.toString(), standConvertCrfVOList); // List lisConList = getConvertList(standConvert.getLisList(), StandConvertEnum.lis.toString(), standConvertCrfVOList); List transfusionConList = getConvertList(standConvert.getTransfusionList(), StandConvertEnum.transfusion.toString(), standConvertCrfVOList); StandConvertCrfBatchDTO standConvertCrfBatchDTO = new StandConvertCrfBatchDTO(); if (!(ListUtil.isEmpty(clinicalConList) // && ListUtil.isEmpty(operationConList) && ListUtil.isEmpty(drugConList) && ListUtil.isEmpty(vitallConList) && ListUtil.isEmpty(diseaseConList) // && ListUtil.isEmpty(pacsConList) // && ListUtil.isEmpty(lisConList) && ListUtil.isEmpty(transfusionConList))) { try { standConvertCrfBatchDTO = standConvertServiceClient.similarityBatch(standConvertCrfVOList); } catch (Exception e) { throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准词转换【服务器】挂了!" + e.getMessage()); } } Map> crfMap = standConvertCrfBatchDTO.getData(); getConvertMap(crfMap, StandConvertEnum.symptom.toString(), clinicalConList, standConvert.getClinicalList(), map); // getConvertMap(crfMap, StandConvertEnum.operation.toString(), operationConList, standConvert.getOperationList(), map); getConvertMap(crfMap, StandConvertEnum.drug.toString(), drugConList, standConvert.getDrugList(), map); getConvertMap(crfMap, StandConvertEnum.vital.toString(), vitallConList, standConvert.getVitalList(), map); getConvertMap(crfMap, StandConvertEnum.disease.toString(), diseaseConList, standConvert.getDiaglList(), map); // getConvertMap(crfMap, StandConvertEnum.pacs.toString(), pacsConList, standConvert.getPacsList(), map); // getConvertMap(crfMap, StandConvertEnum.lis.toString(), lisConList, standConvert.getLisList(), map); getConvertMap(crfMap, StandConvertEnum.transfusion.toString(), transfusionConList, standConvert.getTransfusionList(), map); return map; } /** * 获取标准词转换map结果,并更新redis * * @param crfDTO * @param type * @param convertList * @param map */ public void getConvertMapDisease(Map> crfDTO, String type, List convertList, List originList, Map> map) { Map typeMap = new LinkedHashMap<>(); if (ListUtil.isNotEmpty(convertList)) { Map crfMap = crfDTO.get(type); for (String s : convertList) { boolean convertFlag = false; String lastS = s; if (StringUtil.isBlank(s)) { continue; } if (crfMap != null) { StandConvertCrfDTO standConvertCrfDTO = crfMap.get(s); if (standConvertCrfDTO != null) { List> list = standConvertCrfDTO.getStandard_words(); if (ListUtil.isEmpty(list)) { redisUtil.updateValue(type + "Conv:" + s, ""); } else { String rateStr = standConvertCrfDTO.getStandard_words().get(0).get("rate"); if (StringUtil.isBlank(rateStr)) { redisUtil.updateValue(type + "Conv:" + s, ""); } else { BigDecimal rate = new BigDecimal(rateStr); int flag = rate.compareTo(new BigDecimal(standConvertRate)); if (flag < 0) { redisUtil.updateValue(type + "Conv:" + s, ""); } else { redisUtil.updateValue(type + "Conv:" + s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word")); lastS = standConvertCrfDTO.getStandard_words().get(0).get("standard_word"); convertFlag = true; } } } } else { redisUtil.updateValue(type + "Conv:" + s, ""); } } else { redisUtil.updateValue(type + "Conv:" + s, ""); } if (convertFlag) { typeMap.put(s, lastS); } else { typeMap.put(s, ""); } } } // 将所有的词放入typeMap中 for (String s : originList) { if (!typeMap.containsKey(s)) { String value = redisUtil.get(type + "Conv:" + s); typeMap.put(s, value); } } map.put(type, typeMap); } /** * 入参数据处理 * * @param wordList * @param type * @param standConvertCrfVOList */ public List getConvertList(List wordList, String type, List standConvertCrfVOList) { List convertList = new ArrayList<>(); if (ListUtil.isEmpty(wordList)) { return null; } if (ListUtil.isNotEmpty(wordList)) { for (String s : wordList) { String value = redisUtil.get(type + "Conv:" + s); if (value == null) { StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO(); standConvertCrfVO.setWord_type(type); standConvertCrfVO.setWord(s); standConvertCrfVOList.add(standConvertCrfVO); if (!convertList.contains(s)) { convertList.add(s); } } } } return convertList; } /** * 获取标准词转换map结果,并更新redis * * @param crfDTO * @param type * @param convertList * @param map */ public void getConvertMap(Map> crfDTO, String type, List convertList, List originList, Map> map) { Map typeMap = new LinkedHashMap<>(); if (ListUtil.isNotEmpty(convertList)) { Map crfMap = crfDTO.get(type); for (String s : convertList) { String lastS = s; if (StringUtil.isBlank(s)) { continue; } if (crfMap != null) { StandConvertCrfDTO standConvertCrfDTO = crfMap.get(s); if (standConvertCrfDTO != null) { List> list = standConvertCrfDTO.getStandard_words(); if (ListUtil.isEmpty(list)) { redisUtil.updateValue(type + "Conv:" + s, s); } else { String rateStr = standConvertCrfDTO.getStandard_words().get(0).get("rate"); if (StringUtil.isBlank(rateStr)) { redisUtil.updateValue(type + "Conv:" + s, s); } else { BigDecimal rate = new BigDecimal(rateStr); int flag = rate.compareTo(new BigDecimal(standConvertRate)); if (flag < 0) { redisUtil.updateValue(type + "Conv:" + s, s); } else { redisUtil.updateValue(type + "Conv:" + s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word")); lastS = standConvertCrfDTO.getStandard_words().get(0).get("standard_word"); } } } } else { redisUtil.updateValue(type + "Conv:" + s, s); } } else { redisUtil.updateValue(type + "Conv:" + s, s); } typeMap.put(s, lastS); } } // 将所有的词放入typeMap中 for (String s : originList) { if (!typeMap.containsKey(s)) { String value = redisUtil.get(type + "Conv:" + s); typeMap.put(s, value); } } map.put(type, typeMap); } /** * 手术映射(关闭同义词转换) * * @param wordCrfDTO */ public void operateGetAndSet(WordCrfDTO wordCrfDTO) { // 【所有手术】 List operationList = new ArrayList<>(); // 1、主诉手术 CoreUtil.addList(operationList, CoreUtil.getPropertyList(wordCrfDTO.getChiefLabel().getOperations())); // 2、现病史手术 CoreUtil.addList(operationList, CoreUtil.getPropertyList(wordCrfDTO.getPresentLabel().getOperations())); // 3、既往史手术 CoreUtil.addList(operationList, CoreUtil.getPropertyList(wordCrfDTO.getPastLabel().getOperations())); // 4、开单手术 CoreUtil.addList(operationList, CoreUtil.filterUniqueList(wordCrfDTO.getOperationOrder())); // 5、结构化手术 CoreUtil.addList(operationList, CoreUtil.filterUniqueList(wordCrfDTO.getOperation())); // 6、选中手术 if (wordCrfDTO.getOperationName() != null && StringUtils.isBlank(wordCrfDTO.getOperationName().getUniqueName())) { operationList.add(wordCrfDTO.getOperationName().getName()); } operationList = operationList .stream() .distinct() .collect(Collectors.toList()); // Map> configMap = new LinkedHashMap<>(); if (ListUtil.isNotEmpty(operationList)) { // configMap = tranOperationConfigFacade.getConfigMap(wordCrfDTO.getHospitalId(), operationList, null); Map>>> operstionMap = mappingConfigFacade.groupByHisNameWithName(operationList, ConceptTypeEnum.Operation.getKey(), wordCrfDTO.getHospitalId()); // 1、主诉手术 // setListProperty(wordCrfDTO.getChiefLabel(), "operations", "standName", configMap); setListProperty(wordCrfDTO.getChiefLabel(), "operations", ConceptTypeEnum.Operation.getKey(),"StandName",operstionMap); // 2、现病史手术 // setListProperty(wordCrfDTO.getPresentLabel(), "operations", "standName", configMap); setListProperty(wordCrfDTO.getPresentLabel(),"operations", ConceptTypeEnum.Operation.getKey(),"StandName",operstionMap); // 3、既往史手术 // setListProperty(wordCrfDTO.getPastLabel(), "operations", "standName", configMap); setListProperty(wordCrfDTO.getPastLabel(),"operations", ConceptTypeEnum.Operation.getKey(),"StandName",operstionMap); // 4、结构化手术 // setListProperty(wordCrfDTO, "operation", "uniqueName", configMap); setListProperty(wordCrfDTO, "operation", ConceptTypeEnum.Operation.getKey(),"UniqueName",operstionMap); // 5、手术 // setListProperty(wordCrfDTO, "operationOrder", "uniqueName", configMap); setListProperty(wordCrfDTO, "operationOrder", ConceptTypeEnum.Operation.getKey(),"UniqueName",operstionMap); // 6、选中手术 if (wordCrfDTO.getOperationName() != null && StringUtil.isNotBlank(wordCrfDTO.getOperationName().getName()) && StringUtil.isBlank(wordCrfDTO.getOperationName().getUniqueName())) { wordCrfDTO.getOperationName().setUniqueName(wordCrfDTO.getOperationName().getName()); } } } /** * 辅检映射(关闭同义词转换) * * @param wordCrfDTO */ public void pacsGetAndSet(WordCrfDTO wordCrfDTO) { // 【所有辅检】 List pacsList = new ArrayList<>(); // 1、结构化 CoreUtil.addList(pacsList, CoreUtil.filterUniqueList(wordCrfDTO.getPacs())); // // 2、开单 CoreUtil.addList(pacsList, CoreUtil.filterUniqueList(wordCrfDTO.getPacsOrder())); PacsLabel pacsLabel = wordCrfDTO.getPacsLabel(); if(pacsLabel != null){ pacsList = pacsLabel.getItem().stream() .map(x -> x.getName()) .collect(Collectors.toList()); } if (ListUtil.isNotEmpty(pacsList)) { Map>>> pacsMap = mappingConfigFacade.groupByHisNameWithName(pacsList, ConceptTypeEnum.Pacs.getKey(), wordCrfDTO.getHospitalId()); setListProperty(wordCrfDTO, "pacs", ConceptTypeEnum.Pacs.getKey(),"UniqueName",pacsMap); setListProperty(wordCrfDTO, "pacsOrder", ConceptTypeEnum.Pacs.getKey(),"UniqueName",pacsMap); setListProperty(pacsLabel, "item", ConceptTypeEnum.Pacs.getKey(),"UniqueName",pacsMap); } } /** * 化验映射(关闭同义词转换) * * @param wordCrfDTO */ public void lisGetAndSet(WordCrfDTO wordCrfDTO) { //化验公表转换 List lisHisNameList = Lists.newArrayList(); // 【所有化验】 List lisList = wordCrfDTO.getLis(); if(ListUtil.isNotEmpty(lisList)){ lisHisNameList.addAll(lisList .stream() .filter(i -> StringUtil.isNotBlank(i.getName()) || StringUtil.isNotBlank(i.getUniqueName())) .map(i -> i.getName()) .collect(Collectors.toList())); } lisHisNameList = lisHisNameList .stream() .distinct() .collect(Collectors.toList()); if (ListUtil.isNotEmpty(lisHisNameList)) { Map>>> lisConfigMap = mappingConfigFacade.groupByHisNameWithName(lisHisNameList, ConceptTypeEnum.LisPack.getKey(), wordCrfDTO.getHospitalId()); setListProperty(wordCrfDTO, "lis", ConceptTypeEnum.LisPack.getKey(),"UniqueName",lisConfigMap); } } /** * 替换映射内容 * * @param obj 对象 * @param listProperty 获取List属性名 * @param objProperty 对象属性名 * @param configMap 映射Map */ public void setListProperty(Object obj, String listProperty, String objProperty, Map> configMap) { Object tList = CoreUtil.getFieldValue(obj, listProperty); List newList = convertStandName((List) tList, configMap, objProperty); ReflectUtil.setProperty(obj, listProperty, newList); } public void setListProperty(Object obj, String listProperty,Integer type,String propertyName, Map>>> configMap) { Object tList = CoreUtil.getFieldValue(obj, listProperty); List newList = convertStandName((List) tList,type, propertyName,configMap); ReflectUtil.setProperty(obj, listProperty, newList); } /** * 标准名称转换 * * @param list * @param configMap * @param fieldName * @param * @return */ public List convertStandName(List list, Map> configMap, String fieldName) { List retList = new ArrayList<>(); try { if (ListUtil.isEmpty(list)) { return retList; } for (T item : list) { String name = ReflectUtil.getProperty(item, "name"); if (StringUtil.isBlank(name)) { retList.add(item); continue; } if (fieldName.equals("uniqueName")) { String uniqueName = ReflectUtil.getProperty(item, "uniqueName"); if (StringUtil.isNotBlank(uniqueName)) { retList.add(item); continue; } } if (configMap.containsKey(name)) { List standNames = new ArrayList<>(configMap.get(name).keySet()); for (String stdName : standNames) { T o = (T) item.getClass().newInstance(); BeanUtil.copyProperties(item, o); BeanUtils.copyProperty(o, fieldName, stdName); retList.add(o); } } else { if (fieldName.equals("uniqueName")) { BeanUtils.copyProperty(item, fieldName, name); } retList.add(item); } } } catch (Exception e) { e.printStackTrace(); } return retList; } /** * 标准名称转换 * * @param list * @param configMap * @param type * @param * @return */ public List convertStandName(List list,Integer type,String propertyName, Map>>> configMap) { List retList = new ArrayList<>(); if (ListUtil.isEmpty(list)) { return list; } try { for (T item : list) { String name = ReflectUtil.getProperty(item, "name"); if (StringUtil.isBlank(name)) { retList.add(item); continue; } // String uniqueName = item.getClass().getMethod("getUniqueName").invoke(item).toString(); String uniqueName = ReflectUtil.getProperty(item, "uniqueName"); if (StringUtil.isNotBlank(uniqueName) && !"StandName".equals(propertyName)) { retList.add(item); continue; } String hisDetailName = ""; if(type.equals(ConceptTypeEnum.LisPack.getKey())) { hisDetailName = ReflectUtil.getProperty(item, "detailName"); if (StringUtil.isBlank(hisDetailName)) { hisDetailName = ""; } } if (configMap != null && configMap.containsKey(name)) { Map>> subMap = configMap.get(name); if (subMap.containsKey(hisDetailName)) { if (type.equals(ConceptTypeEnum.Drug.getKey())) { for (Map.Entry> thirdEntry : subMap.get(hisDetailName).entrySet()) { if (ListUtil.isNotEmpty(thirdEntry.getValue())) { for (String form : thirdEntry.getValue()) { T o = (T) item.getClass().newInstance(); BeanUtil.copyProperties(item, o); Method setUniqueName = o.getClass().getMethod("set"+propertyName, String.class); setUniqueName.invoke(o, thirdEntry.getKey()); Method setForm = o.getClass().getMethod("setForm", String.class); setForm.invoke(o, form); retList.add(o); } } else { T o = (T) item.getClass().newInstance(); BeanUtil.copyProperties(item, o); Method setUniqueName = o.getClass().getMethod("set"+propertyName, String.class); setUniqueName.invoke(o, thirdEntry.getKey()); retList.add(o); } } } else { List standNames = new ArrayList<>(subMap.get(hisDetailName).keySet()); for (String stdName : standNames) { T o = (T) item.getClass().newInstance(); BeanUtil.copyProperties(item, o); Method setUniqueName = o.getClass().getMethod("set"+propertyName, String.class); setUniqueName.invoke(o, stdName); retList.add(o); } } } else { retList.add(item); } } else { if (propertyName.equals("UniqueName")) { BeanUtils.copyProperty(item, "uniqueName", name); } retList.add(item); } } } catch (Exception e) { e.printStackTrace(); } return retList; } /** * 生成给图谱的入参(推送) */ public NeoPushVO generatePushInput(WordCrfDTO wordCrfDTO) { NeoPushVO pushVO = new NeoPushVO(); pushVO.setHospitalId(wordCrfDTO.getHospitalId()); ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel(); PresentLabel presentLabel = wordCrfDTO.getPresentLabel(); List diags = wordCrfDTO.getDiag(); Item diseaseName = wordCrfDTO.getDiseaseName(); PastLabel pastLabel = wordCrfDTO.getPastLabel(); List lis = wordCrfDTO.getLis(); // List pacs = wordCrfDTO.getPacs(); // 辅检 PacsLabel pacsLabel = wordCrfDTO.getPacsLabel(); // List pacsNewList = wordCrfDTO.getPacsLabel().getPacsNewList(); pushVO.setAge(wordCrfDTO.getAge()); pushVO.setSex(wordCrfDTO.getSex()); pushVO.setAgeNum(wordCrfDTO.getAgeNum()); pushVO.setDiaeaseName(diseaseName); List depts = wordCrfDTO.getDept(); if (ListUtil.isNotEmpty(depts)) { List collect = depts.stream().map(x -> x.getUniqueName()).collect(Collectors.toList()); pushVO.setDept(collect); } List chiefSymptom = Lists.newArrayList(); List presentSymptom = Lists.newArrayList(); if (chiefLabel != null) { ChiefPushVo chiefPushVo = new ChiefPushVo(); if (ListUtil.isNotEmpty(chiefLabel.getClinicals())) { chiefSymptom = chiefLabel.getClinicals().stream().filter(x -> x.getNegative() == null).map(z -> z.getStandName()).collect(Collectors.toList()); List cjiefClinicals = chiefLabel.getClinicals().stream().filter(x -> x.getNegative() == null).map(z -> { String name_sy = z.getBodyPart() == null ? z.getStandName() : z.getBodyPart().getName() + z.getStandName(); Symptom symptom = new Symptom(); symptom.setName(name_sy); return symptom; }).collect(Collectors.toList()); if (ListUtil.isNotEmpty(cjiefClinicals)) { chiefPushVo.setSymptoms(cjiefClinicals); } } if (ListUtil.isNotEmpty(chiefLabel.getDiags())) { List chief_diags = chiefLabel.getDiags().stream() .filter(x -> x.getNegative() == null && StringUtils.isNotBlank(x.getStandName())) .map(x -> { Diag diag = new Diag(); diag.setName(x.getStandName()); return diag; }).collect(Collectors.toList()); chiefPushVo.setDiags(chief_diags); } if (ListUtil.isNotEmpty(chiefLabel.getPds())) { chiefPushVo.setPds(chiefLabel.getPds()); } pushVO.setChiefPushVo(chiefPushVo); } if (presentLabel != null) { PresentPushVo presentPushVo = new PresentPushVo(); if (ListUtil.isNotEmpty(presentLabel.getClinicals())) { presentSymptom = presentLabel.getClinicals().stream().filter(x -> x.getNegative() == null).map(z -> z.getStandName()).collect(Collectors.toList()); List presentClinicals = presentLabel.getClinicals().stream() .filter(x -> x.getNegative() == null).map(z -> { String name_sy = z.getBodyPart() == null ? z.getStandName() : z.getBodyPart().getName() + z.getStandName(); Symptom symptom = new Symptom(); symptom.setName(name_sy); return symptom; }).collect(Collectors.toList()); presentPushVo.setSymptoms(presentClinicals); } if (ListUtil.isNotEmpty(presentLabel.getDiags())) { List presentdiags = presentLabel.getDiags().stream() .filter(x -> x.getNegative() == null && StringUtils.isNotBlank(x.getStandName()) && x.getPossible() != null).map (x -> x.getStandName()).distinct().map(z -> { Diag diag = new Diag(); diag.setName(z); return diag; }).collect(Collectors.toList()); presentPushVo.setDiags(presentdiags); } if (ListUtil.isNotEmpty(presentLabel.getMedicines())) { List presentdrugs = presentLabel.getMedicines().stream().filter(x -> x.getNegative() == null).map(z -> { Drug drug = new Drug(); drug.setName(z.getStandName()); return drug; }).collect(Collectors.toList()); presentPushVo.setDrugs(presentdrugs); } pushVO.setPresentPushVo(presentPushVo); } presentSymptom.removeAll(chiefSymptom); chiefSymptom.addAll(presentSymptom); pushVO.setSymptoms(chiefSymptom); if (ListUtil.isNotEmpty(lis)) { LisPushVo lisPushVo = new LisPushVo(); lisPushVo.setLises(lis); pushVO.setLisPushVo(lisPushVo); } // 辅检 if (pacsLabel != null) { PacsPushVo pacsPushVo = new PacsPushVo(); pacsPushVo.setPacs(pacsLabel.getRes()); pushVO.setPacsPushVo(pacsPushVo); } if (ListUtil.isNotEmpty(diags)) { DiagVo diagVo = new DiagVo(); List diseases = diags.stream().map(x -> { Diag diag = new Diag(); diag.setName(x.getUniqueName()); return diag; }).collect(Collectors.toList()); diagVo.setDiags(diseases); pushVO.setDiagVo(diagVo); } return pushVO; } /** * 将现病史中提取的体征内容放入体征标签中 * * @param wordCrfDTO */ public void processPresentVital(WordCrfDTO wordCrfDTO) { PresentLabel presentLabel = wordCrfDTO.getPresentLabel(); VitalLabel vitalLabel = wordCrfDTO.getVitalLabel(); if (ListUtil.isNotEmpty(presentLabel.getVitals())) { vitalLabel.getVitals().addAll(BeanUtil.listCopyTo(presentLabel.getVitals(), Vital.class)); } if (ListUtil.isNotEmpty(presentLabel.getClinicals())) { vitalLabel.getClinicals().addAll(BeanUtil.listCopyTo(presentLabel.getClinicals(), Clinical.class)); } } /** * 统一处理化验、辅检、诊断,放入结构化 * * @param wordCrfDTO */ public void processLisPacsDiag(WordCrfDTO wordCrfDTO) { DiagLabel diagLabel = wordCrfDTO.getDiagLabel(); List diags = diagLabel.getDiags(); if (ListUtil.isNotEmpty(diags)) { wordCrfDTO.getDiag().addAll(diags.stream().filter(x -> x.getStandName() != null).map(x -> { Item i = new Item(); i.setName(x.getName()); i.setUniqueName(x.getStandName()); return i; }).collect(Collectors.toList())); } /**************************化验结构化处理开始*****************************/ List lisList = new ArrayList<>(); // 处理主诉化验 getLisStruct(wordCrfDTO.getChiefLabel().getLises(), lisList); // 处理现病史化验 getLisStruct(wordCrfDTO.getPresentLabel().getLises(), lisList); // 统一放置化验结构 if (ListUtil.isNotEmpty(lisList)) { wordCrfDTO.getLis().addAll(lisList); } /*************************化验结构化处理结束******************************/ /**************************辅检结构化处理开始*****************************/ // 处理辅检信息 PacsLabel pacsLabel = wordCrfDTO.getPacsLabel(); // 处理主诉辅检 getPacsStruct(pacsLabel, wordCrfDTO.getChiefLabel().getPacsLabel()); // 处理现病史辅检 getPacsStruct(pacsLabel, wordCrfDTO.getPresentLabel().getPacsLabel()); //结构化pacs List pacs = wordCrfDTO.getPacs(); if(ListUtil.isNotEmpty(pacs)){ pacs.forEach(p ->{ Item item = new Item(); item.setName(p.getName()==null?"":p.getName()); item.setUniqueName(p.getUniqueName()==null?"":p.getUniqueName()); pacsLabel.getItem().add(item); }); } // 辅检结果去重 if (ListUtil.isNotEmpty(pacsLabel.getRes())) { dealMsgWithItem(pacsLabel.getRes()); } // 辅检名称去重 if (ListUtil.isNotEmpty(pacsLabel.getItem())) { dealMsgWithItem(pacsLabel.getItem()); } /*************************辅检结构化处理结束******************************/ } public void getPacsStruct(PacsLabel res, PacsLabel dealPacsLabel) { List pacsResList = res.getRes(); if (dealPacsLabel != null) { // 添加辅检项目名称 if (ListUtil.isNotEmpty(dealPacsLabel.getItem())) { res.getItem().addAll(dealPacsLabel.getItem()); } // 添加辅检的诊断 if (ListUtil.isNotEmpty(dealPacsLabel.getDisease())) { res.getDisease().addAll(dealPacsLabel.getDisease()); } // 添加辅检的描述 if (ListUtil.isNotEmpty(dealPacsLabel.getPacsResults())) { res.getPacsResults().addAll(dealPacsLabel.getPacsResults()); } } if (ListUtil.isNotEmpty(res.getDisease())) { for (Pacs pacs : res.getDisease()) { Item item = new Item(); item.setName(pacs.getName()==null?"":pacs.getName()); item.setUniqueName(pacs.getStandName()==null?"":pacs.getStandName()); pacsResList.add(item); } } // 添加辅检的描述 if (ListUtil.isNotEmpty(res.getPacsResults())) { for (Pacs pacs : res.getPacsResults()) { Item item = new Item(); item.setName(pacs.getName()); item.setUniqueName(pacs.getStandName()); pacsResList.add(item); // 部位 + 描述循环放入 for (BodyPart bodyPart : pacs.getBodyPartList()) { Item itemPart = new Item(); itemPart.setName(bodyPart.getName() + pacs.getName()); itemPart.setUniqueName(bodyPart.getStandName() + pacs.getStandName()); pacsResList.add(itemPart); } // 描述 + 修饰、 修饰 + 描述 循环放入 for (Modification modification : pacs.getModification()) { Item itemModification = new Item(); itemModification.setName(pacs.getName() + modification.getName()); itemModification.setUniqueName(pacs.getStandName() + modification.getStandName()); pacsResList.add(itemModification); Item itemModificationRe = new Item(); itemModificationRe.setName(modification.getName() + pacs.getName()); itemModificationRe.setUniqueName(modification.getStandName() + pacs.getStandName()); pacsResList.add(itemModificationRe); } } } } /** * 获取化验的结构 * * @param lises * @param lisList * */ public void getLisStruct(List lises, List lisList) { if (ListUtil.isNotEmpty(lises)) { lises.stream().forEach(x -> { String bigName = x.getBigItem().getName();//大项名 String detailName = x.getName();//小项名 String value = x.getPd().getValue(); String unit = x.getPd().getUnit(); String standName = x.getStandName(); lisList.add(getLis(bigName,detailName,value,unit,standName)); }); } } private Lis getLis(String bigName, String detailName, String value, String unit, String uniqueName) { Lis lis = new Lis(); lis.setUnits(unit); if (StringUtils.isBlank(unit)) { if (CoreUtil.isNumbers(value)) { lis.setValue(Double.parseDouble(value)); } else { lis.setOtherValue(value); } } else { lis.setValue(Double.parseDouble(value)); } lis.setDetailName(detailName); lis.setName(bigName); lis.setUniqueName(uniqueName); return lis; } /** * 提示信息去重 * * @param billMsgList */ public void dealMsg(List billMsgList) { if (ListUtil.isNotEmpty(billMsgList)) { List msgList = new ArrayList<>(); Iterator it = billMsgList.iterator(); while (it.hasNext()) { String msg = it.next().getMsg(); if (msgList.contains(msg)) { it.remove(); } else { msgList.add(msg); } } } } /** * 提示信息去重 * * @param itemList */ public void dealMsgWithItem(List itemList) { if (ListUtil.isNotEmpty(itemList)) { List msgList = new ArrayList<>(); Iterator it = itemList.iterator(); while (it.hasNext()) { String msg = it.next().getName(); if (msgList.contains(msg)) { it.remove(); } else { msgList.add(msg); } } } } /** * 获取开单项数据,如没有redis数据,则返回null * * @param ruleVO * @return */ public RuleExtDTO getRuleData(RuleVO ruleVO) { RuleExtDTO ruleExtDTO = null; // 获取规则数据 RuleDTO ruleDTO = redisUtil.get(RedisEnum.allRule.getName() + ruleVO.getLibType() + "_" + ruleVO.getLibName() + "_" + ruleVO.getSuffix()); if (ruleDTO == null) { // 辅检特殊处理,如果为空,再获取【辅助检查项目】【辅助检查子项目】中另外一个 if (ruleVO.getLibType().equals(LexiconEnum.PacsName.getKey())) { ruleDTO = redisUtil.get("allRule:" + LexiconEnum.PacsSubName.getKey() + "_" + ruleVO.getLibName() + "_" + ruleVO.getSuffix()); } else if (ruleVO.getLibType().equals(LexiconEnum.PacsSubName.getKey())) { ruleDTO = redisUtil.get("allRule:" + LexiconEnum.PacsName.getKey() + "_" + ruleVO.getLibName() + "_" + ruleVO.getSuffix()); } } if (ruleDTO != null) { ruleExtDTO = new RuleExtDTO(); BeanUtil.copyProperties(ruleVO, ruleExtDTO); BeanUtil.copyProperties(ruleDTO, ruleExtDTO); return ruleExtDTO; } return ruleExtDTO; } /** * 获取【手术数据源】 * * @param wordCrfDTO */ public List getOperationSource(WordCrfDTO wordCrfDTO) { List operationSource = new ArrayList<>(); List operation = wordCrfDTO.getOperation(); List operationsItem = new ArrayList<>(); for (Item item : operation) { Operation operaData = new Operation(); operaData.setName(item.getName()); operaData.setStandName(item.getUniqueName()); operationsItem.add(operaData); } CoreUtil.addList(operationSource, wordCrfDTO.getChiefLabel().getOperations()); // 主诉手术 CoreUtil.addList(operationSource, wordCrfDTO.getPresentLabel().getOperations()); // 现病史手术 CoreUtil.addList(operationSource, wordCrfDTO.getPastLabel().getOperations()); // 既往史手术 CoreUtil.addList(operationSource, operationsItem); // 结构化手术 return operationSource; } /** * 获取【药品过敏数据源】 * * @param wordCrfDTO */ public List getDrugAllergySource(WordCrfDTO wordCrfDTO) { List drugAllergyAll = new ArrayList<>(); CoreUtil.addAllConvert(drugAllergyAll, wordCrfDTO.getPastLabel().getAllergyMedicines()); // 既往史过敏药品 return drugAllergyAll; } /** * 获取【临床表现数据源】 * * @param wordCrfDTO */ public List getClinicalSource(WordCrfDTO wordCrfDTO) { List clinicSource = new ArrayList<>(); CoreUtil.addList(clinicSource, wordCrfDTO.getChiefLabel().getClinicals()); // 主诉临床表现 CoreUtil.addList(clinicSource, wordCrfDTO.getPresentLabel().getClinicals()); // 现病史临床表现 return clinicSource; } /** * 获取【诊断数据源】(只留阳性诊断) * * @param wordCrfDTO */ public List getDiseaseSource(WordCrfDTO wordCrfDTO) { List diags = new ArrayList<>(); CoreUtil.addList(diags, wordCrfDTO.getDiag()); // 结构化诊断 CoreUtil.addAllConvert(diags, wordCrfDTO.getChiefLabel().getDiags());// 主诉诊断 CoreUtil.addAllConvert(diags, wordCrfDTO.getPresentLabel().getDiags()); // 现病史诊断 CoreUtil.addAllConvert(diags, wordCrfDTO.getPastLabel().getDiags()); // 既往史诊断 return diags; } /** * 获取【药品数据源】 * * @param wordCrfDTO */ public List getDrugSource(WordCrfDTO wordCrfDTO) { List drugAll = new ArrayList<>(); CoreUtil.addList(drugAll, wordCrfDTO.getDrug()); CoreUtil.addAllConvert(drugAll, wordCrfDTO.getChiefLabel().getMedicines()); // 主诉药品 CoreUtil.addAllConvert(drugAll, wordCrfDTO.getPresentLabel().getMedicines());// 现病史药品 CoreUtil.addAllConvert(drugAll, wordCrfDTO.getPastLabel().getMedicines()); // 既往史药品 return drugAll; } }