ソースを参照

Merge remote-tracking branch 'origin/dev/mapping20210603' into debug

zhaops 4 年 前
コミット
69b510d7b0

+ 64 - 0
doc/002.20210629术语关联改版/cdss_init.sql

@@ -0,0 +1,64 @@
+use `cdss`;
+DROP TABLE IF EXISTS `tran_dept_config`;
+DROP TABLE IF EXISTS `tran_drug_config`;
+DROP TABLE IF EXISTS `tran_disease_config`;
+DROP TABLE IF EXISTS `tran_lis_config`;
+DROP TABLE IF EXISTS `tran_pacs_config`;
+DROP TABLE IF EXISTS `tran_scale_config`;
+DROP TABLE IF EXISTS `tran_nurse_config`;
+DROP TABLE IF EXISTS `tran_operation_config`;
+DROP TABLE IF EXISTS `tran_transfusion_config`;
+DROP TABLE IF EXISTS `tran_tcmdisease_config`;
+DROP TABLE IF EXISTS `tran_tcmsyndrome_config`;
+
+/*
+ Navicat Premium Data Transfer
+
+ Source Server         : 192.168.2.236
+ Source Server Type    : MySQL
+ Source Server Version : 50731
+ Source Host           : 192.168.2.236:3306
+ Source Schema         : cdss
+
+ Target Server Type    : MySQL
+ Target Server Version : 50731
+ File Encoding         : 65001
+
+ Date: 29/06/2021 13:55:24
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for tran_mapping_config
+-- ----------------------------
+DROP TABLE IF EXISTS `tran_mapping_config`;
+CREATE TABLE `tran_mapping_config`  (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
+  `is_deleted` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'N' COMMENT '是否删除,N:未删除,Y:删除',
+  `gmt_create` datetime(0) NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录创建时间',
+  `gmt_modified` datetime(0) NOT NULL DEFAULT '1970-01-01 12:00:00' COMMENT '记录修改时间,如果时间是1970年则表示纪录未修改',
+  `creator` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '创建人,0表示无创建人值',
+  `modifier` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '修改人,如果为0则表示纪录未修改',
+  `hospital_id` bigint(20) NOT NULL COMMENT '医院id',
+  `type` int(4) NOT NULL COMMENT '医学术语类型( 1-检验套餐、2-检验细项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、10-量表、11-护理、12-中医疾病、13-中医证候、14-麻醉)',
+  `his_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '医院术语名称',
+  `his_code` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '医院术语编码',
+  `his_detail_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '医院术语细项名称(检验细项)',
+  `concept_id` bigint(20) NULL DEFAULT NULL COMMENT '医学标准术语id',
+  `form_concept_id` bigint(20) NULL DEFAULT NULL COMMENT '药品剂型id',
+  `is_match` int(4) NOT NULL DEFAULT 0 COMMENT '是否匹配(0-未匹配、1-已匹配)',
+  `source` int(4) NULL DEFAULT NULL COMMENT '数据来源(1-标准词、2-同义词、3-编码、4-历史数据、5-相似词、99-数据迁移)',
+  `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`id`) USING BTREE,
+  INDEX `idx_his_detail_name`(`hospital_id`, `type`, `his_name`, `his_detail_name`) USING BTREE,
+  INDEX `idx_his_name`(`hospital_id`, `type`, `his_name`) USING BTREE,
+  INDEX `idx_concept_id`(`hospital_id`, `concept_id`) USING BTREE,
+  INDEX `idx_hospital_id`(`hospital_id`) USING BTREE,
+  INDEX `idx_detail_name`(`his_name`, `his_detail_name`) USING BTREE,
+  INDEX `idx_deleted_type`(`type`) USING BTREE,
+  INDEX `idx_type`(`hospital_id`, `type`, `is_deleted`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 797881 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '医学术语映射表' ROW_FORMAT = Dynamic;
+
+SET FOREIGN_KEY_CHECKS = 1;

+ 1 - 1
src/main/java/com/diagbot/aggregate/AssemblePushAggregate.java

@@ -224,7 +224,7 @@ public class AssemblePushAggregate {
 
     @DataProvider("retScale")
     public List<PushScaleDTO> retScale(@InvokeParameter("pushDTO") PushDTO data,
-                                      @InvokeParameter("hospitalId") Long hospitalId) {
+                                       @InvokeParameter("hospitalId") Long hospitalId) {
         //量表
         List<PushScaleDTO> retScale = new ArrayList<>();
         if (ListUtil.isNotEmpty(data.getScale())) {

+ 1 - 0
src/main/java/com/diagbot/entity/MappingConfig.java

@@ -84,6 +84,7 @@ public class MappingConfig implements Serializable {
     /**
      * 医学标准术语id
      */
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
     private Long conceptId;
 
     /**

+ 17 - 1
src/main/java/com/diagbot/facade/KlConceptStaticFacade.java

@@ -12,6 +12,8 @@ import com.diagbot.dto.StaticKnowledgeIndexDTO;
 import com.diagbot.dto.StaticKnowledgeIndexPageDTO;
 import com.diagbot.entity.SysUser;
 import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.RespDTOUtil;
@@ -67,6 +69,8 @@ public class KlConceptStaticFacade {
         RespDTO<List<StaticKnowledgeIndexDTO>> respDTO = cdssCoreClient.staticKnowledgeIndex(staticKnowledgeIndexVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             retList = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
 
         if (staticKnowledgeIndexVO.getHasInfo() != null && staticKnowledgeIndexVO.getHasInfo().equals(1)) {
@@ -104,7 +108,7 @@ public class KlConceptStaticFacade {
             StaticKnowledgeDTO staticKnowledgeDTO = respDTO.data;
             return staticKnowledgeDTO;
         } else {
-            return null;
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
     }
 
@@ -151,6 +155,8 @@ public class KlConceptStaticFacade {
         RespDTO<Page<KlConceptStaticDTO>> respDTO = cdssCoreClient.getPage(klConceptStaticPageVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             page = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
         List<KlConceptStaticDTO> records = page.getRecords();
         List<Long> userIds = records.stream().map(KlConceptStaticDTO::getModifier)
@@ -191,6 +197,8 @@ public class KlConceptStaticFacade {
         RespDTO<Page<StaticKnowledgeIndexPageDTO>> respDTO = cdssCoreClient.staticIndexPage(staticKnowledgeIndexPageVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             page = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
         return page;
     }
@@ -209,6 +217,8 @@ public class KlConceptStaticFacade {
         RespDTO<Boolean> respDTO = cdssCoreClient.saveOrUpdateRecord(klConceptStaticVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             success = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
         return success;
     }
@@ -227,6 +237,8 @@ public class KlConceptStaticFacade {
         RespDTO<Boolean> respDTO = cdssCoreClient.changeStatus(changeStatusVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             success = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
         return success;
     }
@@ -242,6 +254,8 @@ public class KlConceptStaticFacade {
         RespDTO<KlConceptStaticDTO> respDTO = cdssCoreClient.getRecordById(idVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             klConceptStaticDTO = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
         return klConceptStaticDTO;
     }
@@ -257,6 +271,8 @@ public class KlConceptStaticFacade {
         RespDTO<Boolean> respDTO = cdssCoreClient.isExist(klConceptStaticVO);
         if (RespDTOUtil.respIsOK(respDTO)) {
             exist = respDTO.data;
+        } else {
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, respDTO.msg);
         }
         return exist;
     }

+ 100 - 39
src/main/java/com/diagbot/facade/MappingConfigFacade.java

@@ -410,9 +410,13 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             }
             if (StringUtil.isNotBlank(item.getHisDetailName())) {
                 item.setHisDetailName(item.getHisDetailName().trim());
+            } else {
+                item.setHisDetailName("");
             }
             if (StringUtil.isNotBlank(item.getHisCode())) {
                 item.setHisCode(item.getHisCode().trim());
+            } else {
+                item.setHisCode("");
             }
             item.setUniqueName("");
             dataList.add(item);
@@ -604,19 +608,24 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             for (MappingConfigWrapper item : codeList) {
                 if (item.getIsMatch() != null && item.getIsMatch().equals(1)) {
                     retList.add(item);
+                    continue;
                 }
                 if (configMap.containsKey(item.getHisName())) {
                     Map<String, Map<String, List<String>>> subMap = configMap.get(item.getHisName());
-                    for (Map.Entry<String, Map<String, List<String>>> subEntry : subMap.entrySet()) {
-                        for (String name : subEntry.getValue().keySet()) {
+                    if (subMap != null && subMap.size() > 0) {
+                        Map<String, List<String>> thirdMap = subMap.get(item.getHisDetailName());
+                        if (thirdMap == null || thirdMap.size() == 0) {
+                            retList.add(item);
+                            continue;
+                        }
+                        for (Map.Entry<String, List<String>> thirdEntry : thirdMap.entrySet()) {
                             MappingConfigWrapper historyItem = new MappingConfigWrapper();
                             BeanUtils.copyProperties(item, historyItem);
-                            historyItem.setHisDetailName(subEntry.getKey());
-                            historyItem.setUniqueName(name);
+                            historyItem.setUniqueName(thirdEntry.getKey());
                             historyItem.setIsMatch(1);
                             historyItem.setSource(MatchSourceEnum.History.getKey());
                             if (type.equals(ConceptTypeEnum.Drug.getKey())) {
-                                List<String> forms = subEntry.getValue().get(name);
+                                List<String> forms = thirdEntry.getValue();
                                 if (ListUtil.isEmpty(forms)) {
                                     retList.add(historyItem);
                                 } else {
@@ -632,6 +641,8 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
                             }
                         }
                     }
+                } else {
+                    retList.add(item);
                 }
             }
         } else {
@@ -643,6 +654,9 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
                 item.setIsMatch(0);
             }
         }
+
+        //添加编码
+        retList = addCodes(retList, type);
         return retList;
     }
 
@@ -786,7 +800,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
                     .eq("type", type)
                     .in("his_name", hisNames));
 
-            if (ListUtil.isEmpty(existList)) {
+            if (ListUtil.isNotEmpty(existList)) {
                 List<MappingConfigWrapper> existWrapperList = BeanUtil.listCopyTo(existList, MappingConfigWrapper.class);
                 existWrapperList = addNames(existWrapperList);
                 for (MappingConfigWrapper item : existWrapperList) {
@@ -915,7 +929,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             }
 
             //剂型校验
-            if (type.equals(ConceptTypeEnum.Drug)) {
+            if (type.equals(ConceptTypeEnum.Drug.getKey())) {
                 conceptVO.setType(ConceptTypeEnum.Form.getKey());
                 conceptVO.setNames(tempList.stream()
                         .filter(i -> StringUtil.isNotBlank(i.getForm()))
@@ -1006,7 +1020,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         BeanUtils.copyProperties(item, itemWrapper);
         List<MappingConfigWrapper> retList = Lists.newArrayList();
         retList.add(itemWrapper);
-        addNames(retList);
+        retList = addNames(retList);
 
         return retList.get(0);
     }
@@ -1040,7 +1054,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
 
         retList = BeanUtil.listCopyTo(list, MappingConfigWrapper.class);
 
-        addNames(retList);
+        retList = addNames(retList);
         return retList;
     }
 
@@ -1151,7 +1165,8 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
                 .eq("hospital_id", mappingConfig.getHospitalId())
                 .eq("type", mappingConfig.getType())
                 .eq("his_name", mappingConfig.getHisName())
-                .eq("concept_id", null);
+                .isNull("concept_id")
+                .eq("is_match", 0);
         if (StringUtil.isBlank(mappingConfig.getHisDetailName())) {
             qwUnMaptch.and(i -> i.isNull("his_detail_name")
                     .or()
@@ -1196,8 +1211,12 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             if (StringUtil.isBlank(item.getHisDetailName())) {
                 item.setHisDetailName("");
             }
+            item.setId(null);
+            item.setHospitalId(null);
         }
 
+        list = list.stream().distinct().collect(Collectors.toList());
+
         Map<String, List<MappingConfig>> hisMap = list.stream()
                 .filter(i -> StringUtil.isNotBlank(i.getHisName()))
                 .collect(Collectors.groupingBy(MappingConfig::getHisName));
@@ -1206,8 +1225,11 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
             Map<String, List<MappingConfig>> detailMap = entry.getValue().stream()
                     .collect(Collectors.groupingBy(MappingConfig::getHisDetailName));
             for (Map.Entry<String, List<MappingConfig>> subEntry : detailMap.entrySet()) {
-                subMap.put(subEntry.getKey(), subEntry.getValue().stream().collect(Collectors.groupingBy(MappingConfig::getConceptId,
-                        Collectors.mapping(MappingConfig::getFormConceptId, Collectors.toList()))));
+                subMap.put(subEntry.getKey(),
+                        subEntry.getValue()
+                                .stream()
+                                .collect(Collectors.groupingBy(MappingConfig::getConceptId,
+                                        Collectors.mapping(MappingConfig::getFormConceptId, Collectors.toList()))));
             }
             retMap.put(entry.getKey(), subMap);
         }
@@ -1254,40 +1276,28 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
         RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
         List<IndexBatchDTO> indexList = respDTO.data;
         if (ListUtil.isNotEmpty(indexList)) {
-            Map<Long, List<IndexBatchDTO>> indexMap
-                    = indexList.stream().collect(Collectors.groupingBy(IndexBatchDTO::getId));
+            Map<Long, String> idNameMap
+                    = indexList.stream().collect(Collectors.toMap(IndexBatchDTO::getId, IndexBatchDTO::getName));
             for (Map.Entry<String, Map<String, Map<Long, List<Long>>>> entry : idMap.entrySet()) {
                 Map<String, Map<String, List<String>>> subMap = new HashMap<>();
                 for (Map.Entry<String, Map<Long, List<Long>>> subEntry : entry.getValue().entrySet()) {
                     Map<String, List<String>> thirdMap = new HashMap<>();
-                    List<String> uniqueNames = Lists.newArrayList();
-                    List<String> forms = Lists.newArrayList();
-                    for (Long conceptId : subEntry.getValue().keySet()) {
-                        if (indexMap.containsKey(conceptId)) {
-                            uniqueNames.addAll(indexMap.get(conceptId).stream().map(IndexBatchDTO::getName).collect(Collectors.toList()));
-                        }
-                    }
-                    List<Long> formConceptIds = subEntry.getValue().values()
-                            .stream()
-                            .flatMap(Collection::stream)
-                            .distinct()
-                            .collect(Collectors.toList());
-                    for (Long formConceptId : formConceptIds) {
-                        if (formConceptId == null) {
-                            forms.add("");
-                        } else {
-                            if (indexMap.containsKey(formConceptId)) {
-                                forms.addAll(indexMap.get(formConceptId).stream().map(IndexBatchDTO::getName).collect(Collectors.toList()));
+                    for (Map.Entry<Long, List<Long>> thirdEntry : subEntry.getValue().entrySet()) {
+                        List<Long> formConceptIds = thirdEntry.getValue();
+                        List<String> forms = Lists.newArrayList();
+                        if (ListUtil.isNotEmpty(formConceptIds)) {
+                            for (Long formConceptId : formConceptIds) {
+                                if (formConceptId == null) {
+                                    forms.add("");
+                                } else {
+                                    forms.add(idNameMap.get(formConceptId));
+                                }
                             }
+                            forms = forms.stream().distinct().collect(Collectors.toList());
+                            thirdMap.put(idNameMap.get(thirdEntry.getKey()), forms);
                         }
                     }
-                    forms = forms.stream().distinct().collect(Collectors.toList());
-                    if (ListUtil.isNotEmpty(uniqueNames)) {
-                        for (String uniqueName : uniqueNames) {
-                            thirdMap.put(uniqueName, forms);
-                        }
-                        subMap.put(subEntry.getKey(), thirdMap);
-                    }
+                    subMap.put(subEntry.getKey(), thirdMap);
                 }
                 if (subMap != null && subMap.size() > 0) {
                     retMap.put(entry.getKey(), subMap);
@@ -1424,6 +1434,57 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
     }
 
 
+    /**
+     * 返回结果添加编码
+     *
+     * @param list
+     * @return
+     */
+    public List<MappingConfigWrapper> addCodes(List<MappingConfigWrapper> list, Integer type) {
+        List<MappingConfigWrapper> retList = Lists.newLinkedList();
+        if (ListUtil.isEmpty(list)) {
+            return list;
+        }
+
+        if (!(type.equals(ConceptTypeEnum.Operation.getKey())
+                || type.equals(ConceptTypeEnum.Disease.getKey())
+                || type.equals(ConceptTypeEnum.Tcmdisease.getKey())
+                || type.equals(ConceptTypeEnum.Tcmsyndrome.getKey()))) {
+            return list;
+        }
+
+        List<String> names = list.stream()
+                .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
+                .map(MappingConfigWrapper::getUniqueName)
+                .collect(Collectors.toList());
+
+        ConceptVO conceptVO = new ConceptVO();
+        conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
+        conceptVO.setType(type);
+        conceptVO.setNames(names);
+        RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
+        if (RespDTOUtil.respIsOK(respDTO)) {
+            Map<String, List<String>> conceptMap
+                    = respDTO.data.stream().collect(Collectors.groupingBy(IndexBatchDTO::getName,
+                    Collectors.mapping(IndexBatchDTO::getCode, Collectors.toList())));
+            for (MappingConfigWrapper record : list) {
+                if (StringUtil.isNotBlank(record.getUniqueName())
+                        && conceptMap.containsKey(record.getUniqueName())) {
+                    for (String code : conceptMap.get(record.getUniqueName())) {
+                        MappingConfigWrapper tempRecord = new MappingConfigWrapper();
+                        BeanUtils.copyProperties(record, tempRecord);
+                        tempRecord.setCode(code);
+                        retList.add(tempRecord);
+                    }
+                } else {
+                    retList.add(record);
+                }
+            }
+        }
+        return retList;
+    }
+
+
     /**
      * 医院术语检索
      *