|
@@ -0,0 +1,105 @@
|
|
|
+package com.lantone.qc.trans.comsis;
|
|
|
+
|
|
|
+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 com.lantone.qc.trans.changx.util.CxXmlUtil;
|
|
|
+import com.lantone.qc.trans.taizhou.util.TzXmlUtil;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @author: rengb
|
|
|
+ * @time: 2020/4/2 14:04
|
|
|
+ */
|
|
|
+public class OrdinaryAssistant {
|
|
|
+
|
|
|
+ public static Map<String, String> mapKeyContrast(Map<String, String> sourceMap, List<String> keyContrasts) {
|
|
|
+ Map<String, String> retMap = Maps.newHashMap();
|
|
|
+ String[] arry = null;
|
|
|
+ String sourceKey = null, targetKey;
|
|
|
+ for (String keyContrast : keyContrasts) {
|
|
|
+ arry = keyContrast.split("=");
|
|
|
+ sourceKey = arry[0];
|
|
|
+ if (arry.length == 1) {
|
|
|
+ targetKey = arry[0];
|
|
|
+ } else {
|
|
|
+ targetKey = arry[1];
|
|
|
+ }
|
|
|
+ retMap.put(targetKey, sourceMap.get(sourceKey));
|
|
|
+ sourceMap.remove(sourceKey);
|
|
|
+ }
|
|
|
+ retMap.putAll(sourceMap);
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ changx();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void taizhou() {
|
|
|
+ String msg = FileUtil.fileRead("C:\\Users\\RGB\\Desktop\\调试\\台州出院小结.xml");
|
|
|
+ Map<String, String> map = TzXmlUtil.getXmlToMapForTZ(msg);
|
|
|
+ map.keySet().forEach(key -> {
|
|
|
+ System.out.println("\"" + key + "=\",");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void changx() {
|
|
|
+ String content = FileUtil.fileRead("C:\\Users\\RGB\\Desktop\\调试\\入院记录.txt");
|
|
|
+ String text = CxXmlUtil.getTextByNodePath(content, "//DocObjContent/Region/Content_Text");
|
|
|
+ if (StringUtil.isBlank(text)) {
|
|
|
+ text = CxXmlUtil.getTextByNodePath(content, "//DocObjContent/Region");
|
|
|
+ }
|
|
|
+ Map<String, String> cutWordMap = getCutWordMap(text);
|
|
|
+ Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
|
|
|
+ cutWordMap.putAll(xmlNodeValueMap);
|
|
|
+ Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(cutWordMap, keyContrasts);
|
|
|
+ structureMap.put("记录时间", structureMap.get("记录日期"));
|
|
|
+ structureMap.put("查房日期", structureMap.get("记录日期"));
|
|
|
+ structureMap.put("病情记录", text);
|
|
|
+ int endIndex = text.indexOf("查房记录");
|
|
|
+ if (endIndex > 0) {
|
|
|
+ String title = text.substring(0, endIndex);
|
|
|
+ title = title.substring(title.lastIndexOf(" ") + 1) + "查房记录";
|
|
|
+ structureMap.put("查房标题", title);
|
|
|
+ }
|
|
|
+
|
|
|
+ structureMap.keySet().forEach(key -> {
|
|
|
+ System.out.println(key + "-----------" + structureMap.get(key));
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static Map<String, String> getCutWordMap(String content) {
|
|
|
+ if (StringUtil.isBlank(content)) {
|
|
|
+ return Maps.newHashMap();
|
|
|
+ }
|
|
|
+ List<String> targetTitles = Lists.newArrayList();
|
|
|
+ sourceTitles.forEach(sourceTitle -> {
|
|
|
+ String targetTitle = "";
|
|
|
+ for (int index = 0; index < sourceTitle.length(); index++) {
|
|
|
+ if (index == sourceTitle.length() - 1) {
|
|
|
+ targetTitle += sourceTitle.substring(index, index + 1);
|
|
|
+ } else {
|
|
|
+ targetTitle += sourceTitle.substring(index, index + 1) + "[\\s\\p{Zs}]*";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ targetTitles.add(targetTitle);
|
|
|
+ });
|
|
|
+ return Preproc.extract_doc_pub(true, targetTitles, content);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static List<String> sourceTitles = Lists.newArrayList(
|
|
|
+ "记录医生"
|
|
|
+ );
|
|
|
+
|
|
|
+ private static List<String> keyContrasts = Lists.newArrayList(
|
|
|
+ "记录医生=记录医师"
|
|
|
+ );
|
|
|
+
|
|
|
+}
|