소스 검색

其他知情告知同意书

chengyao 4 년 전
부모
커밋
fb934dfbd4

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

@@ -80,6 +80,9 @@ public class StructureFacade {
             case "会诊记录":
                 targetTran = new ConsultationTran();
                 break;
+            case "其他知情告知同意书":
+                targetTran = new InformedConsentTran();
+                break;
             default:
                 break;
         }

+ 9 - 1
structure-center/src/main/java/com/lantone/structure/facade/tran/BeHospitalizedTran.java

@@ -138,9 +138,15 @@ public class BeHospitalizedTran extends TargetTran {
                 if(value.contains("查体:")){
                     value = value.substring(0, value.lastIndexOf("查体:"));
                 }
+                if(value.contains("辅助检查:")){
+                    value = value.substring(0, value.lastIndexOf("辅助检查:"));
+                }
                 if(value.contains("收住我科")){
                     placeName = "收住我科";
                 }
+                if(value.contains("收治我科")){
+                    placeName = "收治我科";
+                }
                 if(value.contains("门诊收住")){
                     placeName = "门诊收住";
                 }
@@ -150,6 +156,9 @@ public class BeHospitalizedTran extends TargetTran {
                 if( value.contains("收治入院")){
                     placeName = "收治入院";
                 }
+                if( value.contains("收住入院")){
+                    placeName = "收住入院";
+                }
                 if(StringUtil.isNotEmpty(placeName)){
                     value = value.substring(0, value.lastIndexOf(placeName)+placeName.length());
                 }
@@ -157,7 +166,6 @@ public class BeHospitalizedTran extends TargetTran {
                   retMap.put("现病史",value);
                     retMap.put("症状描述",value);
                 }
-
             }
             //体格检查指标
             String firRetStr= "";

+ 13 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/ConsultationTran.java

@@ -102,6 +102,13 @@ public class ConsultationTran extends TargetTran {
                     }
                 }
             }
+            if(StringUtil.isNotEmpty(retMap.get("会诊日期时间"))){
+                String date = retMap.get("会诊日期时间");
+                 date = extractDate(date);
+                if(StringUtil.isEmpty(date)){
+                    retMap.remove("会诊日期时间");
+                }
+            }
             //会诊医师签名
                 String data = "";
                 String ret = "";
@@ -182,6 +189,12 @@ public class ConsultationTran extends TargetTran {
                     if(firStr.contains("请求")){
                          deptStr = firStr.substring(firStr.indexOf("请求")+"请求".length());
                     }
+                    if(deptStr.contains(" ")){
+                        String[] split = deptStr.split(" ");
+                        if(split.length>=2){
+                            deptStr = split[split.length-2];
+                        }
+                    }
 
                     if(StringUtil.isNotEmpty(deptStr)){
                         retMap.put("会诊科室名称",deptStr);

+ 188 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/InformedConsentTran.java

@@ -0,0 +1,188 @@
+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.InformedConsentDoc;
+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/10 10:12
+ */
+@Slf4j
+public class InformedConsentTran extends TargetTran {
+
+    @Override
+    public Map<String, String> convert(String text) {
+        InformedConsentDoc informedConsentDoc = new InformedConsentDoc();
+        informedConsentDoc .setText(text);
+        inputInfo.setInformedConsentDoc(informedConsentDoc);
+        Map<String, String> structureMap = cutWord(text);
+        Map<String, String> retMap = new HashMap<String, String>();
+        informedConsentContrast(inputInfo.getInformedConsentDoc(), structureMap);
+        mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
+        return retMap;
+    }
+
+    private List<String> stagesContrasts = Lists.newArrayList(
+            "科别=科室名称",
+            "科别=病区名称",
+            "床号=病房号",
+            "床号=病床号",
+            "病情告知=知情同意内容",
+            "病情告知=医疗机构意见",
+            "具体如下=知情同意内容",
+            "具体如下=医疗机构意见"
+    );
+    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.containsKey("知情选择")
+                || sourceMap.containsKey("医师签名")){
+            sourceMap.remove("联系地址");
+            sourceMap.remove("医生签字");
+            sourceMap.remove("知情选择");
+            sourceMap.remove("医师签名");
+        }
+        return sourceMap;
+    }
+
+
+    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));
+            }
+        }
+    }
+
+
+    public void informedConsentContrast( InformedConsentDoc informedConsentDoc, Map<String, String> retMap) {
+        if(informedConsentDoc != null) {
+            String text = informedConsentDoc.getText();
+            String flag = " ";
+            if (text.contains("\n")) {
+                String[] split = text.split("\n");
+                for (int i = 0; i < split.length; i++) {
+                    String hero = split[i];
+                    if(i == 0 ){
+                        if (!hero.contains(flag)) {
+                            flag = "_";
+                        }
+                    if ( hero.contains(flag)) {
+                        String[] motton = hero.split(flag);
+                        String firStr = motton[0];
+                        String secStr = "";
+                        if (StringUtil.isNotEmpty(firStr)) {
+                             secStr = hero.substring(hero.lastIndexOf(firStr) + firStr.length());
+                            if(firStr.contains("_")){
+                                 firStr = firStr.substring(0, firStr.lastIndexOf("_"));
+                            }
+                            if(secStr.contains("_")){
+                                secStr = secStr.substring(secStr.lastIndexOf("_")+"_".length());
+                            }
+                            retMap.put("知情同意书编号", firStr);
+                        }
+                        if (StringUtil.isNotEmpty(secStr)) {
+                            retMap.put("知情同意书名称", secStr);
+                        }
+                    }
+                }
+                    if (hero.contains("医生签字")) {
+                        if (StringUtil.isNotEmpty(hero)) {
+                            String firRet = "医生签字:";
+                            if (!hero.contains(firRet)) {
+                                firRet = "医生签字:";
+                            }
+                            String firStr = hero.substring(hero.lastIndexOf(firRet) + firRet.length());
+                            String date = extractDate(firStr);
+                            String secStr = "";
+                            if (StringUtil.isNotEmpty(date)) {
+                                retMap.put("医师签名日期时间", date);
+                                secStr = hero.substring(hero.lastIndexOf(firRet) + firRet.length(), hero.lastIndexOf(date));
+                            } else {
+                                if (firStr.contains("年")) {
+                                    secStr = firStr.substring(0, firStr.lastIndexOf("年"));
+                                }
+                            }
+                            if (StringUtil.isNotEmpty(secStr.trim())) {
+                                retMap.put("医师签名", secStr);
+                            }
+                        }
+                    }
+                    if (hero.contains("患方签字")) {
+                        String firRet = "患方签字:";
+                        if (!hero.contains(firRet)) {
+                            firRet = "患方签字:";
+                        }
+                        String firStr = hero.substring(hero.lastIndexOf(firRet) + firRet.length());
+                        String date = extractDate(firStr);
+                        if (StringUtil.isNotEmpty(date)) {
+                            retMap.put("患者/法定代理人签名日期时间", date);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    // 取/前
+    public static String parseStr(String text){
+        if(text.contains("/")){
+            text = text.substring(0,text.lastIndexOf("/"));
+            text= parseStr(text);
+        }
+        return text;
+    }
+
+    /**
+     * 抽取文本中的第一个时间
+     *
+     * @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;
+    }
+}