Bläddra i källkod

1.恩泽xml解析工具添加
2.恩泽死亡病例讨论记录trans层初步完成

hujing 4 år sedan
förälder
incheckning
b65660e426

+ 64 - 0
trans/src/main/java/com/lantone/qc/trans/beilun/util/ez/EzDeathCaseDiscussDocTrans.java

@@ -0,0 +1,64 @@
+package com.lantone.qc.trans.beilun.util.ez;
+
+import com.google.common.collect.Lists;
+import com.lantone.qc.pub.model.doc.DeathCaseDiscussDoc;
+import com.lantone.qc.pub.model.vo.MedrecVo;
+import com.lantone.qc.pub.util.FastJsonUtils;
+import com.lantone.qc.trans.ModelDocTrans;
+import com.lantone.qc.trans.beilun.util.BeiLunDeathCaseDiscussHtmlAnalysis;
+import com.lantone.qc.trans.beilun.util.BeiLunHtmlAnalysis;
+import com.lantone.qc.trans.beilun.util.ez.util.EzXmlUtil;
+import com.lantone.qc.trans.comsis.ModelDocGenerate;
+import com.lantone.qc.trans.comsis.OrdinaryAssistant;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.MapUtils;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 死亡病例讨论记录文档生成
+ * @author: HUJING
+ * @time: 2021/1/4 17:25
+ */
+@Slf4j
+public class EzDeathCaseDiscussDocTrans extends ModelDocTrans {
+
+    @Override
+    public DeathCaseDiscussDoc extract(MedrecVo medrecVo) {
+        DeathCaseDiscussDoc deathCaseDiscussDoc = null;
+        try {
+            Map<String, Object> contentMap = ((List<Map>) medrecVo.getContent().get("content")).get(0);
+            String content = contentMap.get("xmlText").toString();
+            Map<String, String> structureMap = null;
+            if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
+                structureMap = (Map) FastJsonUtils.getJsonToMap(content);
+            } else {
+                String recTitle = contentMap.get("recTitle").toString();
+                String recTypeId = contentMap.get("recTypeId").toString();
+                Map<String, String> sourceMap = EzXmlUtil.analysis(content);
+                if (MapUtils.isNotEmpty(sourceMap)) {
+                    structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
+                    structureMap.put("记录编号", contentMap.get("recId").toString());
+                    structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
+                }
+            }
+            if (MapUtils.isNotEmpty(structureMap)) {
+                deathCaseDiscussDoc = ModelDocGenerate.deathCaseDiscussDocGen(structureMap);
+                deathCaseDiscussDoc.setPageData((Map) structureMap);
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return deathCaseDiscussDoc;
+    }
+
+    private List<String> keyContrasts = Lists.newArrayList(
+            "医生签名时间=记录时间",
+            "主持人小结意见=主持人小结",
+            "具体讨论意见=讨论内容",
+            "记录者签名=记录医生",
+            "主持人(签名)=主持人签名"
+    );
+
+}

+ 86 - 0
trans/src/main/java/com/lantone/qc/trans/beilun/util/ez/util/EzXmlUtil.java

@@ -0,0 +1,86 @@
+package com.lantone.qc.trans.beilun.util.ez.util;
+
+import com.google.common.collect.Maps;
+import com.lantone.qc.pub.util.StringUtil;
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.Node;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @author: HUJING
+ * @time: 2021/1/4 14:30
+ */
+public class EzXmlUtil {
+
+    public static Map<String, String> analysis(String xml) throws Exception {
+        Map<String, String> map = Maps.newLinkedHashMap();
+        Document doc = DocumentHelper.parseText(bom(xml));
+        Element rootElement = doc.getRootElement();
+        findAllNodes(rootElement, map);
+        return map;
+    }
+
+    /**
+     * 从指定节点开始,向下寻找所有节点 ,包括其子节点<br/>
+     *
+     * @param node 所指定的节点
+     */
+    public static void findAllNodes(Element node, Map<String, String> map) {
+
+        putNode(node, map);
+
+        // 递归遍历当前节点所有的子节点
+        List<Element> listElement = node.elements();
+
+        // 遍历所有一级子节点
+        for (Element e : listElement) {
+            findAllNodes(e, map);// 递归
+        }
+    }
+
+    /**
+     * 存放节点,不包括其子节点
+     *
+     * @param node 所指定的节点
+     */
+    public static void putNode(Element node, Map<String, String> map) {
+        String labelName = node.getName();
+        String text = node.getStringValue();
+        List<Attribute> listAttr = node.attributes();// 所有属性
+        for (Attribute attr : listAttr) {// 遍历所有属性
+            String name = attr.getName();// 属性名称
+            String value = attr.getValue();// 属性的值
+            if (("fieldelem".equals(labelName) || "section".equals(labelName)) && StringUtil.isNotBlank(value)) {
+                /*
+                if (text.contains(":") && text.indexOf(":") < text.length()) {
+                    text = text.substring(text.indexOf(":") + 1);
+                }
+                 */
+                map.put(value, text);
+            }
+        }
+    }
+
+    public static String bom(String result) {
+        if (null != result && !"".equals(result)) {
+            if (result.contains("<") && result.lastIndexOf(">") != -1 && result.lastIndexOf(">") > result.indexOf("<")) {
+                result = result.substring(result.indexOf("<"), result.lastIndexOf(">") + 1);
+            }
+        }
+        return result;
+    }
+
+    public static String elementTxt(Node node) {
+        if (node != null) {
+            return StringUtil.removeBlank(node.getStringValue());
+        } else {
+            return "";
+        }
+    }
+}