Ver código fonte

1、收集测试数据中的临床表现、修饰、疾病数据,分别存入Mysql中

louhr 5 anos atrás
pai
commit
a42e4aeaf1

+ 7 - 2
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessClinic.java

@@ -2,9 +2,8 @@ package com.lantone.qc.kernel.structure.ai.process;
 
 
 import com.alibaba.fastjson.JSONObject;
-import com.lantone.qc.kernel.structure.ai.model.CrfOut;
 import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
-import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.kernel.util.KernelConstants;
 import com.lantone.qc.pub.model.entity.*;
 import org.apache.commons.lang3.StringUtils;
 
@@ -29,6 +28,9 @@ public class EntityProcessClinic extends EntityProcess {
                 switch (EntityEnum.parseOfValue(key)){
                     case CLINICAL_FEATURE:
                         clinical.setName(clinicalEntityEntry.get(key));
+                        if (!KernelConstants.clinicNameList.contains(clinicalEntityEntry.get(key))) {
+                            KernelConstants.clinicNameList.add(clinicalEntityEntry.get(key));
+                        }
                         break;
                     case NEGATIVE:
                         Negative negative = new Negative();
@@ -38,6 +40,9 @@ public class EntityProcessClinic extends EntityProcess {
                     case MODIFICATION:
                         Modification modification = new Modification();
                         modification.setName(entity);
+                        if (!KernelConstants.clinicModificationList.contains(entity)) {
+                            KernelConstants.clinicModificationList.add(entity);
+                        }
                         clinical.setModification(modification);
                         break;
 

+ 51 - 41
kernel/src/main/java/com/lantone/qc/kernel/util/CacheFileManager.java

@@ -72,22 +72,16 @@ public class CacheFileManager {
             }
 
             //所有词典库 不能用concat_group 大小写不区分
-            sql = "select l_1.name l_1_name, l_1.type_id type_id, l_2.name l_2_name, \n" +
-                    "kc.lib_name, dis.is_chronic, dis.is_infections, group_concat(l_1.name) group_name, l_1.concept_id \n" +
-                    "from kl_library_info l_1\n" +
-                    "left join kl_library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = 1\n" +
-                    "left join kl_concept kc on l_1.concept_id = kc.id\n" +
-                    "left join kl_disease dis on l_1.concept_id = dis.concept_id\n" +
-                    "where kc.is_deleted = 'N' and l_1.type_id = 18 group by l_1.concept_id";
+            sql = "select dis.name, dis.is_chronic, dis.is_infections, dis.name group_name from kl_disease dis " +
+                    "where kc.is_deleted = 'N' order by name";
 
             FileWriter fw = new FileWriter(path + "concept_diag_properties.dict");
             rs = st.executeQuery(sql);
             while (rs.next()) {
-                r1 = rs.getString(4);
-                r2 = rs.getString(5);
-                r3 = rs.getString(6);
-                r4 = rs.getString(7);
-                r5 = rs.getString(8);
+                r1 = rs.getString(1);
+                r2 = rs.getString(2);
+                r3 = rs.getString(3);
+                r4 = rs.getString(4);
 
 //                r1 = CryptUtil.decrypt_char(r1==null?"":r1);
                 r1 = r1==null?"":r1;
@@ -95,7 +89,7 @@ public class CacheFileManager {
                 r3 = r3==null?"0":r3;
 //                r4 = CryptUtil.decrypt_char(r4==null?"":r4);
                 r4 = r4==null?"":r4;
-                r5 = map.get(r5) == null ? "" : map.get(r5);
+                r5 = map.get(r1) == null ? "" : map.get(r1);
 
                 fw.write(encrypDES.encrytor(r1 + "|" + r2 + "|" + r3 + "|" + r4 + "|" + r5));
                 fw.write("\n");
@@ -103,12 +97,7 @@ public class CacheFileManager {
             fw.close();
 
             //需要部位的症状信息
-            sql = "select l_1.name l_1_name \n" +
-                    "from kl_library_info l_1\n" +
-                    "left join kl_library_info l_2 on l_1.concept_id = l_2.concept_id and l_2.is_concept = 1\n" +
-                    "left join kl_concept kc on l_1.concept_id = kc.id\n" +
-                    "left join kl_clinic cli on l_1.concept_id = cli.concept_id\n" +
-                    "where kc.is_deleted = 'N' and l_1.type_id = 1 and cli.has_bodypart = '1' group by l_1.concept_id";
+            sql = "select name from kl_clinic  where has_bodypart = '1'";
 
             fw = new FileWriter(path + "concept_clinic_bodypart_properties.dict");
             rs = st.executeQuery(sql);
@@ -123,7 +112,7 @@ public class CacheFileManager {
             fw.close();
 
             //性质词典
-            sql = "select name from kl_library_info where type_id = 4";
+            sql = "select name from kl_modification where type_id = 4";
             fw = new FileWriter(path + "concept_prop.dict");
             rs = st.executeQuery(sql);
             while (rs.next()) {
@@ -136,12 +125,38 @@ public class CacheFileManager {
             fw.close();
 
             //程度词典
-            sql = "select name from kl_library_info where type_id = 6";
+            sql = "select name from kl_modification where type_id = 6";
             fw = new FileWriter(path + "concept_degree.dict");
             rs = st.executeQuery(sql);
             while (rs.next()) {
                 r1 = rs.getString(1);
                 r1 = r1==null?"":r1;
+//                r1 = CryptUtil.decrypt_char(r1==null?"":r1);
+                fw.write(encrypDES.encrytor(r1));
+                fw.write("\n");
+            }
+            fw.close();
+
+            //加剧词典
+            sql = "select name from kl_modification where type_id = 1";
+            fw = new FileWriter(path + "concept_aggravate.dict");
+            rs = st.executeQuery(sql);
+            while (rs.next()) {
+                r1 = rs.getString(1);
+                r1 = r1==null?"":r1;
+//                r1 = CryptUtil.decrypt_char(r1==null?"":r1);
+                fw.write(encrypDES.encrytor(r1));
+                fw.write("\n");
+            }
+            fw.close();
+
+            //缓解词典
+            sql = "select name from kl_modification where type_id = 2";
+            fw = new FileWriter(path + "concept_relief.dict");
+            rs = st.executeQuery(sql);
+            while (rs.next()) {
+                r1 = rs.getString(1);
+                r1 = r1==null?"":r1;
 //                r1 = CryptUtil.decrypt_char(r1==null?"":r1);
                 fw.write(encrypDES.encrytor(r1));
                 fw.write("\n");
@@ -158,27 +173,22 @@ public class CacheFileManager {
         }
     }
 
-    private List<Map.Entry<String, String>> rsToMap(ResultSet rs, boolean isJoin) throws SQLException {
-        String r1 = "";
-        String r2 = "";
-        Map<String, String> libraryMap = new HashMap<>(10);
-        while (rs.next()) {
-//            r1 = CryptUtil.decrypt_char(rs.getString(1));
-//            r2 = CryptUtil.decrypt_char(rs.getString(2));
-            if (libraryMap.get(r1) == null) {
-                libraryMap.put(r1, r2);
-            } else if (isJoin && libraryMap.get(r1) != null) {
-                libraryMap.put(r1, libraryMap.get(r1) + "," + r2);
-            }
-        }
+    public void insertFeature(List<String> record, String tableName, String col) {
+        MysqlJdbc nlpJdbc = new MysqlJdbc(user, password, url);
 
-        List<Map.Entry<String, String>> libraryList = new ArrayList<Map.Entry<String, String>>(libraryMap.entrySet());
-        Collections.sort(libraryList, new Comparator<Map.Entry<String, String>>() {
-            public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
-                return o1.getKey().compareTo(o2.getKey());
+        List<String> hasLabelsList = new ArrayList<>();
+        List<Map<String, String>> queryResult = nlpJdbc.query(tableName, new String[]{"name"});
+        for (Map<String, String> map : queryResult) {
+            hasLabelsList.add(map.get(col));
+        }
+        List<Map<String, Object>> data = new ArrayList<>();
+        for (String s : record) {
+            Map<String, Object> obj = new HashMap<>();
+            if (!hasLabelsList.contains(s)) {
+                obj.put(col, s);
+                data.add(obj);
             }
-        });
-
-        return libraryList;
+        }
+        nlpJdbc.insert(data, tableName, new String[]{col});
     }
 }

+ 3 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/DiagEnhancer.java

@@ -17,6 +17,9 @@ public class DiagEnhancer {
         enhancer.setSuperclass(Diag.class);
         //设置回调函数
         enhancer.setCallback(new DiagMethodInterceptor());
+        if (!KernelConstants.hospitalDiagNameList.contains(hospitalDiagName)) {
+            KernelConstants.hospitalDiagNameList.add(hospitalDiagName);
+        }
 
         Diag proxyDiag = (Diag) enhancer.create();
         proxyDiag.setHospitalDiagName(hospitalDiagName);

+ 9 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/KernelConstants.java

@@ -1,5 +1,10 @@
 package com.lantone.qc.kernel.util;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @ClassName : KernelConstants
  * @Description : 业务常数类定义
@@ -17,4 +22,8 @@ public class KernelConstants {
     public static final String CONCEPT_CLINIC_BODYPART_PROPERTIES_LIST = "concept_clinic_bodypart_properties_list";
     //诊断名称映射
     public static final String CONCEPT_DIAG_HOSPITAL_REFLECT = "concept_diag_hospital_reflect";
+
+    public static List<String> hospitalDiagNameList = new ArrayList<>();
+    public static List<String> clinicModificationList = new ArrayList<>();
+    public static List<String> clinicNameList = new ArrayList<>();
 }

+ 9 - 0
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCTestController.java

@@ -2,6 +2,8 @@ package com.lantone.qc.kernel.web.controller;
 
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.analysis.QCAnalysis;
+import com.lantone.qc.kernel.util.CacheFileManager;
+import com.lantone.qc.kernel.util.KernelConstants;
 import com.lantone.qc.pub.jdbc.MysqlJdbc;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.vo.MedrecVo;
@@ -163,6 +165,13 @@ public class QCTestController {
 
             mysqlJdbc.update("qc_inputcases_mapping_all", updates, wheres);
 
+
+
+            CacheFileManager cacheFileManager = new CacheFileManager();
+            cacheFileManager.insertFeature(KernelConstants.clinicModificationList, "kl_modification", "name");
+            cacheFileManager.insertFeature(KernelConstants.clinicNameList, "kl_clinic", "name");
+            cacheFileManager.insertFeature(KernelConstants.hospitalDiagNameList, "kl_disease", "name");
+
         } catch (SQLException sqle) {
             sqle.printStackTrace();
         } catch (Exception e) {