123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- package com.diagbot.facade;
- import com.diagbot.dto.*;
- import com.diagbot.enums.LexiconEnum;
- import com.diagbot.exception.CommonErrorCode;
- import com.diagbot.exception.CommonException;
- import com.diagbot.util.BeanUtil;
- import com.diagbot.util.EntityUtil;
- import com.diagbot.util.ListUtil;
- import com.diagbot.util.StringUtil;
- import com.diagbot.vo.MedRetrievalVO;
- import com.diagbot.vo.RetrievalVO;
- import com.diagbot.vo.StaticKnowledgeIndexVO;
- import com.google.common.collect.Lists;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- /**
- * @Description:
- * @Author:zhaops
- * @time: 2021/2/22 10:35
- */
- @Component
- public class MedRetrievalFacade {
- @Autowired
- private KlConceptFacade klConceptFacade;
- @Autowired
- private DictionaryFacade dictionaryFacade;
- @Autowired
- private KlDictionaryInfoFacade klDictionaryInfoFacade;
- /**
- * 检索
- *
- * @param retrievalVO
- * @return
- */
- public RetrievalDTO index(RetrievalVO retrievalVO) {
- if (retrievalVO.getSize() == null) {
- retrievalVO.setSize(100);
- }
- if (retrievalVO.getDefaultList().equals(0)
- && StringUtil.isBlank(retrievalVO.getInputStr())) {
- throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入检索内容");
- }
- RetrievalDTO retrievalDTO = new RetrievalDTO();
- MedRetrievalVO medRetrievalVO = new MedRetrievalVO();
- BeanUtil.copyProperties(retrievalVO, medRetrievalVO);
- medRetrievalVO.setTypeIds(new ArrayList<>());
- List<IndexDTO> indexList = Lists.newLinkedList();
- /**
- * 类型:1-化验大项、2-化验小项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、9-症状、10-量表、11-护理、12-中医诊断、13-中医证候、14-麻醉、15-药品剂型、16-给药途径、17-物理治疗
- */
- switch (retrievalVO.getType()) {
- case 1:
- medRetrievalVO.setTypeId(LexiconEnum.LisName.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.LisName.getKey());
- List<RetrievalConceptDTO> nameList = new ArrayList<>();
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- nameList = BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class);
- retrievalDTO.setNameList(nameList);
- }
- break;
- case 2:
- medRetrievalVO.setTypeId(LexiconEnum.LisSubName.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.LisSubName.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- List<LisDetailDTO> lisDetails = Lists.newLinkedList();
- indexList.forEach(item -> {
- LisDetailDTO lisDetail = new LisDetailDTO();
- BeanUtil.copyProperties(item, lisDetail);
- lisDetail.setName(item.getPackName());
- lisDetail.setUniqueName(item.getName());
- //默认套餐名称
- if (StringUtil.isBlank(lisDetail.getName())) {
- lisDetail.setName(lisDetail.getUniqueName());
- }
- lisDetails.add(lisDetail);
- });
- retrievalDTO.setLisDetailNames(lisDetails);
- }
- break;
- case 3:
- medRetrievalVO.setTypeId(LexiconEnum.PacsName.getKey());
- medRetrievalVO.getTypeIds().addAll(Arrays.asList(LexiconEnum.PacsName.getKey(),
- LexiconEnum.PacsSubName.getKey()));
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- List<RetrievalConceptDTO> pacsNames = new ArrayList<>();
- pacsNames = BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class);
- retrievalDTO.setNameList(pacsNames);
- }
- break;
- case 4:
- medRetrievalVO.setTypeId(LexiconEnum.Disease.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Disease.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 5:
- medRetrievalVO.setTypeId(LexiconEnum.Medicine.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Medicine.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 6:
- medRetrievalVO.setTypeId(LexiconEnum.Operation.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Operation.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 7:
- medRetrievalVO.setTypeId(LexiconEnum.Dept.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Dept.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- List<RetrievalConceptDTO> deptNames = new ArrayList<>();
- deptNames = BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class);
- retrievalDTO.setNameList(deptNames);
- }
- break;
- case 8:
- medRetrievalVO.setTypeId(LexiconEnum.Transfusion.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Transfusion.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- List<RetrievalConceptDTO> transfusionNames = new ArrayList<>();
- transfusionNames = BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class);
- retrievalDTO.setNameList(transfusionNames);
- }
- break;
- case 9:
- medRetrievalVO.setTypeId(LexiconEnum.Symptom.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Symptom.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- List<RetrievalConceptDTO> symptomNames = new ArrayList<>();
- symptomNames = BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class);
- retrievalDTO.setNameList(symptomNames);
- }
- break;
- case 10:
- medRetrievalVO.setTypeId(LexiconEnum.Scale.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Scale.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 11:
- medRetrievalVO.setTypeId(LexiconEnum.Nurse.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Nurse.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 12:
- medRetrievalVO.setTypeId(LexiconEnum.Tcmdisease.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Tcmdisease.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 13:
- medRetrievalVO.setTypeId(LexiconEnum.Tcmsyndrome.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Tcmsyndrome.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 14:
- medRetrievalVO.setTypeId(LexiconEnum.Anesthesia.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Anesthesia.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 15:
- medRetrievalVO.setTypeId(LexiconEnum.Form.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Form.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 16:
- medRetrievalVO.setTypeId(LexiconEnum.AdministrationRoute.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.AdministrationRoute.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- case 17:
- medRetrievalVO.setTypeId(LexiconEnum.Physicotherapy.getKey());
- medRetrievalVO.getTypeIds().add(LexiconEnum.Physicotherapy.getKey());
- indexList = klConceptFacade.index(medRetrievalVO);
- if (ListUtil.isNotEmpty(indexList)) {
- retrievalDTO.setNameList(BeanUtil.listCopyTo(indexList, RetrievalConceptDTO.class));
- }
- break;
- }
- return retrievalDTO;
- }
- /**
- * 医学知识(静态信息)检索
- *
- * @param staticKnowledgeIndexVO
- * @return
- */
- public List<StaticKnowledgeIndexDTO> staticKnowledgeIndex(StaticKnowledgeIndexVO staticKnowledgeIndexVO) {
- staticKnowledgeIndexVO.setTypeIds(new ArrayList<>());
- if (staticKnowledgeIndexVO.getSize() == null) {
- staticKnowledgeIndexVO.setSize(100);
- }
- List<Integer> types = staticKnowledgeIndexVO.getTypes();
- List<DictionaryInfoDTO> dicType = klDictionaryInfoFacade.getListByGroupType(10);
- Map<String, String> dicTypeMap = EntityUtil.makeMapWithKeyValue(dicType, "name", "val");
- List<DictionaryInfoDTO> dicTypeName = klDictionaryInfoFacade.getListByGroupType(13);
- List<DictionaryInfoDTO> dicType_back = dictionaryFacade.getListByGroupType(10);
- Map<String, String> dicTypeMap_back = EntityUtil.makeMapWithKeyValue(dicType_back, "name", "val");
- List<DictionaryInfoDTO> dicTypeName_back = dictionaryFacade.getListByGroupType(13);
- //检索类型(多选):0-全部、1-诊断、2-药品、3-检验、5-检查、6-手术和操作、8-量表、9-护理
- if (ListUtil.isEmpty(types)
- || (ListUtil.isNotEmpty(types) && types.contains(0))) {
- staticKnowledgeIndexVO.getTypeIds().addAll(Arrays.asList(LexiconEnum.Disease.getKey(),
- LexiconEnum.Medicine.getKey(),
- LexiconEnum.LisName.getKey(),
- LexiconEnum.LisSubName.getKey(),
- LexiconEnum.PacsName.getKey(),
- LexiconEnum.PacsSubName.getKey(),
- LexiconEnum.Operation.getKey(),
- LexiconEnum.Scale.getKey(),
- LexiconEnum.Nurse.getKey(),
- LexiconEnum.Law.getKey()));
- } else {
- if (types.contains(1)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.Disease.getKey());
- }
- if (types.contains(2)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.Medicine.getKey());
- }
- if (types.contains(3)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.LisName.getKey());
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.LisSubName.getKey());
- }
- if (types.contains(5)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.PacsName.getKey());
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.PacsSubName.getKey());
- }
- if (types.contains(6)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.Operation.getKey());
- }
- if (types.contains(8)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.Scale.getKey());
- }
- if (types.contains(9)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.Nurse.getKey());
- }
- if (types.contains(10)) {
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.Law.getKey());
- }
- }
- List<StaticKnowledgeIndexDTO> retList = klConceptFacade.staticIndex(staticKnowledgeIndexVO);
- retList.forEach(i -> {
- //前端展示
- if (staticKnowledgeIndexVO.getHasInfo().equals(1)) {
- i.setTypeName(convertTypeName(i.getTypeName(), 2, dicTypeName));
- if (dicTypeMap.containsKey(i.getTypeName())) {
- i.setType(Integer.valueOf(dicTypeMap.get(i.getTypeName())));
- }
- } else {
- i.setTypeName(convertTypeName(i.getTypeName(), 2, dicTypeName_back));
- if (dicTypeMap_back.containsKey(i.getTypeName())) {
- i.setType(Integer.valueOf(dicTypeMap_back.get(i.getTypeName())));
- }
- }
- });
- return retList;
- }
- /**
- * 经典病历检索
- *
- * @param staticKnowledgeIndexVO
- * @return
- */
- public List<ClassicCaseIndexDTO> classicCaseIndex(StaticKnowledgeIndexVO staticKnowledgeIndexVO) {
- staticKnowledgeIndexVO.setTypeIds(new ArrayList<>());
- if (staticKnowledgeIndexVO.getSize() == null) {
- staticKnowledgeIndexVO.setSize(100);
- }
- List<Integer> types = staticKnowledgeIndexVO.getTypes();
- List<DictionaryInfoDTO> dicType = klDictionaryInfoFacade.getListByGroupType(10);
- Map<String, String> dicTypeMap = EntityUtil.makeMapWithKeyValue(dicType, "name", "val");
- List<DictionaryInfoDTO> dicTypeName = klDictionaryInfoFacade.getListByGroupType(13);
- List<DictionaryInfoDTO> dicType_back = dictionaryFacade.getListByGroupType(10);
- Map<String, String> dicTypeMap_back = EntityUtil.makeMapWithKeyValue(dicType_back, "name", "val");
- List<DictionaryInfoDTO> dicTypeName_back = dictionaryFacade.getListByGroupType(13);
- //类型检索
- staticKnowledgeIndexVO.getTypeIds().add(LexiconEnum.ClassicCase.getKey());
- List<ClassicCaseIndexDTO> retList = klConceptFacade.caseIndex(staticKnowledgeIndexVO);
- retList.forEach(i -> {
- //前端展示
- if (staticKnowledgeIndexVO.getHasInfo().equals(1)) {
- i.setTypeName(convertTypeName(i.getTypeName(), 2, dicTypeName));
- if (dicTypeMap.containsKey(i.getTypeName())) {
- i.setType(Integer.valueOf(dicTypeMap.get(i.getTypeName())));
- }
- } else {
- i.setTypeName(convertTypeName(i.getTypeName(), 2, dicTypeName_back));
- if (dicTypeMap_back.containsKey(i.getTypeName())) {
- i.setType(Integer.valueOf(dicTypeMap_back.get(i.getTypeName())));
- }
- }
- });
- return retList;
- }
- /**
- * 页面显示词性和标准词性转换
- *
- * @param typeName
- * @param flag 1-页面词性转标准词性,2- 标准词性转页面词性
- * @param dicList
- * @return
- */
- public String convertTypeName(String typeName, Integer flag, List<DictionaryInfoDTO> dicList) {
- if (ListUtil.isNotEmpty(dicList)) {
- Map<String, String> nameValMap = new HashMap<>();
- if (flag.equals(1)) {
- nameValMap = EntityUtil.makeMapWithKeyValue(dicList, "name", "val");
- } else if (flag.equals(2)) {
- nameValMap = EntityUtil.makeMapWithKeyValue(dicList, "val", "name");
- }
- if (nameValMap.containsKey(typeName)) {
- return nameValMap.get(typeName);
- }
- }
- return typeName;
- }
- }
|