|
@@ -0,0 +1,109 @@
|
|
|
+package com.lantone.qc.trans.beilun.util;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.lantone.qc.pub.util.FileUtil;
|
|
|
+import com.lantone.qc.pub.util.StringUtil;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+import org.jsoup.nodes.Element;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @author: rengb
|
|
|
+ * @time: 2020/9/15 16:28
|
|
|
+ */
|
|
|
+public class BeiLunBeHospitalizedHtmlAnalysis implements BeiLunHtmlAnalysis {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> analysis(String... args) {
|
|
|
+ String html = args[0];
|
|
|
+ String recTitle = args[1];
|
|
|
+ Document doc = Jsoup.parse(html);
|
|
|
+ Map<String, String> map = Maps.newLinkedHashMap();
|
|
|
+ //个人基础信息table解析
|
|
|
+ BeiLunHtmlAnalysisUtil.tableStyle1InsertMap(doc.getElementById("table1"), map);
|
|
|
+ //主诉、现病史等table解析
|
|
|
+ BeiLunHtmlAnalysisUtil.tableStyle2InsertMap(doc.getElementById("table6"), map);
|
|
|
+ //体 格 检 查 表(一) table解析
|
|
|
+ Element tgjcTableElement = doc.getElementById("table3");
|
|
|
+ BeiLunHtmlAnalysisUtil.tableStyle2InsertMap(tgjcTableElement, map);
|
|
|
+
|
|
|
+ //诊断 table解析
|
|
|
+ String disTableElementId = "table7_2_0_0_1_1_2_0_1_4_5_6_7_0_1";
|
|
|
+ if (recTitle.equals("妇科大病历")) {
|
|
|
+ disTableElementId = "table7_2_0_0_1_1_2_0_1_4_5_6_7_0_1_37";
|
|
|
+ }
|
|
|
+ Element disTableElement = doc.getElementById(disTableElementId);
|
|
|
+ BeiLunHtmlAnalysisUtil.tableStyle1InsertMap(disTableElement, map);
|
|
|
+ disHandleExt(map);
|
|
|
+
|
|
|
+ //医生签名、医生签名时间
|
|
|
+ Element docSignElement = null, docSignTimeElement = null;
|
|
|
+ for (Element disTableElementNt : disTableElement.nextElementSiblings()) {
|
|
|
+ docSignElement = disTableElementNt.selectFirst("image,img");
|
|
|
+ if (docSignElement != null) {
|
|
|
+ docSignTimeElement = disTableElementNt.nextElementSibling();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (docSignElement != null) {
|
|
|
+ map.put("医生签名", docSignElement.outerHtml());
|
|
|
+ }
|
|
|
+ if (docSignTimeElement != null) {
|
|
|
+ map.put("医生签名时间", BeiLunHtmlAnalysisUtil.elementLayer1ToStr(docSignTimeElement, false).trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ //专科检查、辅助检查
|
|
|
+ Element yuElement = new Element("div");
|
|
|
+ for (Element tgjcTableElementNt : tgjcTableElement.nextElementSiblings()) {
|
|
|
+ if (tgjcTableElementNt.id().contains("table7_2_0_0_1_1_2_0_1_4_5_6_7_0_1")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (tgjcTableElementNt.tagName().equals("table")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ tgjcTableElementNt.appendTo(yuElement);
|
|
|
+ }
|
|
|
+ String yuText = BeiLunHtmlAnalysisUtil.blockDivToStr(yuElement, true)
|
|
|
+ .replace("体 格 检 查 表 (二)", "")
|
|
|
+ .replace("(补充及专科情况)", "")
|
|
|
+ .replace("辅 助 检 查", "辅助检查:")
|
|
|
+ .replace("诊断:", "")
|
|
|
+ .replace("补充专科情况", "补充专科情况:")
|
|
|
+ .trim();
|
|
|
+ CommonAnalysisUtil.cutByTitles(yuText, Lists.newArrayList("专科检查", "辅助检查"), 0, map);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void disHandleExt(Map<String, String> map) {
|
|
|
+ String[] keys = { "补充诊断", "修正诊断" };
|
|
|
+ String value = null;
|
|
|
+ int index = 0;
|
|
|
+ for (String key : keys) {
|
|
|
+ value = map.get(key);
|
|
|
+ if (StringUtil.isNotBlank(value)) {
|
|
|
+ for (String key_ : keys) {
|
|
|
+ index = value.indexOf(key_);
|
|
|
+ if (index > 0) {
|
|
|
+ map.put(key_, value.substring(index + 5));
|
|
|
+ map.put(key, value.substring(0, index));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String html = FileUtil.fileRead("C:/Users/Administrator/Desktop/宁波/病例导出/大病历-神经内科-神经内科-2258458.html");
|
|
|
+ String recTitle = "大病历-神经内科";
|
|
|
+ BeiLunBeHospitalizedHtmlAnalysis test = new BeiLunBeHospitalizedHtmlAnalysis();
|
|
|
+ Map<String, String> map = test.analysis(html, recTitle);
|
|
|
+ map.keySet().forEach(key -> {
|
|
|
+ System.out.println(key + "-----" + map.get(key));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+}
|