|
@@ -0,0 +1,124 @@
|
|
|
+package com.lantone.qc.trans.ningbozhongyi.util;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.lantone.qc.pub.util.MapUtil;
|
|
|
+import com.lantone.qc.pub.util.StringUtil;
|
|
|
+import com.lantone.qc.trans.beilun.util.BeiLunHtmlAnalysis;
|
|
|
+import com.lantone.qc.trans.beilun.util.BeiLunHtmlAnalysisUtil;
|
|
|
+import com.lantone.qc.trans.comsis.CommonAnalysisUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.MapUtils;
|
|
|
+import org.jsoup.Jsoup;
|
|
|
+import org.jsoup.nodes.Document;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: 知情同意书html解析
|
|
|
+ * @author: HUJING
|
|
|
+ * @time: 2020/9/14 15:41
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public class NingBoZhongYiInformedHtmlAnalysis implements NingBoZhongYiHtmlAnalysis {
|
|
|
+
|
|
|
+ private String modeId = "53";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> analysis(String... args) {
|
|
|
+ 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 = BeiLunHtmlAnalysisUtil.blockDivToStr(doc.selectFirst("body").child(0), false);
|
|
|
+ if (StringUtil.isNotBlank(recTitle) && recTitle.contains("知情选择授权书")) {
|
|
|
+ structureMap.put("标题", recTitle);
|
|
|
+ return structureMap;
|
|
|
+ } else if ("自费服务项目、药品、材料使用知情同意书".equals(recTitle)) {
|
|
|
+ if (html.contains("自费服务项目、药品、材料使用知情同意书") && html.split("自费服务项目、药品、材料使用知情同意书")[1].contains("<img")) {
|
|
|
+ structureMap.put("谈话医生", "<img");
|
|
|
+ return structureMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.isNotBlank(htmlContent)) {
|
|
|
+ htmlContent = htmlContent.replaceAll("[ ]", " ")
|
|
|
+ .replace("手印说明(\uF06F右食指 \uF06F左食指)", "")
|
|
|
+ .replace("手印说明:(\uF06F右食指 \uF06F左食指)其他手印备注", "")
|
|
|
+ .replace("第1页", "");
|
|
|
+ CommonAnalysisUtil.html2StructureMap(titles, htmlContent, structureMap);
|
|
|
+ }
|
|
|
+ CommonAnalysisUtil.extractDateByTitle(structureMap, "记录时间");
|
|
|
+ for (String ignoreContrast : ignoreContrasts) {
|
|
|
+ if (structureMap.containsKey(ignoreContrast)) {
|
|
|
+ structureMap.remove(ignoreContrast);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resultHandle(structureMap);
|
|
|
+ disDate(structureMap, "医师签名", "签名时间");
|
|
|
+ NingBoZhongYiHtmlAnalysisUtil.insertModuleId(modeId, recTypeId, structureMap);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return structureMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> ignoreContrasts = Lists.newArrayList(
|
|
|
+ "其他",
|
|
|
+ "与患者关系",
|
|
|
+ "手印备注与患者关系",
|
|
|
+ "身份证号码",
|
|
|
+ "九、患者知情同意",
|
|
|
+ "患方意见"
|
|
|
+ );
|
|
|
+
|
|
|
+ private void resultHandle(Map<String, String> result) {
|
|
|
+ if (MapUtils.isEmpty(result)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (result.containsKey("代理人签名")) {
|
|
|
+ String signName = result.get("代理人签名");
|
|
|
+
|
|
|
+ if (signName.contains("手印备注")) {
|
|
|
+ signName = signName.split("手印备注")[0];
|
|
|
+ result.put("代理人签名", signName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.forEach((key, value) -> {
|
|
|
+ if (StringUtil.isNotBlank(value)) {
|
|
|
+ value = StringUtil.trim(value);
|
|
|
+ if (value.endsWith(";") || value.endsWith(";")) {
|
|
|
+ value = value.substring(0, value.length() - 1);
|
|
|
+ }
|
|
|
+ result.put(key, value);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void disDate(Map sourceMap, String... args) {
|
|
|
+ Map<String, String> sourceMap_ = MapUtil.copyMap(sourceMap);
|
|
|
+ if (sourceMap.containsKey(args[0]) && sourceMap_.get(args[0]).contains(args[1])) {
|
|
|
+ int index = sourceMap_.get(args[0]).indexOf(args[1]);
|
|
|
+ sourceMap.put(args[0], sourceMap_.get(args[0]).substring(0, index));
|
|
|
+ sourceMap.put(args[0] + args[1], sourceMap_.get(args[0]).substring(index).replace(args[1], "").replaceAll("[::]", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|