江豪迪 3 anni fa
parent
commit
47b5a3c5d2

+ 1 - 1
dbanaly/src/main/resources/application-dev.yml

@@ -5,7 +5,7 @@ spring:
     druid:
       lantone:
         driver-class-name: com.mysql.jdbc.Driver
-        url: jdbc:mysql://192.168.2.237:3307/qc?useUnicode=true&characterEncoding=utf8&useSSL=false
+        url: jdbc:mysql://192.168.2.237:3307/qc_xszyy?useUnicode=true&characterEncoding=utf8&useSSL=false
         username: root
         password: lantone
         initial-size: 8

+ 1 - 2
trans/src/main/java/com/lantone/qc/trans/hangzhoufubao/FirstCourseRecordDocTrans.java

@@ -11,7 +11,6 @@ import com.lantone.qc.trans.comsis.CommonAnalysisUtil;
 import com.lantone.qc.trans.comsis.ModelDocGenerate;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import com.lantone.qc.trans.hangzhoufubao.util.FirstCourseRecordHtmlAnalysis;
-import com.lantone.qc.trans.hangzhoufubao.util.HangzhoufubaoFirstCourseRecordHtmlAnalysis;
 import com.lantone.qc.trans.hangzhoufubao.util.HtmlAnalysis;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.MapUtils;
@@ -41,7 +40,7 @@ public class FirstCourseRecordDocTrans extends ModelDocTrans {
             } else {
                 String recTitle = contentMap.get("recTitle").toString();
                 String recTypeId = contentMap.get("recTypeId").toString();
-                HtmlAnalysis hangzhoufubaoHtmlAnalysis = new HangzhoufubaoFirstCourseRecordHtmlAnalysis();
+                HtmlAnalysis hangzhoufubaoHtmlAnalysis = new FirstCourseRecordHtmlAnalysis();
                 Map<String, String> sourceMap = hangzhoufubaoHtmlAnalysis.analysis(content, recTitle, recTypeId);
                 if (MapUtils.isNotEmpty(sourceMap)) {
                     sourceMap = removeSerialNumber(sourceMap);

+ 15 - 39
trans/src/main/java/com/lantone/qc/trans/hangzhoufubao/util/FirstCourseRecordHtmlAnalysis.java

@@ -3,13 +3,12 @@ package com.lantone.qc.trans.hangzhoufubao.util;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.lantone.qc.pub.util.StringUtil;
-import com.lantone.qc.trans.comsis.CommonAnalysisUtil;
+import com.lantone.qc.trans.yuhangsy.util.YuhangsyHtmlAnalysisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description:
@@ -23,52 +22,29 @@ public class FirstCourseRecordHtmlAnalysis implements HtmlAnalysis {
 
     @Override
     public Map<String, String> analysis(String... args) {
+        List<String> strings = Arrays.asList("一、", "二、", "三、", "四、", "五、", "六、", "七、", "八、");
         Map<String, String> structureMap = Maps.newLinkedHashMap();
         try {
-            List<String> titles = Lists.newArrayList("病史特点", "初步诊断", "诊断依据", "鉴别诊断","治疗目标","诊疗计划","医生签名");
             String html = args[0];
             String recTitle = args[1];
+            String recTypeId = args[2];
             Document doc = Jsoup.parse(html);
-            String htmlContent = HtmlAnalysisUtil.blockDivToStr(doc.selectFirst("body").child(0), true)
-                    .replace("第1页", "");
-            CommonAnalysisUtil.extractWardInfo(recTitle, htmlContent, structureMap);
+            List<String> titles = Lists.newArrayList("记录时间","一般情况","病史特点", "初步诊断", "诊断依据", "鉴别诊断","治疗目标","诊疗计划","医生签名");
+            String htmlContent = HtmlAnalysisUtil.blockDivToStr(doc.selectFirst("body").child(0), true);
             if (StringUtil.isNotBlank(htmlContent)) {
-                titles = CommonAnalysisUtil.sortTitles(titles, htmlContent);
-                CommonAnalysisUtil.cutByTitles(htmlContent, titles, 0, structureMap);
-                if (!structureMap.containsKey("诊断依据")) {
-                    String zdyj = "";
-                    if (structureMap.containsKey("西医诊断依据")) {
-                        zdyj += "西医诊断依据:" + structureMap.get("西医诊断依据");
-                    }
-                    if (structureMap.containsKey("中医辨病辨证依据")) {
-                        zdyj += "  中医辨病辨证依据:" + structureMap.get("中医辨病辨证依据");
-                    }
-                    structureMap.put("诊断依据", zdyj);
-                }
-                if (!structureMap.containsKey("鉴别诊断")) {
-                    String jbzd = "";
-                    if (structureMap.containsKey("西医鉴别诊断")) {
-                        jbzd += "西医鉴别诊断:" + structureMap.get("西医鉴别诊断");
-                    }
-                    if (structureMap.containsKey("中医鉴别诊断")) {
-                        jbzd += "  中医鉴别诊断:" + structureMap.get("中医鉴别诊断");
-                    }
-                    structureMap.put("鉴别诊断", jbzd);
-                }
-
-                /*if (structureMap.containsKey("诊疗计划")) {
-                    if (structureMap.get("诊疗计划").indexOf("中医治则") != -1) {
-                        structureMap.put("诊疗计划", structureMap.get("诊疗计划").substring(0, structureMap.get("诊疗计划").indexOf("中医治则")));
-                    }
-                }*/
-                if (structureMap.containsKey("医生签名")) {
-                    if (structureMap.get("医生签名").indexOf("SignControl") != -1) {
-                        structureMap.put("医生签名", structureMap.get("医生签名").substring(0, structureMap.get("医生签名").indexOf("SignControl")));
+                HangzhoufubaoCommonAnalysisUtil.html2StructureMap(titles, htmlContent, structureMap);
+            }
+            for (Map.Entry<String, String> stringStringEntry : structureMap.entrySet()) {
+                for (String string : strings) {
+                    String value = stringStringEntry.getValue();
+                    if (value.endsWith(string)) {
+                        structureMap.put(stringStringEntry.getKey(),value.substring(0, value.length() - string.length()));
+                        break;
                     }
                 }
             }
 
-            HtmlAnalysisUtil.insertModuleId(modeId, recTitle, structureMap);
+            HtmlAnalysisUtil.insertModuleId(modeId, recTypeId, structureMap);
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }

+ 0 - 56
trans/src/main/java/com/lantone/qc/trans/hangzhoufubao/util/HangzhoufubaoFirstCourseRecordHtmlAnalysis.java

@@ -1,56 +0,0 @@
-package com.lantone.qc.trans.hangzhoufubao.util;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.lantone.qc.pub.util.StringUtil;
-import com.lantone.qc.trans.yuhangsy.util.YuhangsyHtmlAnalysis;
-import com.lantone.qc.trans.yuhangsy.util.YuhangsyHtmlAnalysisUtil;
-import com.lantone.qc.trans.yuhangsy.util.comsis.YuhangsyCommonAnalysisUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-
-import java.util.*;
-
-/**
- * @Description:
- * @author: HUJING
- * @time: 2020/9/9 11:24
- */
-@Slf4j
-public class HangzhoufubaoFirstCourseRecordHtmlAnalysis implements HtmlAnalysis {
-
-    private String modeId = "2";
-
-    @Override
-    public Map<String, String> analysis(String... args) {
-        List<String> strings = Arrays.asList("一、", "二、", "三、", "四、", "五、", "六、", "七、", "八、");
-        Map<String, String> structureMap = Maps.newLinkedHashMap();
-        try {
-            String html = args[0];
-            String recTitle = args[1];
-            String recTypeId = args[2];
-            Document doc = Jsoup.parse(html);
-            List<String> titles = Lists.newArrayList("记录时间","一般情况","病史特点", "初步诊断", "诊断依据", "鉴别诊断","治疗目标","诊疗计划","医生签名");
-            String htmlContent = hangzhoufubaoHtmlAnalysisUtil.blockDivToStr2(doc.selectFirst("body").child(0), true);
-            if (StringUtil.isNotBlank(htmlContent)) {
-                HangzhoufubaoCommonAnalysisUtil.html2StructureMap(titles, htmlContent, structureMap);
-            }
-            for (Map.Entry<String, String> stringStringEntry : structureMap.entrySet()) {
-                for (String string : strings) {
-                    String value = stringStringEntry.getValue();
-                    if (value.endsWith(string)) {
-                        structureMap.put(stringStringEntry.getKey(),value.substring(0, value.length() - string.length()));
-                        break;
-                    }
-                }
-            }
-
-            YuhangsyHtmlAnalysisUtil.insertModuleId(modeId, recTypeId, structureMap);
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-        }
-        return structureMap;
-    }
-
-}

+ 0 - 292
trans/src/main/java/com/lantone/qc/trans/hangzhoufubao/util/hangzhoufubaoHtmlAnalysisUtil.java

@@ -1,292 +0,0 @@
-package com.lantone.qc.trans.hangzhoufubao.util;
-
-import com.google.common.collect.Lists;
-import com.lantone.qc.dbanaly.util.ModuleMappingUtil;
-import com.lantone.qc.pub.util.StringUtil;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Description:
- * @author: rengb
- * @time: 2020/9/15 16:31
- */
-public class hangzhoufubaoHtmlAnalysisUtil {
-
-    /**
-     * table样式:key和value在同一个td中,以冒号分开;保留换行
-     *
-     * @param tableElement
-     * @param map
-     */
-    public static void tableStyle1InsertMap(Element tableElement, Map<String, String> map) {
-        if (tableElement == null || map == null) {
-            return;
-        }
-        List<Element> tdElements = Lists.newArrayList();
-        tableElement.selectFirst("tbody").children().forEach(trElement -> {
-            trElement.children().forEach(tdElement -> {
-                tdElements.add(tdElement);
-            });
-        });
-        String tdText = null;
-        int tdMhIndex = 0;
-        for (Element tdElement : tdElements) {
-            if (tdElement.childNodeSize() == 0) {
-                continue;
-            }
-            tdText = blockDivToStr(tdElement.child(0), true);
-            if (tdText.endsWith("\n")) {
-                tdText = tdText.substring(0, tdText.length() - 1);
-            }
-            if (StringUtil.isBlank(tdText)) {
-                continue;
-            }
-            tdMhIndex = tdText.indexOf(":");
-            if (tdMhIndex == -1) {
-                tdMhIndex = tdText.indexOf(":");
-            }
-            if (tdMhIndex < 1) {
-                continue;
-            }
-            if (tdText.contains("姓    名") && tdText.contains("年    龄")) {
-                multiColonResolve(tdMhIndex, tdText, "年    龄", map);
-            } else if (tdText.contains("姓    名") && tdText.contains("年   龄")) {
-                multiColonResolve(tdMhIndex, tdText, "年   龄", map);
-            } else if (tdText.contains("姓    名") && tdText.contains("年  龄")) {
-                multiColonResolve(tdMhIndex, tdText, "年  龄", map);
-            } else if (tdText.contains("姓    名") && tdText.contains("年 龄")) {
-                multiColonResolve(tdMhIndex, tdText, "年 龄", map);
-            } else if (tdText.contains("产前检查") && tdText.contains("孕/产次")) {
-                multiColonResolve(tdMhIndex, tdText, "孕/产次", map);
-            } else if (tdText.contains("末次月经") && tdText.contains("预产期")) {
-                multiColonResolve(tdMhIndex, tdText, "预产期", map);
-            } else {
-                map.put(
-                        StringUtil.removeBlank(tdText.substring(0, tdMhIndex)),
-                        tdText.length() - 1 <= tdMhIndex ? "" : tdText.substring(tdMhIndex + 1)
-                );
-            }
-        }
-    }
-
-    /**
-     * 取得多个字段时,分别存储
-     *
-     * @param tdText
-     * @param text
-     */
-    public static void multiColonResolve(int tdMhIndex, String tdText, String text, Map<String, String> map) {
-        String firstText = tdText.split(text)[0];
-        map.put(
-                StringUtil.removeBlank(firstText.substring(0, tdMhIndex)),
-                firstText.length() - 1 <= tdMhIndex ? "" : firstText.substring(tdMhIndex + 1)
-        );
-        String secondText = tdText.split(text)[1];
-        secondText = secondText.replace(":", "");
-        secondText = secondText.replace(":", "");
-        map.put(StringUtil.removeBlank(text), secondText);
-    }
-
-    /**
-     * table样式:td两两配对,一个key,一个value;不保留换行
-     *
-     * @param tableElement
-     * @param map
-     */
-    public static void tableStyle2InsertMap(Element tableElement, Map<String, String> map) {
-        if (tableElement == null || map == null) {
-            return;
-        }
-        List<Element> tdElements = Lists.newArrayList();
-        tableElement.selectFirst("tbody").children().forEach(trElement -> {
-            if (trElement.childNodeSize() != 2) {
-                return;
-            }
-            trElement.children().forEach(tdElement -> {
-                tdElements.add(tdElement);
-            });
-        });
-        int index = 0;
-        String key = null, value = null, text = null;
-        for (Element tdElement : tdElements) {
-            if (tdElement.childNodeSize() == 0) {
-                text = "";
-            } else {
-                text = blockDivToStr(tdElement.child(0), false);
-            }
-            if (index % 2 == 0) {
-                key = text.replaceAll("[:: ]", "");
-            }
-            if (index % 2 == 1) {
-                value = text;
-                if (StringUtil.isNotBlank(key)) {
-                    map.put(key, value);
-                }
-            }
-            index++;
-        }
-    }
-
-    /**
-     * 一个大的块状div下包含很多行行状div
-     *
-     * @param divElement
-     * @param isLineBreak 是否保留换行
-     * @return
-     */
-    public static String blockDivToStr(Element divElement, boolean isLineBreak) {
-        if (divElement == null) {
-            return "";
-        }
-        StringBuffer sbf = new StringBuffer();
-        for (Element childElement : divElement.children()) {
-            if (isLineBreak) {
-                sbf.append(elementLayer1ToStr(childElement, false)).append("\n");
-            } else {
-                sbf.append(elementLayer1ToStr(childElement, false).trim());
-            }
-        }
-        return sbf.toString();
-    }
-
-    /**
-     * 标签仅遍历第一子层级后转字符串
-     *
-     * @param element
-     * @param isLineBreak 是否保留换行
-     * @return
-     */
-    public static String elementLayer1ToStr(Element element, boolean isLineBreak) {
-        if (element == null) {
-            return "";
-        }
-        StringBuffer sbf = new StringBuffer();
-        List<Element> elements = Lists.newArrayList();
-        Elements childElements = element.children();
-        if (childElements.size() == 0) {
-            elements.add(element);
-        }
-        for (Element childElement : childElements) {
-            elements.add(childElement);
-        }
-        for (Element childElement : elements) {
-            if (childElement.tagName().equals("img") || childElement.tagName().equals("image")) {
-                //                sbf.append(childElement.outerHtml());
-                sbf.append("—");
-            } else {
-                sbf.append(childElement.text());
-            }
-            if (isLineBreak) {
-                sbf.append("\n");
-            }
-        }
-        String sbfString = removeSex(sbf.toString().replaceAll(" ", " "));
-        return sbfString;
-    }
-
-    /**
-     * 查询并插入页面模板id
-     *
-     * @param modeId
-     * @param recTitle
-     * @param map
-     */
-    public static void insertModuleId(String modeId, String recTitle, Map<String, String> map) {
-        if ((StringUtil.isBlank(modeId) && StringUtil.isBlank(recTitle)) || map == null) {
-            return;
-        }
-        String moduleId = ModuleMappingUtil.getHtmlDataTypeModuleId(recTitle);
-        if (StringUtil.isBlank(moduleId)) {
-            moduleId = ModuleMappingUtil.getStandardModuleId(modeId);
-        }
-        map.put("mode_id", moduleId);
-    }
-
-    /**
-     * map中有的value以冒号开头,用此方法来去掉冒号
-     *
-     * @param map
-     */
-    public static void mapValueRemoveStartColon(Map<String, String> map) {
-        if (map == null) {
-            return;
-        }
-        map.keySet().forEach(key -> {
-            if (map.get(key).startsWith(":") || map.get(key).startsWith(":")) {
-                map.put(key, map.get(key).replaceFirst("[::]", ""));
-            }
-        });
-    }
-
-    /**
-     * 北仑:入院记录中性别取得去除"性"
-     * e.g.(性    别:男性 ->性    别:男)
-     *
-     * @param sbfString
-     */
-    public static String removeSex(String sbfString) {
-        if (sbfString.contains("性    别:")) {
-            sbfString = sbfString.substring(0, sbfString.length() - 1);
-        }
-        return sbfString;
-    }
-
-    /**
-     * 杭州妇保自定义xml解析模板(入院记录)
-     * @param divElement
-     * @param isLineBreak 是否保留换行
-     * @return
-     */
-    public static String blockDivToStr2(Element divElement, boolean isLineBreak) {
-        if (divElement == null) {
-            return "";
-        }
-        StringBuffer sbf = new StringBuffer();
-        for (Element childElement : divElement.children()) {
-            if (isLineBreak) {
-                sbf.append(elementLayer1ToStr2(childElement, false)).append("\n");
-            } else {
-                sbf.append(elementLayer1ToStr2(childElement, false).trim());
-            }
-        }
-        return sbf.toString();
-    }
-
-    /**
-     * 余杭三院自定义xml解析模板(入院记录)
-     * @param element
-     * @param isLineBreak 是否保留换行
-     * @return
-     */
-    public static String elementLayer1ToStr2(Element element, boolean isLineBreak) {
-        if (element == null) {
-            return "";
-        }
-        StringBuffer sbf = new StringBuffer();
-        List<Element> elements = Lists.newArrayList();
-        Elements childElements = element.children();
-        if (childElements.size() == 0) {
-            elements.add(element);
-        }
-        for (Element childElement : childElements) {
-            elements.add(childElement);
-        }
-        for (Element childElement : elements) {
-            if (childElement.tagName().equals("img") || childElement.tagName().equals("image")) {
-                //                sbf.append(childElement.outerHtml());
-                sbf.append("—");
-            } else {
-                sbf.append(childElement.text());
-            }
-            if (isLineBreak) {
-                sbf.append("\n");
-            }
-        }
-        String sbfString = removeSex(sbf.toString().replaceAll(" ", " "));
-        return sbfString;
-    }
-}