Jelajahi Sumber

Merge remote-tracking branch 'origin/dev/ez' into dev/ez

chengyao 4 tahun lalu
induk
melakukan
097c3e74c7

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

@@ -86,6 +86,12 @@ public class StructureFacade {
             case "输血治疗同意书":
                 targetTran = new ClinicBloodConsentDocTran();
                 break;
+//            case "特殊检查及特殊治疗同意书":
+//                targetTran = new SpecialCureConsentDocTran();
+//                break;
+//            case "一般手术记录":
+//                targetTran = new OperationRecordDocTran();
+//                break;
             default:
                 break;
         }

+ 108 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/OperationRecordDocTran.java

@@ -0,0 +1,108 @@
+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.operation.OperationDoc;
+import com.lantone.structure.model.doc.operation.OperationRecordDoc;
+import com.lantone.structure.util.MapUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Description: 一般手术记录
+ * @author: wsy
+ * @time: 2021/3/11 15:49
+ */
+@Slf4j
+public class OperationRecordDocTran extends TargetTran {
+    @Override
+    public Map<String, String> convert(String text) {
+        List<OperationDoc> operationDocs = new ArrayList<OperationDoc>();
+        OperationDoc operationDoc = new OperationDoc();
+        OperationRecordDoc operationRecordDoc = new OperationRecordDoc();
+        operationRecordDoc.setText(text);
+        operationDoc.setOperationRecordDoc(operationRecordDoc);
+        operationDocs.add(operationDoc);
+        inputInfo.setOperationDocs(operationDocs);
+        aiProcess();
+
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        CommonAnalysisUtil.mapKeyContrastCommon(structureMap, keyContrasts, retMap);
+        retMap.entrySet().removeIf(entry -> StringUtil.isBlank(entry.getValue()));
+        retMap.entrySet().removeIf(entry -> !entry.getValue().matches("\\d") && "医师签名日期时间".equals(entry.getKey()));
+        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 != null) {
+            if (sourceMap.containsKey("主刀医生")) {
+                String dataStr = sourceMap.get("主刀医生");
+                String date = extractDate(dataStr);
+                if (StringUtil.isNotBlank(date)) {
+                    sourceMap.put("主刀医生", dataStr.replace(date, ""));
+                    sourceMap.put("签名日期时间", date);
+                }
+            }
+            CommonAnalysisUtil.removeKey(sourceMap, "术前诊断", "术中诊断", "⒈患者基本情况", "⒉拟实施的输血方案");
+        }
+        return sourceMap;
+    }
+
+    /**
+     * 抽取文本中的第一个时间
+     *
+     * @param top
+     * @return
+     */
+    private 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]+日 [0-9]+时[0-9]+分");
+            Matcher m1 = p1.matcher(top);
+            if (m1.find()) {
+                return m1.group(0);
+            }
+        }
+        return null;
+    }
+
+    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("[::]", ""));
+        }
+    }
+
+
+    private List<String> keyContrasts = Lists.newArrayList(
+            "手术开始时间=手术开始日期时间",
+            "手术结束时间=手术结束日期时间",
+            "手术经过=手术过程描述",
+            "手 术 者=手术者姓名",
+            "助手=Ⅰ助姓名",
+            "麻 醉 者=麻醉医师姓名",
+            "医护人员陈述=手术者签名",
+            "主刀医生=手术者签名"
+    );
+}

+ 83 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/SpecialCureConsentDocTran.java

@@ -0,0 +1,83 @@
+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.util.MapUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 特殊检查及特殊治疗同意书
+ * @author: wsy
+ * @time: 2021/3/11 14:49
+ */
+@Slf4j
+public class SpecialCureConsentDocTran extends TargetTran {
+    @Override
+    public Map<String, String> convert(String text) {
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        CommonAnalysisUtil.mapKeyContrastCommon(structureMap, keyContrasts, retMap);
+        retMap.entrySet().removeIf(entry -> StringUtil.isBlank(entry.getValue()));
+        retMap.entrySet().removeIf(entry ->
+                !entry.getValue().matches("\\d") && ("患者/法定代理人签名日期时间".equals(entry.getKey()) || "医师签名日期时间".equals(entry.getKey()))
+        );
+        return retMap;
+    }
+
+    private Map<String, String> cutWord(String text) {
+        Map<String, String> sourceMap = Maps.newHashMap();
+//        String dataStr = "";
+        text = text.replace("年   月   日    时   分", "").replace("如果患者无法签署知情同意书,请其授权的亲属在此签名:", "");
+        List<String> titles = CommonAnalysisUtil.sortTitles(
+                Lists.newArrayList("姓名", "性别", "年龄", "科别", "床号","门诊号/住院号", "就诊/入院日期", "临床诊断", "康复治疗计划", "并发症及注意事项",
+                        "医生签名", "治疗师签名", "患方签名", "患者家属签名(关系)"),
+                text
+        );
+        CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
+//        if (sourceMap != null) {
+//            if (sourceMap.containsKey("医护人员陈述")) {
+//                dataStr = sourceMap.get("医护人员陈述");
+//                sourceMap.put("医护人员陈述", dataStr.substring(0, Math.max(0, dataStr.indexOf("医生签名"))));
+//            }
+//            List<String> listTitle = Lists.newArrayList(
+//                    "医生签名", "患者、患者家属或患者的法定监护人、授权委托人意见", "患者/患者授权委托人签名", "患者签名", "代理人签名", "与患者关系"
+//            );
+//            CommonAnalysisUtil.sortTitlesNoColon(listTitle, dataStr);
+//            CommonAnalysisUtil.cutByTitlesNoColon(dataStr, listTitle, 0, sourceMap);
+//            CommonAnalysisUtil.removeKey(sourceMap, "1.患者基本情况", "2.拟使用的血液制品", "⒈患者基本情况", "⒉拟实施的输血方案", "与患者关系");
+//            disDate(sourceMap, "住院号", "疾病介绍和治疗建议");
+//            disDate(sourceMap, "医生签名", "签名日期");
+//            disDate(sourceMap, "医生签名", "签名时间");
+//            disDate(sourceMap, "患者/患者授权委托人签名", "签名日期");
+//            disDate(sourceMap, "患者签名", "签名时间");
+//        }
+        return sourceMap;
+    }
+
+    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("[::]", ""));
+        }
+    }
+
+
+    private List<String> keyContrasts = Lists.newArrayList(
+            "门诊号/住院号=住院号",
+            "姓名=患者姓名",
+            "年龄=年龄(岁)",
+            "床号=病床号",
+            "科别=病区名称",
+            "临床诊断=特殊检查及特殊治疗项目名称",
+            "康复治疗计划=特殊检查及特殊治疗目的",
+            "并发症及注意事项=特殊检查及特殊治疗可能引起的并发症及风险"
+    );
+}