123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697 |
- 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.dto.BillMsg;
- import com.diagbot.dto.WordCrfDTO;
- import com.diagbot.enums.StandConvertEnum;
- import com.diagbot.model.ai.AIAnalyze;
- import com.diagbot.model.entity.BodyPart;
- import com.diagbot.model.entity.Modification;
- import com.diagbot.model.entity.Pacs;
- import com.diagbot.model.label.ChiefLabel;
- import com.diagbot.model.label.DiagLabel;
- import com.diagbot.model.label.PacsLabel;
- import com.diagbot.model.label.PastLabel;
- import com.diagbot.model.label.PresentLabel;
- import com.diagbot.model.label.VitalLabel;
- import com.diagbot.util.CoreUtil;
- import com.diagbot.util.ListUtil;
- import com.diagbot.util.StringUtil;
- import com.diagbot.vo.NeoPushVO;
- import com.diagbot.vo.SearchData;
- import com.diagbot.vo.StandConvert;
- import com.diagbot.vo.neoPushEntity.*;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.stream.Collectors;
- /**
- * @Description: 通过业务facade
- * @author: zhoutg
- * @time: 2018/8/6 9:11
- */
- @Component
- public class CommonFacade {
- @Autowired
- CRFServiceClient crfServiceClient;
- @Autowired
- LisConfigFacade lisConfigFacade;
- @Autowired
- PacsConfigFacade pacsConfigFacade;
- //组装好的label
- public WordCrfDTO crf_process(SearchData searchData) {
- AIAnalyze aiAnalyze = new AIAnalyze(crfServiceClient);
- 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.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(searchData.getPasts())) {
- wordCrfDTO.setPasts(searchData.getPasts());
- }
- if (StringUtil.isNotBlank(searchData.getMenstrual())) {
- wordCrfDTO.setMenstrual(searchData.getMenstrual());
- }
- //模型处理数据
- aiAnalyze.aiProcess(searchData, wordCrfDTO);
- // 统一处理化验、辅检、诊断,放入结构化
- processLisPacsDiag(wordCrfDTO);
- // 现病史中体征内容放入体征标签
- processPresentVital(wordCrfDTO);
- return wordCrfDTO;
- }
- //返回给图谱的词,这些词需要转换成标准词
- 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(presentLabel.getOperations()));
- // 2、既往史手术
- CoreUtil.addList(operationList, CoreUtil.getPropertyList(pastLabel.getOperations()));
- // 3、开单手术
- CoreUtil.addList(operationList, CoreUtil.filterUniqueList(wordCrfDTO.getOperationOrder()));
- // 4、结构化手术
- CoreUtil.addList(operationList, CoreUtil.filterUniqueList(wordCrfDTO.getOperation()));
- // 5、选中手术
- 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中
- 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.setPropertyList(vitalLabel.getVitals(), map.get(StandConvertEnum.vital.toString()));
- CoreUtil.setPropertyList(vitalLabel.getClinicals(), map.get(StandConvertEnum.vital.toString()));
- // 【手术回填】
- // 1、现病史手术
- CoreUtil.setPropertyList(presentLabel.getOperations(), map.get(StandConvertEnum.operation.toString()));
- // 2、既往史手术
- CoreUtil.setPropertyList(pastLabel.getOperations(), map.get(StandConvertEnum.operation.toString()));
- // 3、开单手术
- CoreUtil.setPropertyList(wordCrfDTO.getOperationOrder(), "name", "uniqueName", map.get(StandConvertEnum.operation.toString()));
- // 4、结构化手术
- CoreUtil.setPropertyList(wordCrfDTO.getOperation(), "name", "uniqueName", map.get(StandConvertEnum.operation.toString()));
- // 5、选中手术
- CoreUtil.setPropertyList(wordCrfDTO.getOperationName(), "name", "uniqueName", map.get(StandConvertEnum.operation.toString()));
- //【输血回填】
- CoreUtil.setPropertyList(wordCrfDTO.getTransfusionOrder(), "name", "uniqueName", map.get(StandConvertEnum.transfusion.toString()));
- }
- /**
- * 生成给图谱的入参(推送)
- */
- public NeoPushVO generatePushInput(WordCrfDTO wordCrfDTO) {
- NeoPushVO pushVO = new NeoPushVO();
- 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();
- // TODO 辅检
- 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);
- }
- if (chiefLabel != null) {
- ChiefPushVo chiefPushVo = new ChiefPushVo();
- if (ListUtil.isNotEmpty(chiefLabel.getClinicals())) {
- 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())) {
- 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())).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);
- }
- if (ListUtil.isNotEmpty(lis)) {
- LisPushVo lisPushVo = new LisPushVo();
- lisPushVo.setLises(lis);
- pushVO.setLisPushVo(lisPushVo);
- }
- // TODO 辅检
- 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(presentLabel.getVitals());
- }
- if (ListUtil.isNotEmpty(presentLabel.getClinicals())) {
- vitalLabel.getClinicals().addAll(presentLabel.getClinicals());
- }
- }
- /**
- * 统一处理化验、辅检、诊断,放入结构化
- *
- * @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, wordCrfDTO.getHospitalId());
- // 处理现病史化验
- getLisStruct(wordCrfDTO.getPresentLabel().getLises(), lisList, wordCrfDTO.getHospitalId());
- // 统一放置化验结构
- if (ListUtil.isNotEmpty(lisList)) {
- wordCrfDTO.getLis().addAll(lisList);
- }
- /*************************化验结构化处理结束******************************/
- /**************************辅检结构化处理开始*****************************/
- // 处理辅检信息
- PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
- // 处理主诉辅检
- getPacsStruct(pacsLabel, wordCrfDTO.getChiefLabel().getPacsLabel());
- // 处理现病史辅检
- getPacsStruct(pacsLabel, wordCrfDTO.getPresentLabel().getPacsLabel());
- // 辅检结果去重
- if (ListUtil.isNotEmpty(pacsLabel.getRes())) {
- dealMsgWithItem(pacsLabel.getRes());
- }
- // 辅检名称去重
- if (ListUtil.isNotEmpty(pacsLabel.getItem())) {
- dealMsgWithItem(pacsLabel.getItem());
- }
- /*************************辅检结构化处理结束******************************/
- //处理辅检
- // List<com.diagbot.biz.push.entity.Pacs> pacs = new ArrayList<>();
- // List<PacsNew> packagePacs = new ArrayList<>();
- // List<PacsNew> pacsNewList = wordCrfDTO.getPresentLabel().getPacsNewList();
- // if(ListUtil.isNotEmpty(pacsNewList)){
- // List<String> pacsNames = pacsNewList.stream().map(x -> x.getName()).collect(Collectors.toList());
- // Map<String, Map<String, Long>> configMap = pacsConfigFacade.getConfigMap(wordCrfDTO.getHospitalId(), pacsNames, null);
- // if(configMap.size() > 0){
- // pacsNewList.stream().forEach(pacsNew ->{
- // String name = pacsNew.getName();
- // List<Pacs> disease = pacsNew.getDisease();
- // List<Pacs> pacsResults = pacsNew.getPacsResults();
- // if(configMap.containsKey(name)){
- // Map<String, Long> uinqueNameMap = configMap.get(name);
- // List<PacsNew> collect = uinqueNameMap.keySet().stream().map(x -> {
- // PacsNew pan = new PacsNew();
- // pan.setName(name);
- // pan.setUniqueName(x);
- // pan.setPacsResults(pacsResults);
- // pan.setDisease(disease);
- // return pan;
- // }).collect(Collectors.toList());
- // packagePacs.addAll(collect);
- // collect.forEach(x ->{
- // com.diagbot.biz.push.entity.Pacs p = new com.diagbot.biz.push.entity.Pacs();
- // p.setName(x.getName());
- // p.setUniqueName(x.getUniqueName());
- // pacs.add(p);
- // });
- // }else {
- // PacsNew pan = new PacsNew();
- // pan.setName(name);
- // pan.setPacsResults(pacsResults);
- // pan.setDisease(disease);
- // packagePacs.add(pan);
- // com.diagbot.biz.push.entity.Pacs p = new com.diagbot.biz.push.entity.Pacs();
- // p.setName(name);
- // pacs.add(p);
- // }
- // });
- // }else {
- // packagePacs.addAll(pacsNewList);
- // pacsNewList.forEach(x ->{
- // com.diagbot.biz.push.entity.Pacs p = new com.diagbot.biz.push.entity.Pacs();
- // p.setName(x.getName());
- // pacs.add(p);
- // });
- // }
- // }
- // if(ListUtil.isNotEmpty(pacs)){
- // wordCrfDTO.getPacs().addAll(pacs);
- // }
- // pacsLabel.getPacsNewList().addAll(packagePacs);
- }
- 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());
- item.setUniqueName(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
- * @param hospitalId
- */
- public void getLisStruct(List<com.diagbot.model.entity.Lis> lises, List<Lis> lisList, Long hospitalId) {
- if (ListUtil.isNotEmpty(lises)) {
- List<String> lisNames = lises.stream().map(x -> x.getBigItem().getName()).distinct().collect(Collectors.toList());
- Map<String, Map<String, Map<String, Long>>> configMap = lisConfigFacade.getConfigMap(hospitalId, lisNames, null);
- if (configMap.size() > 0) {
- lises.stream().forEach(x -> {
- String bigName = x.getBigItem().getName();//大项名
- String detailName = x.getName();//小项名
- String value = x.getPd().getValue();
- String unit = x.getPd().getUnit();
- if (configMap.containsKey(bigName)) {
- Map<String, Map<String, Long>> uniqueDetailMap = configMap.get(bigName);
- if (uniqueDetailMap.containsKey(detailName)) {
- List<String> uniques = uniqueDetailMap.get(detailName).keySet().stream().collect(Collectors.toList());//所有的公表项
- if (ListUtil.isNotEmpty(uniques)) {
- List<Lis> lisStream = uniques.stream().map(z -> {
- return getLis(bigName, detailName, value, unit, z);
- }).collect(Collectors.toList());
- lisList.addAll(lisStream);
- }
- } else {
- Lis lis = getLis(bigName, detailName, value, unit, null);
- lisList.add(lis);
- }
- } else {
- Lis lis = getLis(bigName, detailName, value, unit, null);
- lisList.add(lis);
- }
- });
- } else {
- lises.stream().forEach(x -> {
- Lis lis = getLis(x.getBigItem().getName(), x.getName(), x.getPd().getValue(), x.getPd().getUnit(), null);
- lisList.add(lis);
- });
- }
- }
- }
- 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);
- }
- }
- }
- }
- }
|