Browse Source

交接班记录

chengyao 4 years ago
parent
commit
67706b9324

+ 3 - 0
structure-center/src/main/java/com/lantone/structure/facade/StructureFacade.java

@@ -50,6 +50,9 @@ public class StructureFacade {
             case "转科记录":
             case "转科记录":
                 targetTran = new TransferRecordTran();
                 targetTran = new TransferRecordTran();
                 break;
                 break;
+            case "交接班记录":
+                targetTran = new DutyShiftSystemTran();
+                break;
            /* case "上级医师查房记录":
            /* case "上级医师查房记录":
                 targetTran = new WardRecordTran();
                 targetTran = new WardRecordTran();
                 break;*/
                 break;*/

+ 144 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/DutyShiftSystemTran.java

@@ -0,0 +1,144 @@
+package com.lantone.structure.facade.tran;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.lantone.common.util.StringUtil;
+import com.lantone.structure.facade.tran.util.CommonAnalysisUtil;
+import com.lantone.structure.model.doc.DutyShiftSystemDoc;
+import com.lantone.structure.util.MapUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Description:交接班记录
+ * @author: cy
+ * @time: 2021/3/01 18:52
+ */
+@Slf4j
+public class DutyShiftSystemTran extends TargetTran {
+    @Override
+    public Map<String, String> convert(String text) {
+        List<DutyShiftSystemDoc> dutyShiftSystemDocs = new ArrayList<>();
+        DutyShiftSystemDoc dutyShiftSystemDoc = new DutyShiftSystemDoc();
+        dutyShiftSystemDoc.setText(text);
+        dutyShiftSystemDocs.add(dutyShiftSystemDoc);
+        inputInfo.setDutyShiftSystemDocs(dutyShiftSystemDocs);
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        dutyShiftSystemContrast(inputInfo.getDutyShiftSystemDocs(), structureMap);
+        mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
+        return retMap;
+    }
+
+    private Map<String, String> cutWord(String text) {
+        Map<String, String> sourceMap = Maps.newHashMap();
+        List<String> titles = CommonAnalysisUtil.sortTitles(
+                Lists.newArrayList("入院日期","交班日期","接班日期","主    诉","入院情况","入院诊断","诊治经过","目前诊断", "治疗情况", "诊疗计划","交班注意事项"),
+                text
+        );
+        CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
+        if(sourceMap.containsKey("入院诊断") ||sourceMap.containsKey("目前诊断")){
+            sourceMap.remove("入院诊断");
+            sourceMap.remove("目前诊断");
+        }
+        return sourceMap;
+    }
+
+
+    private List<String> stagesContrasts = Lists.newArrayList(
+            "入院日期=入院日期时间",
+            "交班日期=交班日期时间",
+            "接班日期=接班日期时间",
+            "主    诉=主诉",
+            "诊治经过=诊疗过程描述",
+            "治疗情况=目前情况",
+            "交班注意事项=注意事项",
+            "诊疗计划=接班诊疗计划"
+    );
+
+    public void dutyShiftSystemContrast ( List<DutyShiftSystemDoc> dutyShiftSystemDocs,Map<String, String> retMap) {
+        String text = dutyShiftSystemDocs.get(0).getText();
+        String fir = text.split("\n")[1];
+        if(StringUtil.isNotEmpty(retMap.get("诊疗计划"))){
+            String subStr = text.substring(text.indexOf("诊疗计划:"));
+            String[] split = subStr.split("\n");
+            String planRet =split[0];
+            String planSignDate = parseString(split[1]);
+            retMap.put("诊疗计划",planRet);
+            if(fir.contains("接班记录") && StringUtil.isNotEmpty(planSignDate.trim())){
+                retMap.put("接班者签名",planSignDate);
+            }
+        }
+
+        if(StringUtil.isNotEmpty(retMap.get("交班注意事项"))){
+            String subStr = text.substring(text.indexOf("交班注意事项:"));
+            String[] split = subStr.split("\n");
+            String planRet = split[0];
+            String planSignDate = parseString(split[1]);
+            retMap.put("交班注意事项",planRet);
+            if(fir.contains("交班记录") && StringUtil.isNotEmpty(planSignDate.trim())){
+                    retMap.put("交班者签名",planSignDate);
+            }
+        }
+    }
+
+    public static void mapKeyContrastCommon(Map sourceMap, List<String> keyContrasts, Map<String, String> retMap) {
+        Map<String, String> sourceMap_ = MapUtil.copyMap(sourceMap);
+        String[] arry = null;
+        String sourceKey = null, targetKey;
+        Set<String> removeKey = new HashSet<>();
+        for (String keyContrast : keyContrasts) {
+            arry = keyContrast.split("=");
+            sourceKey = arry[0];
+            if (arry.length == 1) {
+                targetKey = arry[0];
+            } else {
+                targetKey = arry[1];
+            }
+            if (StringUtil.isNotBlank(sourceMap_.get(sourceKey))
+                    && (!retMap.containsKey(targetKey) || StringUtil.isBlank(retMap.get(targetKey)))) {
+                retMap.put(targetKey, sourceMap_.get(sourceKey));
+            }
+            removeKey.add(sourceKey);
+        }
+        Set<String> keySet = retMap.keySet();
+        for (String key : sourceMap_.keySet()) {
+            if (!keySet.contains(key) && !removeKey.contains(key)) { // 如果之前已放过key就不用放了
+                retMap.put(key, sourceMap_.get(key));
+            }
+        }
+    }
+
+
+    /**
+     * 抽取文本中的第一个时间
+     *
+     * @param top
+     * @return
+     */
+    public static String extractDate(String top) {
+        Pattern pattern = Pattern.compile("[0-9]{4}[-][0-9]{1,2}[-][0-9]{1,2}");
+        Matcher matcher = pattern.matcher(top);
+        if (matcher.find()) {
+            return matcher.group(0);
+        } else {
+            Pattern p1 = Pattern.compile("[0-9]{4}年[0-9]+月[0-9]+日");
+            Matcher m1 = p1.matcher(top);
+            if (m1.find()) {
+                return m1.group(0);
+            }
+        }
+        return null;
+    }
+
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(text.lastIndexOf("/")+1);
+            text= parseString(text);
+        }
+        return text;
+    }
+}