1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339 |
- 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 <T>
- */
- public <T> void participleByType(List<T> tList, String type) {
- List<T> participleList = Lists.newArrayList();
- if (ListUtil.isNotEmpty(tList)) {
- for (T t : tList) {
- String val = ReflectUtil.getProperty(t, "name");
- List<String> 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<String, Map<String, String>> standConvertMap = standConvertCrf(standConvert);
- dataTypeSet(wordCrfDTO, standConvertMap);
- }
- /**
- * 获取所有需要转标准词的词
- *
- * @param wordCrfDTO
- * @return
- */
- public StandConvert dataTypeGet(WordCrfDTO wordCrfDTO) {
- StandConvert standConvert = new StandConvert();
- // 【所有症状】(主诉、现病史)
- List<String> 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<String> 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<String> allLis = new ArrayList<>();
- // // 1、普通化验——取明细
- // CoreUtil.addList(allLis, CoreUtil.filterUniqueList(wordCrfDTO.getLis(), "detailName"));
- // // 2、开单化验——取套餐
- // CoreUtil.addList(allLis, CoreUtil.filterUniqueList(wordCrfDTO.getLisOrder()));
- // standConvert.setLisList(allLis);
- //
- // // 【所有辅助项目】
- // List<String> 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<String> 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<String> 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<String> 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<String> 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<String, Map<String, String>> map) {
- ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
- PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
- PastLabel pastLabel = wordCrfDTO.getPastLabel();
- DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
- List<Lis> lis = wordCrfDTO.getLis();
- List<Item> 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<String,Map<String,String>> -->Map<类型, Map<原始词, 标准词>>
- */
- public Map<String, Map<String, String>> standConvertCrf(StandConvert standConvert) {
- Map<String, Map<String, String>> map = new LinkedHashMap<>();
- List<StandConvertCrfVO> standConvertCrfVOList = new ArrayList<>();
- List<String> clinicalConList = getConvertList(standConvert.getClinicalList(), StandConvertEnum.symptom.toString(), standConvertCrfVOList);
- // List<String> operationConList = getConvertList(standConvert.getOperationList(), StandConvertEnum.operation.toString(), standConvertCrfVOList);
- List<String> drugConList = getConvertList(standConvert.getDrugList(), StandConvertEnum.drug.toString(), standConvertCrfVOList);
- List<String> vitallConList = getConvertList(standConvert.getVitalList(), StandConvertEnum.vital.toString(), standConvertCrfVOList);
- List<String> diseaseConList = getConvertList(standConvert.getDiaglList(), StandConvertEnum.disease.toString(), standConvertCrfVOList);
- // List<String> pacsConList = getConvertList(standConvert.getPacsList(), StandConvertEnum.pacs.toString(), standConvertCrfVOList);
- // List<String> lisConList = getConvertList(standConvert.getLisList(), StandConvertEnum.lis.toString(), standConvertCrfVOList);
- List<String> 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<String, Map<String, StandConvertCrfDTO>> 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<String, Map<String, StandConvertCrfDTO>> crfDTO, String type, List<String> convertList,
- List<String> originList, Map<String, Map<String, String>> map) {
- Map<String, String> typeMap = new LinkedHashMap<>();
- if (ListUtil.isNotEmpty(convertList)) {
- Map<String, StandConvertCrfDTO> 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<Map<String, String>> 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<String> getConvertList(List<String> wordList, String type, List<StandConvertCrfVO> standConvertCrfVOList) {
- List<String> 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<String, Map<String, StandConvertCrfDTO>> crfDTO, String type, List<String> convertList,
- List<String> originList, Map<String, Map<String, String>> map) {
- Map<String, String> typeMap = new LinkedHashMap<>();
- if (ListUtil.isNotEmpty(convertList)) {
- Map<String, StandConvertCrfDTO> 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<Map<String, String>> 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<String> 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<String, Map<String, Long>> configMap = new LinkedHashMap<>();
- if (ListUtil.isNotEmpty(operationList)) {
- // configMap = tranOperationConfigFacade.getConfigMap(wordCrfDTO.getHospitalId(), operationList, null);
- Map<String, Map<String, Map<String, List<String>>>> 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<String> 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<String, Map<String, Map<String, List<String>>>> 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<String> lisHisNameList = Lists.newArrayList();
- // 【所有化验】
- List<Lis> 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<String, Map<String, Map<String, List<String>>>> 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 <T> void setListProperty(Object obj, String listProperty, String objProperty, Map<String, Map<String, Long>> configMap) {
- Object tList = CoreUtil.getFieldValue(obj, listProperty);
- List<T> newList = convertStandName((List) tList, configMap, objProperty);
- ReflectUtil.setProperty(obj, listProperty, newList);
- }
- public <T> void setListProperty(Object obj, String listProperty,Integer type,String propertyName, Map<String, Map<String, Map<String, List<String>>>> configMap) {
- Object tList = CoreUtil.getFieldValue(obj, listProperty);
- List<T> newList = convertStandName((List) tList,type, propertyName,configMap);
- ReflectUtil.setProperty(obj, listProperty, newList);
- }
- /**
- * 标准名称转换
- *
- * @param list
- * @param configMap
- * @param fieldName
- * @param <T>
- * @return
- */
- public <T> List<T> convertStandName(List<T> list, Map<String, Map<String, Long>> configMap, String fieldName) {
- List<T> 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<String> 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 <T>
- * @return
- */
- public <T> List<T> convertStandName(List<T> list,Integer type,String propertyName, Map<String, Map<String, Map<String, List<String>>>> configMap) {
- List<T> 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<String, Map<String, List<String>>> subMap = configMap.get(name);
- if (subMap.containsKey(hisDetailName)) {
- if (type.equals(ConceptTypeEnum.Drug.getKey())) {
- for (Map.Entry<String, List<String>> 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<String> 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<Item> diags = wordCrfDTO.getDiag();
- Item diseaseName = wordCrfDTO.getDiseaseName();
- PastLabel pastLabel = wordCrfDTO.getPastLabel();
- List<Lis> lis = wordCrfDTO.getLis();
- // List<Pacs> pacs = wordCrfDTO.getPacs();
- // 辅检
- PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
- // List<PacsNew> pacsNewList = wordCrfDTO.getPacsLabel().getPacsNewList();
- pushVO.setAge(wordCrfDTO.getAge());
- pushVO.setSex(wordCrfDTO.getSex());
- pushVO.setAgeNum(wordCrfDTO.getAgeNum());
- pushVO.setDiaeaseName(diseaseName);
- List<Item> depts = wordCrfDTO.getDept();
- if (ListUtil.isNotEmpty(depts)) {
- List<String> collect = depts.stream().map(x -> x.getUniqueName()).collect(Collectors.toList());
- pushVO.setDept(collect);
- }
- List<String> chiefSymptom = Lists.newArrayList();
- List<String> 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<Symptom> 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<Diag> 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<Symptom> 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<Diag> 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<Drug> 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<Diag> 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<com.diagbot.model.entity.Diag> 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<Lis> 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<com.diagbot.biz.push.entity.Pacs> 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<Item> 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<com.diagbot.model.entity.Lis> lises, List<Lis> 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<BillMsg> billMsgList) {
- if (ListUtil.isNotEmpty(billMsgList)) {
- List<String> msgList = new ArrayList<>();
- Iterator<BillMsg> 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<Item> itemList) {
- if (ListUtil.isNotEmpty(itemList)) {
- List<String> msgList = new ArrayList<>();
- Iterator<Item> 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<Operation> getOperationSource(WordCrfDTO wordCrfDTO) {
- List<Operation> operationSource = new ArrayList<>();
- List<Item> operation = wordCrfDTO.getOperation();
- List<Operation> 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<Item> getDrugAllergySource(WordCrfDTO wordCrfDTO) {
- List<Item> drugAllergyAll = new ArrayList<>();
- CoreUtil.addAllConvert(drugAllergyAll, wordCrfDTO.getPastLabel().getAllergyMedicines()); // 既往史过敏药品
- return drugAllergyAll;
- }
- /**
- * 获取【临床表现数据源】
- *
- * @param wordCrfDTO
- */
- public List<Clinical> getClinicalSource(WordCrfDTO wordCrfDTO) {
- List<Clinical> clinicSource = new ArrayList<>();
- CoreUtil.addList(clinicSource, wordCrfDTO.getChiefLabel().getClinicals()); // 主诉临床表现
- CoreUtil.addList(clinicSource, wordCrfDTO.getPresentLabel().getClinicals()); // 现病史临床表现
- return clinicSource;
- }
- /**
- * 获取【诊断数据源】(只留阳性诊断)
- *
- * @param wordCrfDTO
- */
- public List<Item> getDiseaseSource(WordCrfDTO wordCrfDTO) {
- List<Item> 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<Item> getDrugSource(WordCrfDTO wordCrfDTO) {
- List<Item> 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;
- }
- }
|