|
@@ -0,0 +1,180 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.client.StandConvertServiceClient;
|
|
|
+import com.diagbot.dto.StandConvertCrfDTO;
|
|
|
+import com.diagbot.dto.TermConceptDTO;
|
|
|
+import com.diagbot.entity.KlLibraryInfo;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
+import com.diagbot.enums.StandConvertCrfEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.StandConvertCrfVO;
|
|
|
+import com.diagbot.vo.TermMatchingVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wangfeng
|
|
|
+ * @Description:
|
|
|
+ * @date 2021-06-10 19:48
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class TermMatchingFacade {
|
|
|
+ @Autowired
|
|
|
+ KlLibraryInfoFacade klLibraryInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ StandConvertServiceClient standConvertServiceClient;
|
|
|
+
|
|
|
+ public List<TermConceptDTO> getTermMatchingAll(TermMatchingVO termMatchingVO) {
|
|
|
+ List<TermConceptDTO> list = new ArrayList<>();
|
|
|
+ Integer type = convertType(termMatchingVO.getType());
|
|
|
+ if (type != null) {
|
|
|
+ QueryWrapper<KlLibraryInfo> klLibraryInfo = new QueryWrapper<>();
|
|
|
+ klLibraryInfo.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("type_id", type)
|
|
|
+ .eq("name", termMatchingVO.getInputStr());
|
|
|
+ KlLibraryInfo libraryInfo = klLibraryInfoFacade.getOne(klLibraryInfo, false);
|
|
|
+ if (null != libraryInfo) {
|
|
|
+ TermConceptDTO termConceptDTO = new TermConceptDTO();
|
|
|
+ termConceptDTO.setId(libraryInfo.getConceptId());
|
|
|
+ termConceptDTO.setName(libraryInfo.getName());
|
|
|
+ termConceptDTO.setSource(libraryInfo.getIsConcept() == 1 ? 1 : 2);
|
|
|
+ list.add(termConceptDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //没有找到标准词或同义词才找相似词
|
|
|
+ if (ListUtil.isEmpty(list)) {
|
|
|
+ //相似词
|
|
|
+ StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
|
|
|
+ // 类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 辅助检查:vital
|
|
|
+ String wordType = wordType(termMatchingVO.getType());
|
|
|
+ if (StringUtil.isNotBlank(wordType)) {
|
|
|
+ standConvertCrfVO.setWord_type(wordType);
|
|
|
+ standConvertCrfVO.setWord(termMatchingVO.getInputStr());
|
|
|
+ standConvertCrfVO.setNumber(5);
|
|
|
+ StandConvertCrfDTO standConvertCrfDTO = new StandConvertCrfDTO();
|
|
|
+ try {
|
|
|
+ standConvertCrfDTO = standConvertServiceClient.similarity(standConvertCrfVO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准词转换【服务器】挂了!" + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Map<String, String>> standard_words = standConvertCrfDTO.getStandard_words();
|
|
|
+ List<String> placeToList = new ArrayList<>();
|
|
|
+ if (ListUtil.isNotEmpty(standard_words)) {
|
|
|
+ for (Map<String, String> map : standard_words) {
|
|
|
+ String placeTo = map.get("standard_word");
|
|
|
+ placeToList.add(placeTo);
|
|
|
+ }
|
|
|
+ QueryWrapper<KlLibraryInfo> klLibraryInfo = new QueryWrapper<>();
|
|
|
+ klLibraryInfo.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("type_id", type)
|
|
|
+ .in("name", placeToList);
|
|
|
+ List<KlLibraryInfo> libraryInfoList = klLibraryInfoFacade.list(klLibraryInfo);
|
|
|
+ if (ListUtil.isNotEmpty(libraryInfoList)) {
|
|
|
+ for (KlLibraryInfo data : libraryInfoList) {
|
|
|
+ TermConceptDTO termConceptDTO = new TermConceptDTO();
|
|
|
+ termConceptDTO.setId(data.getConceptId());
|
|
|
+ termConceptDTO.setName(data.getName());
|
|
|
+ termConceptDTO.setSource(5);
|
|
|
+ list.add(termConceptDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer convertType(Integer type) {
|
|
|
+ Integer retType = null;
|
|
|
+ //type: 类型:1-化验大项、2-化验小项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ retType = LexiconEnum.LisName.getKey();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ retType = LexiconEnum.LisSubName.getKey();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ retType = LexiconEnum.PacsName.getKey();
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ retType = LexiconEnum.Disease.getKey();
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ retType = LexiconEnum.Medicine.getKey();
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ retType = LexiconEnum.Operation.getKey();
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ retType = LexiconEnum.Dept.getKey();
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ retType = LexiconEnum.Transfusion.getKey();
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ retType = LexiconEnum.Symptom.getKey();
|
|
|
+ break;
|
|
|
+ case 10:
|
|
|
+ retType = LexiconEnum.Scale.getKey();
|
|
|
+ break;
|
|
|
+ case 11:
|
|
|
+ retType = LexiconEnum.Nurse.getKey();
|
|
|
+ break;
|
|
|
+ case 12:
|
|
|
+ retType = LexiconEnum.Tcmdisease.getKey();
|
|
|
+ break;
|
|
|
+ case 13:
|
|
|
+ retType = LexiconEnum.Tcmsyndrome.getKey();
|
|
|
+ break;
|
|
|
+ case 14:
|
|
|
+ retType = LexiconEnum.Anesthesia.getKey();
|
|
|
+ break;
|
|
|
+ case 15:
|
|
|
+ retType = LexiconEnum.Form.getKey();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return retType;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String wordType(Integer type) {
|
|
|
+ String retType = null;
|
|
|
+ //type: 类型:1-化验大项、2-化验小项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医诊断、13-中医证候
|
|
|
+ //类型,疾病: disease,症状: symptom,手术和操作:operation,药品: drug,实验室检查:lis,辅助检查:pacs, 查体:vital
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ retType = StandConvertCrfEnum.lis.getName();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ retType = StandConvertCrfEnum.lis.getName();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ retType = StandConvertCrfEnum.pacs.getName();
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ retType = StandConvertCrfEnum.disease.getName();
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ retType = StandConvertCrfEnum.drug.getName();
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ retType = StandConvertCrfEnum.operation.getName();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return retType;
|
|
|
+ }
|
|
|
+}
|