Browse Source

标注术语数据导入、同义词代码修改

louhr 6 năm trước cách đây
mục cha
commit
28d4c58c74

+ 2 - 2
bigdata-web/src/main/java/org/diagbot/bigdata/common/ApplicationCacheUtil.java

@@ -13,7 +13,7 @@ import java.util.*;
 public class ApplicationCacheUtil {
 
     //词库同义词定义
-    public static Map<String, String> standard_info_synonym_map = null;
+    public static Map<String, Map<String, String>> standard_info_synonym_map = null;
     //词库大小类定义
     public static Map<String, String> standard_info_classify_map = null;
     //树形结构存储大小类
@@ -25,7 +25,7 @@ public class ApplicationCacheUtil {
     //特征性别 年龄过滤等
     public static Map<String, Map<String, ResultMappingFilter>> doc_result_mapping_filter_map = null;
 
-    public static Map<String, String> getStandard_info_synonym_map() {
+    public static Map<String, Map<String, String>> getStandard_info_synonym_map() {
         if (standard_info_synonym_map == null) {
             standard_info_synonym_map = NlpCache.getStandard_info_synonym_map();
         }

+ 1 - 1
bigdata-web/src/main/java/org/diagbot/bigdata/work/AlgorithmCore.java

@@ -52,7 +52,7 @@ public class AlgorithmCore {
                 featuresOrderList = new ArrayList<Map.Entry<String, Float>>();
             } else {
                 //同义词转化
-                featuresMap = resultDataProxy.synonymConvert(request, featuresMap);
+                featuresMap = resultDataProxy.synonymConvert(request, featuresMap, featureTypes[i]);
                 //大小类合并
                 featuresMap = resultDataProxy.resultMerge(request, featuresMap);
                 //按模型计算的概率排序

+ 25 - 7
bigdata-web/src/main/java/org/diagbot/bigdata/work/ResultDataProxy.java

@@ -6,6 +6,7 @@ import org.diagbot.bigdata.dao.model.ResultMappingFilter;
 import org.diagbot.bigdata.util.BigDataConstants;
 import org.diagbot.common.work.FeatureRate;
 import org.diagbot.nlp.feature.FeatureType;
+import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpCache;
 
 import javax.servlet.http.HttpServletRequest;
@@ -95,16 +96,33 @@ public class ResultDataProxy {
         return true;
     }
 
-    public Map<String, Float> synonymConvert(HttpServletRequest request, Map<String, Float> map) {
-//        Map<String, String> standardInfoSynonymMap = (Map<String, String>) request.getServletContext().getAttribute(BigDataConstants.standard_info_synonym_cache);
-        Map<String, String> standardInfoSynonymMap = NlpCache.getStandard_info_synonym_map();
+    public Map<String, Float> synonymConvert(HttpServletRequest request, Map<String, Float> map, String featureType) {
+        Map<String, Map<String, String>> standardInfoSynonymMap = NlpCache.getStandard_info_synonym_map();
         Map<String, Float> result = new HashMap<>();
+        String lexiconId = "";
+        switch (FeatureType.parse(featureType)) {
+            case SYMPTOM:
+                lexiconId = NegativeEnum.SYMPTOM.toString();
+                break;
+            case DIAG:
+                lexiconId = NegativeEnum.DISEASE.toString();
+                break;
+            case VITAL:
+                lexiconId = NegativeEnum.VITAL_RESULT.toString();
+                break;
+            case LIS:
+                lexiconId = NegativeEnum.LIS_TYPE.toString();
+                break;
+            case PACS:
+                lexiconId = NegativeEnum.PACS_NAME.toString();
+                break;
+        }
+        Map<String, String> synonymMap = standardInfoSynonymMap.get(lexiconId);
+        if (synonymMap == null) return map;
+
         String synonym = "";
         for (Map.Entry<String, Float> entry : map.entrySet()) {
-            if (entry.getKey().equals("冠状动脉粥样硬化性心脏病")) {
-                System.out.println("冠状动脉粥样硬化性心脏病");
-            }
-            synonym = standardInfoSynonymMap.get(entry.getKey());
+            synonym = synonymMap.get(entry.getKey());
             if (synonym != null) {
                 if (result.get(synonym) == null) {
                     result.put(synonym, entry.getValue());

+ 4 - 4
nlp-web/src/main/java/org/diagbot/nlp/dao/xml/InfoMapper.xml

@@ -83,8 +83,8 @@
 		<if test="id != null and id != ''">
 				 and t.id = #{id}
 		</if>
-		<if test="rdn != null and rdn != ''">
-				 and t.rdn = #{rdn}
+		<if test="pkDcpv != null and pkDcpv != ''">
+			and t.pk_dcpv = #{pkDcpv}
 		</if>
 		<if test="sex != null and sex != ''">
 				 and t.sex = #{sex}
@@ -117,8 +117,8 @@
 		<if test="id != null and id != ''">
 				 and t.id = #{id}
 		</if>
-		<if test="rdn != null and rdn != ''">
-				 and t.rdn = #{rdn}
+		<if test="pkDcpv != null and pkDcpv != ''">
+				 and t.pk_dcpv = #{pkDcpv}
 		</if>
 		<if test="sex != null and sex != ''">
 				 and t.sex = #{sex}

+ 1 - 1
nlp-web/src/main/resources/application.yml

@@ -12,7 +12,7 @@ spring:
       charset: UTF-8
       enabled: true
   datasource:       # mybatis 配置,使用druid数据源
-    url: jdbc:mysql://192.168.2.235:3306/nlp-web?useUnicode=true&characterEncoding=UTF-8
+    url: jdbc:mysql://192.168.2.235:3306/med-s?useUnicode=true&characterEncoding=UTF-8
     username: root
     password: diagbot@20180822
     type: com.alibaba.druid.pool.DruidDataSource

+ 6 - 0
nlp/pom.xml

@@ -32,6 +32,12 @@
             <artifactId>algorithm</artifactId>
             <version>1.0.0</version>
         </dependency>
+        <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>3.17</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 5 - 3
nlp/src/main/java/org/diagbot/nlp/feature/FeatureAnalyze.java

@@ -49,7 +49,7 @@ public class FeatureAnalyze {
             return null;
         }
         lexemePath = ParticipleUtil.participle(content);
-        lexemePath = replaceLexeme(lexemePath);
+//        lexemePath = replaceLexeme(lexemePath);
         return caseToken.analyze(lexemePath);
     }
 
@@ -61,8 +61,10 @@ public class FeatureAnalyze {
     private LexemePath replaceLexeme(LexemePath<Lexeme> lexemePath) {
         if (NlpCache.standard_info_synonym_map == null) NlpCache.createSynonymCache();
         for (Lexeme l : lexemePath) {
-            if (NlpCache.standard_info_synonym_map.get(l.getText()) != null) {
-                l.setText(NlpCache.standard_info_synonym_map.get(l.getText()));
+
+            if (NlpCache.standard_info_synonym_map.get(l.getProperty()) != null &&
+                    NlpCache.standard_info_synonym_map.get(l.getProperty()).get(l.getText()) != null) {
+                l.setText(NlpCache.standard_info_synonym_map.get(l.getProperty()).get(l.getText()));
             }
         }
         return lexemePath;

+ 1 - 1
nlp/src/main/java/org/diagbot/nlp/participle/ParticipleUtil.java

@@ -81,7 +81,7 @@ public class ParticipleUtil {
                     if (!new_line) {
                         sb.append(separator);
                     }
-                    if (lexeme.getProperty() != null && !"99".equals(lexeme.getProperty())) {
+                    if (lexeme.getProperty() != null && !Constants.word_property_other.equals(lexeme.getProperty())) {
                         sb.append("<font color='blue'>");
                         sb.append(lexeme.getText());
                         if (!StringUtils.isEmpty(lexeme.getConcept()) && hasConcept(lexeme)) {

+ 17 - 16
nlp/src/main/java/org/diagbot/nlp/util/DictUtil.java

@@ -29,15 +29,15 @@ public class DictUtil {
     }
 
     public void writeToDict(String path) {
-        MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med?useUnicode=true&characterEncoding=UTF-8");
+        MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/med-s?useUnicode=true&characterEncoding=UTF-8");
         Connection conn = nlpJdbc.connect();
         Statement st = null;
         ResultSet rs = null;
         try {
             EncrypDES encrypDES = new EncrypDES();
             //所有词典库 不能用concat_group 大小写不区分
-            String sql = "select l_1.name l_1_name, l_1.type_id type_id, l_2.name l_2_name from library_info l_1 " +
-                    "left join library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = 1 ";
+            String sql = "select l_1.name l_1_name, l_1.type_id type_id, l_2.name l_2_name from kl_library_info l_1 " +
+                    "left join kl_library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = 1 ";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
             FileWriter fw = new FileWriter(path + "tc.dict");
@@ -74,26 +74,27 @@ public class DictUtil {
 
             fw.close();
 
-            sql = "SELECT l_1.name l_1_name, l_2.name l_2_name FROM library_info l_1 " +
-                    "left join library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = '1' " +
+            sql = "SELECT l_1.name l_1_name, l_2.name l_2_name, l_1.type_id FROM kl_library_info l_1 " +
+                    "left join kl_library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = '1' " +
                     "where l_1.is_concept = '0'";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
 
-            libraryList = rsToMap(rs, false);
-
             fw = new FileWriter(path + "synonym.dict");
-            for (Map.Entry<String, String> entry : libraryList) {
-                fw.write(encrypDES.encrytor(entry.getKey() + "|" + entry.getValue()));
+            while (rs.next()) {
+                r1 = rs.getString(1);
+                r2 = rs.getString(2);
+                r3 = rs.getString(3);
+                fw.write(encrypDES.encrytor(r1 + "|" + r2 + "|" + r3));
                 fw.write("\n");
             }
             fw.close();
 
-            sql = "SELECT l_1.name l_1_name, l_2.name l_2_name FROM relation r " +
-                    "left join concept c1 on r.start_id = c1.id " +
-                    "left join concept c2 on r.end_id = c2.id " +
-                    "left join library_info l_1 on l_1.id = c1.lib_id " +
-                    "left join library_info l_2 on l_2.id = c2.lib_id where r.relation_id = 3";
+            sql = "SELECT l_1.name l_1_name, l_2.name l_2_name FROM kl_relation r " +
+                    "left join kl_concept c1 on r.start_id = c1.id " +
+                    "left join kl_concept c2 on r.end_id = c2.id " +
+                    "left join kl_library_info l_1 on l_1.id = c1.lib_id " +
+                    "left join kl_library_info l_2 on l_2.id = c2.lib_id where r.relation_id = 3";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
 
@@ -107,8 +108,8 @@ public class DictUtil {
             fw.close();
 
             //推送词典
-            sql = "select l.name, l.type_id from bg_library_prop bp, library_info l " +
-                    "where bp.concept_id = l.concept_id  and l.is_concept = 1 and type_id != 99 and bp.is_push = 1 order by l.name";
+            sql = "select l.lib_name, l.lib_type from kl_concept_common bp, kl_concept l " +
+                    "where bp.concept_id = l.id and l.lib_type != 44 and bp.is_push = 1 order by l.lib_name";
             st = conn.createStatement();
             rs = st.executeQuery(sql);
             libraryList = rsToMap(rs, true);

+ 36 - 45
nlp/src/main/java/org/diagbot/nlp/util/NegativeEnum.java

@@ -4,15 +4,15 @@ package org.diagbot.nlp.util;
  * Created by Administrator on 2017/11/8.
  */
 public enum NegativeEnum {
-    NUMBER("0"), SYMPTOM("1"), SYMPTOM_INDEX("75"), EVENT_TIME("2"), EVENT_TIME_DESC("74"), BODY_PART("3"), PROPERTY("4"), CAUSE("5"), DEEP("6"), DEEP_QUANTIFIER("80"), FEMININE("7"), POSITIVE("8"),
+    NUMBER("0"), SYMPTOM("1"), SYMPTOM_INDEX("41"), EVENT_TIME("2"), EVENT_TIME_DESC("40"), BODY_PART("3"), PROPERTY("4"), CAUSE("5"), DEEP("6"), DEEP_QUANTIFIER("43"), FEMININE("7"), POSITIVE("8"),
     UNIT("9"), MEDICINE("10"), TREATMENT("11"),
-    LIS_TYPE("13"), LIS_NAME("14"), LIS_RESULT("15"), WAY("16"),
-    PACS_NAME("17"), PACS_RESULT("18"),
-    DISEASE("19"), JOIN("20"), POSITION("21"), FAMILY("24"), FOOD("27"), PAST("28"), OPERATION("29"),
-    HABIT("25"), SYMPTOM_PERFORMANCE("32"), NUMBER_QUANTIFIER("33"), FREQUENCY("34"),
-    OTHER("99"),
-    VITAL_INDEX("60"), VITAL_INDEX_VALUE("61"), VITAL_RESULT("62"), VITAL_BODY_PART("63"),
-    ADDRESS("70"), PERSON("72"), PERSON_FEATURE_DESC("73"),
+    LIS_TYPE("12"), LIS_NAME("13"), LIS_RESULT("14"), WAY("15"),
+    PACS_NAME("16"), PACS_RESULT("17"),
+    DISEASE("18"), JOIN("19"), POSITION("20"), FAMILY("21"), FOOD("23"), PAST("24"), OPERATION("25"),
+    SYMPTOM_PERFORMANCE("26"), NUMBER_QUANTIFIER("27"),
+    OTHER("44"),
+    VITAL_INDEX("33"), VITAL_INDEX_VALUE("34"), VITAL_RESULT("35"),
+    ADDRESS("36"), PERSON("38"), PERSON_FEATURE_DESC("39"),
     SCALE("44");
     private String value;
 
@@ -64,91 +64,82 @@ public enum NegativeEnum {
             case "11":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.TREATMENT;
                 break;
-            case "13":
+            case "12":
                 negativeEnum = NegativeEnum.LIS_TYPE;
                 break;
-            case "14":
+            case "13":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.LIS_NAME;
                 break;
-            case "15":
+            case "14":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.LIS_RESULT;
                 break;
-            case "16":
+            case "15":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.WAY;
                 break;
-            case "17":
+            case "16":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.PACS_NAME;
                 break;
-            case "18":
+            case "17":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.PACS_RESULT;
                 break;
-            case "19":
+            case "18":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.DISEASE;
                 break;
-            case "20":
+            case "19":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.JOIN;
                 break;
-            case "21":
+            case "20":
                 negativeEnum = NegativeEnum.POSITION;
                 break;
-            case "24":
+            case "21":
                 negativeEnum = NegativeEnum.FAMILY;
                 break;
-            case "25":
-                negativeEnum = NegativeEnum.HABIT;
-                break;
-            case "27":
+            case "23":
                 negativeEnum = NegativeEnum.FOOD;
                 break;
-            case "28":
+            case "24":
                 negativeEnum = NegativeEnum.PAST;
                 break;
-            case "29":
+            case "25":
                 negativeEnum = NegativeEnum.OPERATION;
                 break;
-            case "32":
+            case "26":
                 negativeEnum = NegativeEnum.SYMPTOM_PERFORMANCE;
                 break;
-            case "33":
+            case "27":
                 negativeEnum = NegativeEnum.NUMBER_QUANTIFIER;
                 break;
-            case "34":
-                negativeEnum = NegativeEnum.FREQUENCY;
-                break;
-            case "44":
-                negativeEnum = NegativeEnum.SCALE;
-                break;
-            case "60":
+//            case "44":
+//                negativeEnum = NegativeEnum.SCALE;
+//                break;
+            case "33":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.VITAL_INDEX;
                 break;
-            case "61":
+            case "34":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.VITAL_INDEX_VALUE;
                 break;
-            case "62":
+            case "35":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.VITAL_RESULT;
                 break;
-            case "63":
-                negativeEnum = org.diagbot.nlp.util.NegativeEnum.VITAL_BODY_PART;
-                break;
-            case "70":
+            case "36":
                 negativeEnum = NegativeEnum.ADDRESS;
                 break;
-            case "72":
+            case "38":
                 negativeEnum = NegativeEnum.PERSON;
                 break;
-            case "73":
+            case "39":
                 negativeEnum = NegativeEnum.PERSON_FEATURE_DESC;
                 break;
-            case "74":
+            case "40":
                 negativeEnum = NegativeEnum.EVENT_TIME_DESC;
                 break;
-            case "75":
+            case "41":
                 negativeEnum = NegativeEnum.SYMPTOM_INDEX;
                 break;
-            case "80":
+            case "43":
                 negativeEnum = NegativeEnum.DEEP_QUANTIFIER;
                 break;
-            case "99":
+            case "44":
                 negativeEnum = org.diagbot.nlp.util.NegativeEnum.OTHER;
                 break;
         }

+ 16 - 3
nlp/src/main/java/org/diagbot/nlp/util/NlpCache.java

@@ -19,7 +19,7 @@ public class NlpCache {
     //推送字典
     public static Map<String, String> standard_info_push_map = null;
     //词库同义词定义
-    public static Map<String, String> standard_info_synonym_map = null;
+    public static Map<String, Map<String, String>> standard_info_synonym_map = null;
     //词库大小类定义
     public static Map<String, String> standard_info_classify_map = null;
     //树形结构存储大小类
@@ -39,7 +39,20 @@ public class NlpCache {
 
     public static void createSynonymCache() {
         Configuration configuration = new DefaultConfig();
-        standard_info_synonym_map = configuration.loadMapDict("synonym.dict");
+        List<String> lines = configuration.readFileContents("synonym.dict");
+
+        String[] line_arr;
+        Map<String, String> map = null;
+        standard_info_synonym_map = new HashMap<>();
+        for (String line : lines) {
+            line_arr = org.apache.commons.lang3.StringUtils.split(line, "\\|");
+            map = standard_info_synonym_map.get(line_arr[2]);
+            if (map == null) {
+                map = new HashMap<>();
+            }
+            map.put(line_arr[0], line_arr[1]);
+            standard_info_synonym_map.put(line_arr[2], map);
+        }
     }
 
     public static void createClassifyCache() {
@@ -106,7 +119,7 @@ public class NlpCache {
         return standard_info_push_map;
     }
 
-    public static Map<String, String> getStandard_info_synonym_map() {
+    public static Map<String, Map<String, String>> getStandard_info_synonym_map() {
         if (standard_info_synonym_map == null) {
             createSynonymCache();
         }

+ 85 - 299
nlp/src/test/java/org/diagbot/nlp/test/ConceptTest.java

@@ -27,24 +27,29 @@ public class ConceptTest {
     private static final String EXCEL_XLS = "xls";
     private static final String EXCEL_XLSX = "xlsx";
 
-    private static final String lis_path = "E:\\git\\docs\\医学知识库\\化验\\化验标准库第一期-邵启华0614.xlsx";
+    private static final String lis_path = "E:\\git\\docs\\医学知识库\\化验\\化验标准库第一期-邵启华0617.xlsx";
     private static final String pacs_path = "E:\\git\\docs\\医学知识库\\辅检\\辅检标准库第一期-邵青华0612.xlsx";
-    private static final String symptom_path = "E:\\git\\docs\\医学知识库\\症状\\症状标准库-王玲0613.xlsx";
-    private static final String drug_path = "E:\\git\\docs\\医学知识库\\药品\\药品标准库-邵启华0515.xlsx";
-    private static final String vital_path = "E:\\git\\docs\\医学知识库\\体征\\体征标准库第一阶段-吕纯0614.xlsx";
-    private static final String part_path = "E:\\git\\docs\\医学知识库\\部位和科室\\部位标准库-最新结构0613.xlsx";
+    private static final String symptom_path = "E:\\git\\docs\\医学知识库\\症状\\症状标准库-王玲0619.xlsx";
+    private static final String drug_path = "E:\\git\\docs\\医学知识库\\药品\\药品标准库-邵启华0618.xlsx";
+    private static final String vital_path = "E:\\git\\docs\\医学知识库\\体征\\体征标准库第一阶段-吕纯0618.xlsx";
+    private static final String part_path = "E:\\git\\docs\\医学知识库\\部位和科室\\部位标准库-最新结构0617.xlsx";
     private static final String disease_path = "E:\\git\\docs\\医学知识库\\诊断名和治疗方案\\知识库标准疾病名称和疾病治疗方案-邵青华0605.xlsx";
     private static final String dept_path = "E:\\git\\docs\\医学知识库\\部位和科室\\科室标准库-邵启华0521.xlsx";
+    private static final String scale_path = "E:\\git\\docs\\医学知识库\\量表\\量表标准词-邵青华0618.xlsx";
+    private static final String other_path = "E:\\git\\docs\\医学知识库\\其他史\\其他史-邵青华0619.xls";
 
     public static void main(String[] args) {
         try {
-//            insertSymptom();
+            insertSymptom();
 //            insertPart();
 //            insertVital();
 //            insertLis();
 //            insertPacs();
 //            insertDisease();
 //            insertDept();
+//            insertDrug();
+//            insertScale();
+//            insertOther();
 
 //            insertStandardInfo();
 //            validateSplit();
@@ -54,176 +59,22 @@ public class ConceptTest {
         }
     }
 
-    public static void validateSplit() {
-        MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med-0606?useUnicode=true&characterEncoding=UTF-8");
-        List<Map<String, String>> data = nlpJdbc.query("library_info", new String[]{"id", "name"}, "");
-
-        Map<String, String> all_words = new HashMap<>();
-        for (Map<String, String> map : data) {
-            all_words.put(map.get("name"), map.get("name"));
-        }
-
-        nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-rule?useUnicode=true&characterEncoding=UTF-8");
-        data = nlpJdbc.query("medicine_rule_split", new String[]{"id", "split_word"}, "");
-        String[] names = null;
-        List<String> notin_words = new ArrayList<>();
-        for (Map<String, String> map : data) {
-            names = map.get("split_word").split(",");
-            for (int i = 0; i < names.length; i++) {
-                if (all_words.get(names[i]) == null) {
-                    notin_words.add(names[i]);
-                    all_words.put(names[i], names[i]);
-                }
-            }
-        }
-
-        List<Map<String, Object>> notin_words_list = new ArrayList<>();
-        for (String word : notin_words) {
-            Map<String, Object> line = new HashMap<>();
-            line.put("name", word);
-            notin_words_list.add(line);
-        }
-        nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med-0606?useUnicode=true&characterEncoding=UTF-8");
-        nlpJdbc.insert(notin_words_list, "kl_standard_notin", new String[]{"name"});
-
+    public static void insertScale() throws Exception {
+        insertOneColumn(0, scale_path, 0, "48", "量表");
+        insertOneColumn(1, scale_path, 0, "49", "不良反应");
+        insertOneColumn(2, scale_path, 0, "50", "核心指标");
     }
 
     public static void insertDept() throws Exception {
-        File excelFile = new File(dept_path); // 创建文件对象
-        FileInputStream in = new FileInputStream(excelFile); // 文件流
-        Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(0);
-
-        int count = 0;
-        Map<String, String> concept_words = new HashMap<>();
-        Map<String, String> all_words = new HashMap<>();
-        for (Row row : sheet) {
-            // 跳过第一和第二行的目录
-            if (count < 1) {
-                count++;
-                continue;
-            }
-            count++;
-            try {
-                Cell cell0 = row.getCell(0);
-                if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
-                    concept_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                    all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                }
-                Cell cell1 = row.getCell(1);
-                if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
-                    all_words.put(cell1.getStringCellValue(), cell0.getStringCellValue());
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                System.out.println("第" + count + "出现错误!");
-            }
-        }
-
-        List<Map<String, Object>> all_words_list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : all_words.entrySet()) {
-            Map<String, Object> line = new HashMap<>();
-            if (StringUtils.isNotEmpty(entry.getKey())) {
-                line.put("name", entry.getKey());
-                line.put("type_id", "47");
-                line.put("type", "科室");
-                all_words_list.add(line);
-            }
-        }
-
-        insertLibraryInfo(all_words_list, all_words, concept_words);
+        insertTwoColumn(dept_path, 0, 1, "47", "科室");
     }
 
     public static void insertSymptom() throws Exception {
-        File excelFile = new File(symptom_path); // 创建文件对象
-        FileInputStream in = new FileInputStream(excelFile); // 文件流
-        Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(1);
-
-        int count = 0;
-        Map<String, String> concept_words = new HashMap<>();
-        Map<String, String> all_words = new HashMap<>();
-        for (Row row : sheet) {
-            // 跳过第一和第二行的目录
-            if (count < 1) {
-                count++;
-                continue;
-            }
-            count++;
-            try {
-                Cell cell0 = row.getCell(0);
-                if (cell0 != null && !"".equals(cell0.getStringCellValue())) {
-                    put(concept_words, cell0);
-                    all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                }
-                Cell cell1 = row.getCell(1);
-                if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
-                    all_words.put(cell1.getStringCellValue(), cell0.getStringCellValue());
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                System.out.println("第" + count + "出现错误!");
-            }
-        }
-
-        List<Map<String, Object>> all_words_list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : all_words.entrySet()) {
-            Map<String, Object> line = new HashMap<>();
-            if (StringUtils.isNotEmpty(entry.getKey())) {
-                line.put("name", entry.getKey());
-                line.put("type_id", "1");
-                line.put("type", "症状");
-                all_words_list.add(line);
-            }
-        }
-
-        insertLibraryInfo(all_words_list, all_words, concept_words);
+        insertTwoColumn(1, symptom_path, 0, 1, "1", "症状");
     }
 
     public static void insertPart() throws Exception {
-        File excelFile = new File(part_path); // 创建文件对象
-        FileInputStream in = new FileInputStream(excelFile); // 文件流
-        Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(0);
-
-        int count = 0;
-        Map<String, String> concept_words = new HashMap<>();
-        Map<String, String> all_words = new HashMap<>();
-        for (Row row : sheet) {
-            // 跳过第一和第二行的目录
-            if (count < 1) {
-                count++;
-                continue;
-            }
-            count++;
-            try {
-                Cell cell0 = row.getCell(1);
-                if (cell0 != null && !"".equals(cell0.getStringCellValue())) {
-                    concept_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                    all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                }
-                Cell cell1 = row.getCell(0);
-                if (cell1 != null && !"".equals(cell1.getStringCellValue())) {
-                    all_words.put(cell1.getStringCellValue(), cell0.getStringCellValue());
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                System.out.println("第" + count + "出现错误!");
-            }
-        }
-
-        List<Map<String, Object>> all_words_list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : all_words.entrySet()) {
-            Map<String, Object> line = new HashMap<>();
-            if (StringUtils.isNotEmpty(entry.getKey())) {
-                line.put("name", entry.getKey());
-                line.put("type_id", "3");
-                line.put("type", "部位");
-                all_words_list.add(line);
-            }
-        }
-
-        insertLibraryInfo(all_words_list, all_words, concept_words);
+        insertTwoColumn(part_path, 0, 1, "3", "部位");
     }
 
     public static void insertVital() throws Exception {
@@ -239,16 +90,43 @@ public class ConceptTest {
     }
 
     public static void insertLisMeal() throws Exception {
-        File excelFile = new File(lis_path); // 创建文件对象
-        FileInputStream in = new FileInputStream(excelFile); // 文件流
-        Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(0);
+        insertTwoColumn(lis_path, 0, 1, "12", "化验套餐");
+    }
+
+    public static void insertLisDetail() throws Exception {
+        insertTwoColumn(lis_path, 2, 3, "13", "化验明细");
+    }
+
+    public static void insertLisPublic() throws Exception {
+        insertOneColumn(lis_path, 4, "46", "化验公表项");
+    }
+
+    public static void insertOther() throws Exception {
+        insertOneColumn(other_path, 0, "55", "既往疾病史");
+        insertOneColumn(other_path, 1, "56", "外伤史");
+        insertOneColumn(other_path, 2, "57", "手术史");
+        insertOneColumn(other_path, 3, "58", "输血史");
+        insertOneColumn(other_path, 4, "59", "传染病史");
+        insertOneColumn(other_path, 5, "60", "不良习惯");
+        insertOneColumn(other_path, 6, "61", "冶游史");
+        insertOneColumn(other_path, 7, "62", "婚育史");
+        insertOneColumn(other_path, 8, "63", "生育史");
+        insertOneColumn(other_path, 9, "64", "家族史");
+        insertOneColumn(other_path, 10, "65", "食物过敏史");
+        insertOneColumn(other_path, 11, "66", "药物过敏史");
+        insertOneColumn(other_path, 12, "67", "家族相关传染病史");
 
+    }
+
+    public static void insertOneColumn(String path, int columnIndex, String typeId, String typeName) throws Exception {
+        insertOneColumn(0, path, columnIndex, typeId, typeName);
+    }
+
+    public static void insertOneColumn(int sheetIndex, String path, int columnIndex, String typeId, String typeName) throws Exception {
+        Sheet sheet = loadSheet(path, sheetIndex);
         int count = 0;
         Map<String, String> concept_words = new HashMap<>();
         Map<String, String> all_words = new HashMap<>();
-
-        String[] self = null;
         for (Row row : sheet) {
             // 跳过第一和第二行的目录
             if (count < 1) {
@@ -257,17 +135,10 @@ public class ConceptTest {
             }
             count++;
             try {
-                Cell cell0 = row.getCell(0);
-                Cell cell1 = row.getCell(1);
-                if (cell0 != null && !"".equals(cell0.getStringCellValue())) {
-                    put(concept_words, cell0);
-                    all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                }
-                if (cell1 != null && StringUtils.isNotEmpty(cell1.getStringCellValue())) {
-                    self = cell1.getStringCellValue().split("、");
-                    for (int i = 0; i < self.length; i++) {
-                        all_words.put(self[i], cell0.getStringCellValue());
-                    }
+                Cell cell = row.getCell(columnIndex);
+                if (cell != null && StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                    all_words.put(cell.getStringCellValue().trim(), cell.getStringCellValue().trim());
+                    concept_words.put(cell.getStringCellValue().trim(), cell.getStringCellValue().trim());
                 }
             } catch (Exception e) {
                 e.printStackTrace();
@@ -275,25 +146,15 @@ public class ConceptTest {
             }
         }
 
-        List<Map<String, Object>> all_words_list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : all_words.entrySet()) {
-            Map<String, Object> line = new HashMap<>();
-            if (StringUtils.isNotEmpty(entry.getKey())) {
-                line.put("name", entry.getKey());
-                line.put("type_id", "12");
-                line.put("type", "化验套餐");
-                all_words_list.add(line);
-            }
-        }
+        convertAndSave(typeId, typeName, all_words, concept_words);
+    }
 
-        insertLibraryInfo(all_words_list, all_words, concept_words);
+    public static void  insertTwoColumn(String path, int columnIndex0, int columnIndex1, String typeId, String typeName) throws Exception {
+        insertTwoColumn(0, path, columnIndex0, columnIndex1, typeId, typeName);
     }
 
-    public static void insertLisDetail() throws Exception {
-        File excelFile = new File(lis_path); // 创建文件对象
-        FileInputStream in = new FileInputStream(excelFile); // 文件流
-        Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(0);
+    public static void  insertTwoColumn(int sheetIndex, String path, int columnIndex0, int columnIndex1, String typeId, String typeName) throws Exception {
+        Sheet sheet = loadSheet(path, sheetIndex);
 
         int count = 0;
         Map<String, String> concept_words = new HashMap<>();
@@ -308,16 +169,16 @@ public class ConceptTest {
             }
             count++;
             try {
-                Cell cell2 = row.getCell(2);
-                Cell cell3 = row.getCell(3);
-                if (cell2 != null && StringUtils.isNotEmpty(cell2.getStringCellValue())) {
-                    put(concept_words, cell2);
-                    all_words.put(cell2.getStringCellValue(), cell2.getStringCellValue());
+                Cell cell0 = row.getCell(columnIndex0);
+                Cell cell1 = row.getCell(columnIndex1);
+                if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
+                    concept_words.put(cell0.getStringCellValue().trim(), cell0.getStringCellValue().trim());
+                    all_words.put(cell0.getStringCellValue().trim(), cell0.getStringCellValue().trim());
                 }
-                if (cell3 != null && StringUtils.isNotEmpty(cell3.getStringCellValue())) {
-                    self = cell3.getStringCellValue().split("、");
+                if (cell1 != null && StringUtils.isNotEmpty(cell1.getStringCellValue()) && cell0 != null) {
+                    self = cell1.getStringCellValue().split("、");
                     for (int i = 0; i < self.length; i++) {
-                        all_words.put(self[i], cell2.getStringCellValue());
+                        all_words.put(self[i].trim(), cell0.getStringCellValue().trim());
                     }
                 }
             } catch (Exception e) {
@@ -326,61 +187,28 @@ public class ConceptTest {
             }
         }
 
-        List<Map<String, Object>> all_words_list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : all_words.entrySet()) {
-            Map<String, Object> line = new HashMap<>();
-            if (StringUtils.isNotEmpty(entry.getKey())) {
-                line.put("name", entry.getKey());
-                line.put("type_id", "13");
-                line.put("type", "化验明细");
-                all_words_list.add(line);
-            }
-        }
-
-        insertLibraryInfo(all_words_list, all_words, concept_words);
+        convertAndSave(typeId, typeName, all_words, concept_words);
     }
 
-    public static void insertLisPublic() throws Exception {
-        File excelFile = new File(lis_path); // 创建文件对象
+    public static Sheet loadSheet(String path, int sheetIndex) throws Exception {
+        File excelFile = new File(path); // 创建文件对象
         FileInputStream in = new FileInputStream(excelFile); // 文件流
         Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(0);
-
-        int count = 0;
-        Map<String, String> concept_words = new HashMap<>();
-        Map<String, String> all_words = new HashMap<>();
-
-        String[] self = null;
-        for (Row row : sheet) {
-            // 跳过第一和第二行的目录
-            if (count < 1) {
-                count++;
-                continue;
-            }
-            count++;
-            try {
-                Cell cell4 = row.getCell(4);
-                if (cell4 != null && StringUtils.isNotEmpty(cell4.getStringCellValue())) {
-                    concept_words.put(cell4.getStringCellValue(), cell4.getStringCellValue());
-                    all_words.put(cell4.getStringCellValue(), cell4.getStringCellValue());
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                System.out.println("第" + count + "出现错误!");
-            }
-        }
+        Sheet sheet = workbook.getSheetAt(sheetIndex);
+        return sheet;
+    }
 
+    public static void convertAndSave(String typeId, String typeName, Map<String, String> all_words, Map<String, String> concept_words) {
         List<Map<String, Object>> all_words_list = new ArrayList<>();
         for (Map.Entry<String, String> entry : all_words.entrySet()) {
             Map<String, Object> line = new HashMap<>();
             if (StringUtils.isNotEmpty(entry.getKey())) {
                 line.put("name", entry.getKey());
-                line.put("type_id", "46");
-                line.put("type", "化验公表项");
+                line.put("type_id", typeId);
+                line.put("type", typeName);
                 all_words_list.add(line);
             }
         }
-
         insertLibraryInfo(all_words_list, all_words, concept_words);
     }
 
@@ -453,58 +281,15 @@ public class ConceptTest {
     }
 
     public static void insertDisease() throws Exception {
-        File excelFile = new File(disease_path); // 创建文件对象
-        FileInputStream in = new FileInputStream(excelFile); // 文件流
-        Workbook workbook = getWorkbok(in, excelFile);
-        Sheet sheet = workbook.getSheetAt(0);
-
-        int count = 0;
-        Map<String, String> concept_words = new HashMap<>();
-        Map<String, String> all_words = new HashMap<>();
-
-        String[] self = null;
-        for (Row row : sheet) {
-            // 跳过第一和第二行的目录
-            if (count < 1) {
-                count++;
-                continue;
-            }
-            count++;
-            try {
-                Cell cell0 = row.getCell(0);
-                Cell cell1 = row.getCell(1);
-                if (cell0 != null && StringUtils.isNotEmpty(cell0.getStringCellValue())) {
-                    concept_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                    all_words.put(cell0.getStringCellValue(), cell0.getStringCellValue());
-                }
-                if (cell1 != null && StringUtils.isNotEmpty(cell1.getStringCellValue()) && cell0 != null) {
-                    self = cell1.getStringCellValue().split("、");
-                    for (int i = 0; i < self.length; i++) {
-                        all_words.put(self[i], cell0.getStringCellValue());
-                    }
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-                System.out.println("第" + count + "出现错误!");
-            }
-        }
-
-        List<Map<String, Object>> all_words_list = new ArrayList<>();
-        for (Map.Entry<String, String> entry : all_words.entrySet()) {
-            Map<String, Object> line = new HashMap<>();
-            if (StringUtils.isNotEmpty(entry.getKey())) {
-                line.put("name", entry.getKey());
-                line.put("type_id", "18");
-                line.put("type", "疾病");
-                all_words_list.add(line);
-            }
-        }
-
-        insertLibraryInfo(all_words_list, all_words, concept_words);
+        insertTwoColumn(disease_path, 0, 1, "18", "疾病");
     }
 
     public static void insertDrug() throws Exception {
-
+        insertTwoColumn(drug_path, 0, 1, "53", "药品化学名");
+        insertTwoColumn(drug_path, 2, 3, "10", "药品通用名");
+        insertOneColumn(drug_path, 4, "54", "药品商品名");
+        insertOneColumn(drug_path, 5, "29", "药品大类");
+        insertOneColumn(drug_path, 6, "30", "药品小类");
     }
 
     public static void insertVitalIndex() throws Exception {
@@ -732,6 +517,7 @@ public class ConceptTest {
             initInsertLine(line, updateDate);
         }
         MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/med-s?useUnicode=true&characterEncoding=UTF-8");
+//        MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/diagbot-med-0606?useUnicode=true&characterEncoding=UTF-8");
         int[] infoIds = nlpJdbc.insertBatch(list, "kl_library_info", new String[]{"name", "type_id", "is_concept", "creator", "modifier", "gmt_create", "gmt_modified", "is_deleted"});
 
         List<Map<String, Object>> concept_words_list = new ArrayList<>();