|
@@ -0,0 +1,117 @@
|
|
|
+package com.lantone.qc.trans.changx.util;
|
|
|
+
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.lantone.qc.pub.util.FileUtil;
|
|
|
+import com.lantone.qc.pub.util.StringUtil;
|
|
|
+import org.dom4j.Document;
|
|
|
+import org.dom4j.DocumentHelper;
|
|
|
+import org.dom4j.Element;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description: xml解析工具
|
|
|
+ * @author: rengb
|
|
|
+ * @time: 2020/3/28 14:23
|
|
|
+ */
|
|
|
+public class CxXmlUtil {
|
|
|
+
|
|
|
+ public static Map<String, String> beHospitalizedXmlToMap(String xml) {
|
|
|
+ Map<String, String> retMap = Maps.newHashMap();
|
|
|
+ try {
|
|
|
+ String helpTip, contentText;
|
|
|
+ Element contentTextElement;
|
|
|
+ Document doc = DocumentHelper.parseText(xml);
|
|
|
+ Element rootElement = doc.getRootElement();
|
|
|
+
|
|
|
+ List<Element> sectionElements = rootElement.elements("Section");
|
|
|
+ Map<String, String> sectionMap = Maps.newHashMap();
|
|
|
+ for (Element sectionElement : sectionElements) {
|
|
|
+ helpTip = sectionElement.attributeValue("HelpTip");
|
|
|
+ if (StringUtil.isBlank(helpTip)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ contentTextElement = sectionElement.element("Content_Text");
|
|
|
+ if (contentTextElement == null) {
|
|
|
+ contentText = sectionElement.getStringValue().trim();
|
|
|
+ } else {
|
|
|
+ contentText = contentTextElement.getTextTrim();
|
|
|
+ }
|
|
|
+ sectionMap.put(helpTip, contentText);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Element> newCtrlElements = rootElement.elements("NewCtrl");
|
|
|
+ Map<String, String> newCtrlMap = Maps.newHashMap();
|
|
|
+ for (Element newCtrlElement : newCtrlElements) {
|
|
|
+ helpTip = newCtrlElement.attributeValue("HelpTip");
|
|
|
+ if (StringUtil.isBlank(helpTip)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ contentTextElement = newCtrlElement.element("Content_Text");
|
|
|
+ if (contentTextElement == null) {
|
|
|
+ contentText = newCtrlElement.getStringValue().trim();
|
|
|
+ } else {
|
|
|
+ contentText = contentTextElement.getTextTrim();
|
|
|
+ }
|
|
|
+ newCtrlMap.put(helpTip, contentText);
|
|
|
+ }
|
|
|
+
|
|
|
+ retMap.put("姓名", newCtrlMap.get("姓名"));
|
|
|
+ retMap.put("性别", newCtrlMap.get("性别"));
|
|
|
+ retMap.put("年龄", newCtrlMap.get("年龄"));
|
|
|
+ retMap.put("民族", newCtrlMap.get("民族"));
|
|
|
+ retMap.put("职业", newCtrlMap.get("职业"));
|
|
|
+ retMap.put("出生地", newCtrlMap.get("出生地"));
|
|
|
+ retMap.put("婚姻", newCtrlMap.get("婚姻状况"));
|
|
|
+ retMap.put("联系地址", "");
|
|
|
+ retMap.put("病史陈述者", newCtrlMap.get("供史者"));
|
|
|
+ retMap.put("出生日期", newCtrlMap.get("出生日期"));
|
|
|
+ retMap.put("户口地址", newCtrlMap.get("户口地址"));
|
|
|
+ retMap.put("电话", newCtrlMap.get("联系电话"));
|
|
|
+ retMap.put("入院日期", newCtrlMap.get("入院日期"));
|
|
|
+ retMap.put("记录日期", newCtrlMap.get("记录日期"));
|
|
|
+ retMap.put("辅助检查", newCtrlMap.get("辅助检查"));
|
|
|
+ retMap.put("初步诊断", newCtrlMap.get("初步诊断"));
|
|
|
+ retMap.put("修正诊断", newCtrlMap.get("修正诊断"));
|
|
|
+ retMap.put("补充诊断", newCtrlMap.get("补充诊断"));
|
|
|
+ retMap.put("主诉", newCtrlMap.get("主诉"));
|
|
|
+ retMap.put("现病史", newCtrlMap.get("现病史"));
|
|
|
+
|
|
|
+ retMap.put("既往史", sectionMap.get("既往史"));
|
|
|
+ retMap.put("个人史", sectionMap.get("个人史"));
|
|
|
+ retMap.put("婚育史", sectionMap.get("婚育史:"));
|
|
|
+ retMap.put("月经史", sectionMap.get("月经史"));
|
|
|
+ retMap.put("家族史", sectionMap.get("家族史"));
|
|
|
+ retMap.put("专科体格检查", sectionMap.get("体格检查"));
|
|
|
+
|
|
|
+ String tgjc = sectionMap.get("一般情况") + "。"
|
|
|
+ + sectionMap.get("皮肤情况") + "。"
|
|
|
+ + newCtrlMap.get("淋巴") + "。"
|
|
|
+ + sectionMap.get("头部检查") + "。"
|
|
|
+ + sectionMap.get("颈部") + "。"
|
|
|
+ + sectionMap.get("胸部检查") + "。"
|
|
|
+ + sectionMap.get("肺部检查") + "。"
|
|
|
+ + sectionMap.get("心脏检查") + "。"
|
|
|
+ + newCtrlMap.get("血管") + "。"
|
|
|
+ + sectionMap.get("腹部检查") + "。"
|
|
|
+ + newCtrlMap.get("外生殖器") + "。"
|
|
|
+ + newCtrlMap.get("直肠肛门") + "。"
|
|
|
+ + sectionMap.get("四肢脊柱检查") + "。"
|
|
|
+ + sectionMap.get("神经系统检查") + "。"
|
|
|
+ + newCtrlMap.get("其他说明") + "。";
|
|
|
+ retMap.put("体格检查", tgjc);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String msg = FileUtil.fileRead("C:\\Users\\RGB\\Desktop\\调试\\入院记录.txt");
|
|
|
+ Map<String, String> map = beHospitalizedXmlToMap(msg);
|
|
|
+ map.keySet().forEach(key -> {
|
|
|
+ System.out.println(key + "---" + map.get(key));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+}
|