Pārlūkot izejas kodu

自定义病程记录解析html修改,抽取自定义病程记录解析部分公共方法

huj 4 gadi atpakaļ
vecāks
revīzija
9acd676002

+ 2 - 18
trans/src/main/java/com/lantone/qc/trans/beilun/util/BeiLunThreeLevelWardHtmlAnalysis.java

@@ -23,24 +23,8 @@ public class BeiLunThreeLevelWardHtmlAnalysis implements BeiLunHtmlAnalysis {
         String html = args[0];
         String recTitle = args[1];
         Map<String, String> structureMap = Maps.newLinkedHashMap();
-        List<String> htmlText = html2List(html, true);
-        String dateTitle = htmlText.get(0).replaceAll("[   ]", " ");
-        String date = CommonAnalysisUtil.extractDate(dateTitle);
-        if (date != null) {
-            structureMap.put("查房日期", date);
-            String title = dateTitle.replace(date, "").trim();
-            structureMap.put("查房标题", title);
-        }
-        htmlText.remove(0);
-        StringBuffer sb = new StringBuffer();
-        for (String line : htmlText) {
-            String text = line.replaceAll("[   ]", " ");
-            if (text.length() == 0) {
-                continue;
-            }
-            sb.append(text).append("\n");
-        }
-        structureMap.put("病情记录", sb.toString());
+        String htmlText = CommonAnalysisUtil.html2String(html);
+        CommonAnalysisUtil.extractWardInfo(htmlText, structureMap);
         structureMap.put("rec_title=", "5254");
         return structureMap;
     }

+ 29 - 0
trans/src/main/java/com/lantone/qc/trans/beilun/util/CommonAnalysisUtil.java

@@ -303,4 +303,33 @@ public class CommonAnalysisUtil {
             htmlList.remove(index.get(i) - i);
         }
     }
+
+    /**
+     * 抽取自定义病程录信息
+     *
+     * @param html
+     * @param structureMap
+     */
+    public static void extractWardInfo(String html, Map<String, String> structureMap) {
+        String htmlText = CommonAnalysisUtil.html2String(html);
+        if (StringUtil.isNotBlank(htmlText)) {
+            htmlText = htmlText.replaceAll("[   ]", " ");
+            String date = extractDate(htmlText);
+            if (date != null) {
+                structureMap.put("查房日期", date);
+                htmlText = htmlText.replace(date, "").trim();
+            }
+            List<String> titleContent = Lists.newArrayList(htmlText.split(" "));
+            String title = titleContent.get(0);
+            if (StringUtil.isNotBlank(title)) {
+                structureMap.put("查房标题", title);
+                titleContent.remove(0);
+            }
+            StringBuffer sb = new StringBuffer();
+            for (String text : titleContent) {
+                sb.append(text).append(" ");
+            }
+            structureMap.put("病情记录", sb.toString());
+        }
+    }
 }