chengyao 4 anni fa
parent
commit
c7a68b8a9a

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

@@ -56,9 +56,9 @@ public class StructureFacade {
             case "疑难病例讨论记录":
                 targetTran = new DifficultCaseDiscussTran();
                 break;
-           /* case "上级医师查房记录":
+            case "上级医师查房记录":
                 targetTran = new WardRecordTran();
-                break;*/
+                break;
             default:
                 break;
         }

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

@@ -134,6 +134,7 @@ public class DutyShiftSystemTran extends TargetTran {
         return null;
     }
 
+    // 取/后
     public static String parseString(String text){
         if(text.contains("/")){
             text = text.substring(text.lastIndexOf("/")+1);

+ 1 - 0
structure-center/src/main/java/com/lantone/structure/facade/tran/StagesSummaryTran.java

@@ -73,6 +73,7 @@ public class StagesSummaryTran extends TargetTran {
         return sourceMap;
     }
 
+    // 取/前
     public static String parseString(String text){
         if(text.contains("/")){
             text = text.substring(0,text.lastIndexOf("/"));

+ 54 - 15
structure-center/src/main/java/com/lantone/structure/facade/tran/TransferRecordTran.java

@@ -34,16 +34,17 @@ public class TransferRecordTran extends TargetTran {
     private Map<String, String> cutWord(String text) {
         Map<String, String> sourceMap = Maps.newHashMap();
         List<String> titles = CommonAnalysisUtil.sortTitles(
-                Lists.newArrayList("转出日期","转出科室","转入科室","入院情况","简要病情","入院诊断","诊疗经过","转科理由", "目前情况","目前诊断", "转入诊断","转入诊疗计划","转科目的及其注意事项","医生签名","签名时间","患者或代理人签名","签名时间"),
+                Lists.newArrayList("转出日期","转出科室","转入科室","入院情况","简要病情","入院诊断","诊疗经过","转科理由", "目前情况","目前诊断", "转入诊断","转入诊疗计划","下一步治疗方案","转科目的及其注意事项","医生签名","签名时间","患者或代理人签名","签名时间"),
                 text
         );
         CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
         if(sourceMap.containsKey("入院诊断") ||sourceMap.containsKey("目前诊断") ||sourceMap.containsKey("转入诊断")
-                ||sourceMap.containsKey("签名时间")){
+                ||sourceMap.containsKey("签名时间") ||sourceMap.containsKey("患者或代理人签名")){
             sourceMap.remove("入院诊断");
             sourceMap.remove("目前诊断");
             sourceMap.remove("转入诊断");
             sourceMap.remove("签名时间");
+            sourceMap.remove("患者或代理人签名");
         }
         return sourceMap;
     }
@@ -52,10 +53,13 @@ public class TransferRecordTran extends TargetTran {
     private List<String> stagesContrasts = Lists.newArrayList(
             "简要病情=入院情况",
             "诊疗经过=诊疗过程描述",
+            "转科理由=转科目的",
             "转科目的及其注意事项=转科目的",
             "转科目的及其注意事项=注意事项",
             "防范措施=注意事项",
-            "防范措施=手术要点"
+            "防范措施=手术要点",
+            "医生签名=转出医师签名",
+            "下一步治疗方案=转入诊疗计划"
     );
 
     public void transferRecordContrast (TransferRecordDoc transferRecordDocs,Map<String, String> retMap) {
@@ -64,7 +68,18 @@ public class TransferRecordTran extends TargetTran {
         String fir = text.split("\n")[1];
         String planText = "";
         if(text.contains("转入诊疗计划:")){
-               planText = text.substring( text.indexOf("转入诊疗计划:"));
+            planText = text.substring( text.indexOf("转入诊疗计划:"));
+        }
+        if(text.contains("下一步治疗方案:")){
+            planText = text.substring( text.indexOf("下一步治疗方案:"));
+        }
+
+        if(!(text.contains("简要病情") || text.contains("入院情况"))){
+            if(text.contains("入院诊断") && (StringUtil.isEmpty(retMap.get("入院情况")) || StringUtil.isEmpty(
+                    retMap.get("简要病情")))){
+                String ret = text.substring( text.indexOf(fir)+fir.length(),text.lastIndexOf("入院诊断"));
+                retMap.put("入院情况",ret);
+            }
         }
 
         if(fir.contains("转入记录")){
@@ -73,6 +88,16 @@ public class TransferRecordTran extends TargetTran {
                 retMap.put("转入日期时间",date);
             }
         }
+        if(StringUtil.isNotEmpty(retMap.get("医生签名"))){
+            String signName = retMap.get("医生签名");
+            if(signName.contains("签名时间")){
+                retMap.remove("医生签名");
+                signName = signName.substring(0, signName.lastIndexOf("签名时间"));
+                if(StringUtil.isNotEmpty(signName)){
+                    retMap.put("医生签名",signName);
+                }
+            }
+        }
 
         if(fir.contains("转科记录")){
             if(StringUtil.isNotEmpty(retMap.get("转出日期"))){
@@ -86,27 +111,32 @@ public class TransferRecordTran extends TargetTran {
         }
 
         String innerSignName = parseString(planText);
-        if(StringUtil.isNotEmpty(innerSignName)){
+        if(StringUtil.isNotEmpty(innerSignName.trim()) && planText.contains("/")){
             retMap.put("转入医师签名",innerSignName.trim());
         }
 
-        if(StringUtil.isNotEmpty(retMap.get("转入诊疗计划"))){
-            String innerPlan = retMap.get("转入诊疗计划");
-            String innerPlanRet = innerPlan.substring(0, innerPlan.lastIndexOf("。")+1).trim();
+        if(text.contains("转入诊疗计划:")){
+            String inFir = text.substring(text.indexOf("转入诊疗计划:") + 7);
+            String innerPlanRet = inFir.split("\n")[0];
+            if(innerPlanRet.contains("/")){
+                innerPlanRet = parseStr(innerPlanRet);
+            }
             retMap.put("转入诊疗计划",innerPlanRet);
         }
 
-        if(StringUtil.isNotEmpty(retMap.get("医生签名"))){
-            String innerPlan = retMap.get("医生签名").trim();
-            if(StringUtil.isEmpty(innerPlan)){
-                retMap.remove("医生签名");
+        if(text.contains("下一步治疗方案:") && StringUtil.isEmpty(retMap.get("转入诊疗计划"))){
+            String  plan = text.substring( text.indexOf("下一步治疗方案:")+"下一步治疗方案:".length());
+            String planRet = plan.split("\n")[0];
+            if(planRet.contains("/")){
+                planRet = parseStr(planRet);
             }
+            retMap.put("下一步治疗方案",planRet);
         }
 
-        if(StringUtil.isNotEmpty(retMap.get("患者或代理人签名"))){
-            String innerPlan = retMap.get("患者或代理人签名").trim();
+        if(StringUtil.isNotEmpty(retMap.get("医生签名"))){
+            String innerPlan = retMap.get("医生签名").trim();
             if(StringUtil.isEmpty(innerPlan)){
-                retMap.remove("患者或代理人签名");
+                retMap.remove("医生签名");
             }
         }
     }
@@ -167,4 +197,13 @@ public class TransferRecordTran extends TargetTran {
         }
         return text;
     }
+
+    // 取/前
+    public static String parseStr(String text){
+        if(text.contains("/")){
+            text = text.substring(0,text.lastIndexOf("/"));
+            text= parseString(text);
+        }
+        return text;
+    }
 }

+ 52 - 197
structure-center/src/main/java/com/lantone/structure/facade/tran/WardRecordTran.java

@@ -16,6 +16,8 @@ import org.apache.commons.lang3.StringUtils;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * @Description:上级医师查房记录
@@ -35,220 +37,73 @@ public class WardRecordTran extends TargetTran {
         aiProcess();
       //  ============================封装完成==============================
         Map<String, String> structureMap = cutWord(text);
-        rescueContrast(inputInfo.getRescueDocs(), structureMap);
+        wardRecordContrast(inputInfo.getWardRecordDocs(), structureMap);
         return structureMap;
     }
 
     private Map<String, String> cutWord(String text) {
         Map<String, String> sourceMap = Maps.newHashMap();
         List<String> titles = CommonAnalysisUtil.sortTitles(
-                Lists.newArrayList("抢救措施","参与现场抢救的医务人员","注意事项"),
+                Lists.newArrayList("鉴别诊断","诊疗计划","补充诊断"),
                 text
         );
         CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
-        if(sourceMap.containsKey("参与现场抢救的医务人员")){
-            sourceMap.remove("参与现场抢救的医务人员");
+        if(sourceMap.containsKey("鉴别诊断") || sourceMap.containsKey("补充诊断")){
+            sourceMap.remove("鉴别诊断");
+            sourceMap.remove("补充诊断");
         }
         return sourceMap;
     }
 
 
-    public void rescueContrast( List<RescueDoc> rescueDocs,Map<String, String> retMap) {
-        if(ListUtil.isNotEmpty(rescueDocs)){
-            rescueDocs.forEach(rescueDoc -> {
-                int auxiliaryCount = 1;
-                int auxiliaryResultCount = 1;
-                int operationsCount = 1;
-                int operationLocationCount = 1;
-                int methodsCount = 1;
-                int count = 1;
-                int interventionCount = 1;
-                int conditionsCount = 1;
-                int diagnosisCount = 1;
-                int drugsCount = 1;
-                StringBuffer auxiliaryTestString = new StringBuffer();
-                StringBuffer auxiliaryResultString  = new StringBuffer();
-                StringBuffer operationsString = new StringBuffer();
-                StringBuffer operationLocationString = new StringBuffer();
-                StringBuffer methodsString = new StringBuffer();
-                StringBuffer countString = new StringBuffer();
-                StringBuffer conditionsString = new StringBuffer();
-                StringBuffer diagnosisString = new StringBuffer();
-                StringBuffer interventionString = new StringBuffer();
-                StringBuffer drugsString = new StringBuffer();
-                StringBuffer resMedString = new StringBuffer();
-
-                RescueLabel rescueLabel = rescueDoc.getRescueLabel();
-                    if(ListUtil.isNotEmpty( rescueLabel.getAuxiliaryTest())){
-                        for (AuxiliaryTest auxiliaryTest : rescueLabel.getAuxiliaryTest()) {
-                                for (AuxiliaryResult auxiliaryResult : auxiliaryTest.getAuxiliaryResult()) {
-                                    if(StringUtils.isNotEmpty( auxiliaryResult.getName())){
-                                        if(auxiliaryTest.getAuxiliaryResult().size()>1){
-                                            auxiliaryResultString.append((auxiliaryResultCount++) + ".");
-                                        }
-                                        auxiliaryResultString.append(auxiliaryResult.getName());
-                                    }
-                                }
-
-                            if(StringUtils.isNotEmpty(auxiliaryTest.getName())){
-                                if(rescueLabel.getAuxiliaryTest().size()>1) {
-                                    auxiliaryTestString.append((auxiliaryCount++) + ".");
-                                }
-                                auxiliaryTestString.append(auxiliaryTest.getName());
-                            }
-
-                        }
-                        if(StringUtil.isNotEmpty(auxiliaryTestString.toString())){
-                            retMap.put("检查/检验项目名称", auxiliaryTestString.toString());
-                        }
-
-                        if(StringUtil.isNotEmpty(auxiliaryResultString.toString())){
-                            retMap.put("检查/检验结果", auxiliaryResultString.toString());
-                        }
-                       }
-
-                    if(ListUtil.isNotEmpty( rescueLabel.getOperations())){
-                        for (Operation operations : rescueLabel.getOperations()) {
-                            if(operations.getOperationLocation()!=null && StringUtils.isNotEmpty( operations.getOperationLocation().getName())){
-                                if(rescueLabel.getOperations().size()>1){
-                                    operationLocationString.append((operationLocationCount++) + ".");
-                                }
-                                operationLocationString.append(operations.getOperationLocation().getName());
-                            }
-                            if(StringUtils.isNotEmpty(operations.getName())){
-                                if(rescueLabel.getOperations().size()>1){
-                                    operationsString.append((operationsCount++) + ".");
-                                }
-                                operationsString.append( operations.getName());
-                            }
-
-                        }
-                        if(StringUtil.isNotEmpty(operationsString.toString())){
-                            retMap.put("手术及操作名称", operationsString.toString());
-                        }
-
-                        if(StringUtil.isNotEmpty(operationLocationString.toString())){
-                            retMap.put("手术及操作目标部位名称", operationLocationString.toString());
-                        }
-                        if(StringUtils.isNotEmpty(retMap.get("手术及操作名称"))){
-                            resMedString.append("手术及操作名称"+":"+retMap.get("手术及操作名称")+";");
-                        }
-
-                        if(StringUtils.isNotEmpty(retMap.get("手术及操作目标部位名称"))){
-                            resMedString.append("手术及操作目标部位名称"+":"+retMap.get("手术及操作目标部位名称")+";");
-                        }
-
-                  }
-
-                    if(ListUtil.isNotEmpty(rescueLabel.getMethods())){
-                        for (Method methods : rescueLabel.getMethods()) {
-                            if(StringUtils.isNotEmpty(methods.getName())){
-                                if(rescueLabel.getMethods().size()>1){
-                                    methodsString.append((methodsCount++) + ".");
-                                }
-                                methodsString.append( methods.getName());
-                            }
-                            if( methods.getCount() != null){
-                                if(rescueLabel.getMethods().size()>1){
-                                    countString.append((count++) + ".");
-                                }
-                                countString.append(methods.getName()+methods.getCount().getName());
-                            }
-                        }
-                        if(StringUtil.isNotEmpty(methodsString.toString())){
-                            retMap.put("操作方法", methodsString.toString());
-                        }
-                        if(StringUtil.isNotEmpty(countString.toString())){
-                            retMap.put("操作次数", countString.toString());
-                        }
-
-                        if(StringUtils.isNotEmpty(retMap.get("操作方法"))){
-                            resMedString.append("操作方法"+":"+retMap.get("操作方法")+";");
-                        }
-                        if(StringUtils.isNotEmpty(retMap.get("操作次数"))){
-                            resMedString.append("操作次数"+":"+retMap.get("操作次数")+";");
-                        }
-
-                        }
-
-                    if(ListUtil.isNotEmpty(rescueLabel.getInterventions())){
-                        for (Intervention intervention : rescueLabel.getInterventions()) {
-                            if(StringUtils.isNotEmpty(intervention.getName())){
-                                if(rescueLabel.getInterventions().size()>1){
-                                    interventionString.append((interventionCount++) + ".");
-                                }
-                                interventionString.append(intervention.getName());
-                            }
-                        }
-                        if(StringUtil.isNotEmpty(interventionString.toString())){
-                            retMap.put("介入物名称",interventionString.toString());
-                        }
-                    }
-
-                    if(ListUtil.isNotEmpty(rescueLabel.getConditions())){
-                        //抢救病情长度1时间没有,大于1时间开始取最初 结束取最后
-                        if(rescueLabel.getConditions().size()>1){
-                            if( null != (rescueLabel.getConditions().get(0).getPd()) && StringUtils.isNotEmpty(rescueLabel.getConditions().get(0).getPd().getValue())){
-                                retMap.put("抢救开始日期时间",rescueLabel.getConditions().get(0).getPd().getValue());
-                            }
-
-                            if( null != (rescueLabel.getConditions().get(rescueLabel.getConditions().size()-1).getPd()) && StringUtils.isNotEmpty(rescueLabel.getConditions().get(rescueLabel.getConditions().size()-1).getPd().getValue())){
-                                retMap.put("抢救开始日期时间",rescueLabel.getConditions().get(rescueLabel.getConditions().size()-1).getPd().getValue());
-                            }
-                        }
-                    for (Condition conditions : rescueLabel.getConditions()) {
-                        if(StringUtils.isNotEmpty(conditions.getName())){
-                            if(rescueLabel.getInterventions().size()>1){
-                                conditionsString.append((conditionsCount++) + ".");
-                            }
-                            conditionsString.append(conditions.getName());
-                        }
-
-                    }
-                        if(StringUtil.isNotEmpty(conditionsString.toString())){
-                            retMap.put("病情变化情况",conditionsString.toString());
-                        }
-                  }
+    public void wardRecordContrast(  List<WardRecordDoc> wardRecordDoc,Map<String, String> retMap) {
+        String text = wardRecordDoc.get(0).getText();
+        //查房日期时间
+        String sumdDate = extractDate(text);
+        if(StringUtil.isNotEmpty(sumdDate)){
+            retMap.put("查房日期时间",sumdDate);
+        }
+        if(text.contains("鉴别诊断")){
+            String logo = text.split("\n")[1];
+            String fir = text.substring(text.indexOf(logo) + logo.length(),text.lastIndexOf("鉴别诊断"));
+            if(StringUtil.isNotEmpty(fir)){
+                retMap.put("查房记录",fir);
+            }
+        }
 
-                    if(ListUtil.isNotEmpty(rescueLabel.getDiagnosis())){
-                    for (Diagnosis diagnosis : rescueLabel.getDiagnosis()) {
-                        if(StringUtils.isNotEmpty(diagnosis.getName())){
-                            if(rescueLabel.getInterventions().size()>1){
-                                diagnosisString.append((diagnosisCount++) + ".");
-                            }
-                            diagnosisString.append(diagnosis.getName());
-                        }
-                    }
-                        if(StringUtil.isNotEmpty(conditionsString.toString())){
-                            retMap.put("疾病诊断名称", diagnosisString.toString());
-                        }
-                  }
+        if(StringUtil.isNotEmpty(retMap.get("诊疗计划"))){
+            String plan = retMap.get("诊疗计划");
+               String Data = parseString(plan);
+               retMap.put("诊疗计划",Data);
+           }
+        }
 
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(0,text.lastIndexOf("/"));
+            text= parseString(text);
+        }
+        return text;
+    }
 
-                if(!retMap.containsKey("抢救措施")&&StringUtils.isEmpty(retMap.get("抢救措施"))){
-                    //抢救药品只会出现在抢救措施里面
-                    if(ListUtil.isNotEmpty(rescueLabel.getDrugs())){
-                        for (Drug drugs : rescueLabel.getDrugs()) {
-                            if(StringUtils.isNotEmpty(drugs.getName())){
-                                if(rescueLabel.getDrugs().size()>1){
-                                    drugsString.append((drugsCount++) + ".");
-                                }
-                                drugsString.append(drugs.getName());
-                            }
-                        }
-                        if(StringUtils.isNotEmpty( drugsString.toString())){
-                            resMedString.append("抢救药品"+":"+ drugsString.toString()+";");
-                        }
-                    }
-                    if(StringUtils.isNotEmpty( drugsString.toString())){
-                        String resMedStr = resMedString.toString();
-                        if(resMedStr.endsWith(";")){
-                            resMedStr = resMedStr.substring(0, resMedStr.lastIndexOf(";"));
-                        }
-                        retMap.put("抢救措施",resMedStr);
-                    }
-                }
-            });
+    /**
+     * 抽取文本中的第一个时间
+     *
+     * @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;
     }
 }