ソースを参照

模块健壮性

chengyao 4 年 前
コミット
1b4e588ed9

+ 4 - 2
structure-center/src/main/java/com/lantone/structure/ai/process/EntityProcessBlood.java

@@ -38,9 +38,10 @@ public class EntityProcessBlood extends EntityProcess {
             for (Lemma lemma : typeBlood) {
                 Type type = new Type();
                 type.setName(lemma.getText());
-                Amount amount = new Amount();
+                List<Amount> amountList = new ArrayList<>();
                 if (lemma.isHaveChildren()) {
                     for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                        Amount amount = new Amount();
                         if (relationLemma.getProperty().equals(EntityEnum.AMOUNT_BLOOD.toString())) {
                             amount.setName(relationLemma.getText());
                             MeasurementUnit measurementUnit = new MeasurementUnit();
@@ -50,10 +51,11 @@ public class EntityProcessBlood extends EntityProcess {
                                 }
                             }
                             amount.setMeasurementUnit(measurementUnit);
+                            amountList.add(amount);
                         }
                     }
                 }
-                type.setAmount(amount);
+                type.setAmount(amountList);
                 clinicalBloodLabel.setType(type);
             }
             //输血原因

+ 104 - 48
structure-center/src/main/java/com/lantone/structure/facade/tran/ClinicalBloodTran.java

@@ -1,6 +1,7 @@
 package com.lantone.structure.facade.tran;
 import com.lantone.common.util.ListUtil;
 import com.lantone.structure.model.doc.ClinicalBloodDoc;
+import com.lantone.structure.model.entity.Amount;
 import com.lantone.structure.model.entity.Indication;
 import com.lantone.structure.model.entity.ResponseType;
 import com.lantone.structure.model.label.ClinicalBloodLabel;
@@ -33,65 +34,120 @@ public class ClinicalBloodTran extends TargetTran {
     }
 
         public void bloodContrast( List<ClinicalBloodDoc> clinicalBloodDocs, Map<String, String> retMap) {
-            if(ListUtil.isNotEmpty(clinicalBloodDocs)){
-                clinicalBloodDocs.forEach(clinicalBloodDoc -> {
-                    int indicationCount = 1;
-                    int responseTypeCount = 1;
-                    StringBuffer indicationString = new StringBuffer();
-                    StringBuffer responseTypeString  = new StringBuffer();
-                    ClinicalBloodLabel clinicalBlood = clinicalBloodDoc.getClinicalBloodLabel();
-
-                        if(ListUtil.isNotEmpty(clinicalBlood.getIndication())){
-                            for (Indication indications : clinicalBlood.getIndication()) {
-                                if(StringUtils.isNotEmpty( indications.getName())){
-                                    if(clinicalBlood.getIndication().size()>1){
-                                        indicationString.append((indicationCount++) + "." );
-                                    }
-                                    indicationString.append(indications.getName());
-                                }
+            if(ListUtil.isNotEmpty(clinicalBloodDocs)) clinicalBloodDocs.forEach(clinicalBloodDoc -> {
+                int indicationCount = 1;
+                int responseTypeCount = 1;
+                int amountCount = 1;
+                int measureCount = 1;
+                StringBuffer indicationString = new StringBuffer();
+                StringBuffer responseTypeString = new StringBuffer();
+                StringBuffer timeString = new StringBuffer();
+                StringBuffer amountString = new StringBuffer();
+                StringBuffer measureString = new StringBuffer();
+                StringBuffer bloodNoteString = new StringBuffer();
+                ClinicalBloodLabel clinicalBlood = clinicalBloodDoc.getClinicalBloodLabel();
 
+                if (ListUtil.isNotEmpty(clinicalBlood.getIndication())) {
+                    for (Indication indications : clinicalBlood.getIndication()) {
+                        if (StringUtils.isNotEmpty(indications.getName())) {
+                            if (clinicalBlood.getIndication().size() > 1) {
+                                indicationString.append((indicationCount++) + ".");
                             }
-                            retMap.put("输血指征",indicationString.toString());
-                        }
-
-                    if(clinicalBlood.getType()!= null){
-                        if(clinicalBlood.getType().getAmount()!= null && clinicalBlood.getType().getAmount().getMeasurementUnit()!= null &&
-                                StringUtils.isNotEmpty(clinicalBlood.getType().getAmount().getMeasurementUnit().getName())){
-                            retMap.put("输血量计量单位",clinicalBlood.getType().getAmount().getMeasurementUnit().getName());
-                        }
-                        if(clinicalBlood.getType().getAmount()!= null &&  StringUtils.isNotEmpty(clinicalBlood.getType().getAmount().getMeasurementUnit().getName())){
-                            retMap.put("输血量(mL)",clinicalBlood.getType().getAmount().getName());
-                        }
-                        if (StringUtils.isNotEmpty(clinicalBlood.getType().getName())){
-                            retMap.put("输血类型",clinicalBlood.getType().getName());
+                            indicationString.append(indications.getName());
                         }
 
                     }
-                    if(clinicalBlood.getReason()!= null && StringUtils.isNotEmpty(clinicalBlood.getReason().getName())){
-                        retMap.put("输血原因",clinicalBlood.getReason().getName());
-                    }
-                    if(clinicalBlood.getStartTime()!= null && StringUtils.isNotEmpty(clinicalBlood.getStartTime().getName())){
-                        retMap.put("输血开始时间",clinicalBlood.getStartTime().getName());
+                    retMap.put("输血指征", indicationString.toString());
+                }
+
+                if (clinicalBlood.getType() != null) {
+                    if (ListUtil.isNotEmpty(clinicalBlood.getType().getAmount())) {
+                        for (Amount amount : clinicalBlood.getType().getAmount()) {
+                            if (amount != null && StringUtils.isNotEmpty(amount.getName())) {
+                                if (clinicalBlood.getType().getAmount().size() > 1) {
+                                    amountString.append((amountCount++) + ".");
+                                }
+                                amountString.append(amount.getName());
+                                retMap.put("输血量(mL)", amountString.toString());
+                            }
+                            if (amount != null && amount.getMeasurementUnit() != null && StringUtils.isNotEmpty(amount.getMeasurementUnit().getName())) {
+                                if (clinicalBlood.getType().getAmount().size() > 1) {
+                                    measureString.append((measureCount++) + ".");
+                                }
+                                measureString.append(amount.getMeasurementUnit().getName());
+                                retMap.put("输血量计量单位", measureString.toString());
+                            }
+                            if (StringUtils.isNotEmpty(clinicalBlood.getType().getName())) {
+                                retMap.put("输血类型", clinicalBlood.getType().getName());
+                            }
+                        }
                     }
-                    if(clinicalBlood.getEndTime()!= null && StringUtils.isNotEmpty(clinicalBlood.getEndTime().getName())){
-                        retMap.put("输血结束时间",clinicalBlood.getEndTime().getName());
+                }
+                if (clinicalBlood.getReason() != null && StringUtils.isNotEmpty(clinicalBlood.getReason().getName())) {
+                    retMap.put("输血原因", clinicalBlood.getReason().getName());
+                }
+                if (clinicalBlood.getStartTime() != null && StringUtils.isNotEmpty(clinicalBlood.getStartTime().getName())) {
+                    timeString.append("输血开始时间:" + clinicalBlood.getStartTime().getName() + ";");
+                    bloodNoteString.append("输血开始时间:" + clinicalBlood.getStartTime().getName() + ";");
+                }
+                if (clinicalBlood.getEndTime() != null && StringUtils.isNotEmpty(clinicalBlood.getEndTime().getName())) {
+                    timeString.append("输血结束时间:" + clinicalBlood.getEndTime().getName() + ";");
+                    bloodNoteString.append("输血结束时间:" + clinicalBlood.getEndTime().getName() + ";");
+
+                }
+                if (clinicalBlood.getStartTime() != null || clinicalBlood.getEndTime() != null) {
+                    String timeStr = timeString.toString();
+                    if(timeStr.endsWith(";")){
+                        timeStr = timeStr.substring(0, timeStr.lastIndexOf(";"));
                     }
+                    retMap.put("输血日期时间", timeStr);
+                }
 
-                        if (ListUtil.isNotEmpty(clinicalBlood.getResponseType())) {
-                            for (ResponseType responseTypes : clinicalBlood.getResponseType()) {
-                                if(StringUtils.isNotEmpty( responseTypes.getName())){
-                                    if(clinicalBlood.getResponseType().size()>1){
-                                        responseTypeString.append((responseTypeCount++) + "." );
-                                    }
-                                    responseTypeString.append(responseTypes.getNegative().getName() + responseTypes.getName());
-                                }
+                if (ListUtil.isNotEmpty(clinicalBlood.getResponseType())) {
+                    for (ResponseType responseTypes : clinicalBlood.getResponseType()) {
+                        if (StringUtils.isNotEmpty(responseTypes.getName())) {
+                            if (clinicalBlood.getResponseType().size() > 1) {
+                                responseTypeString.append((responseTypeCount++) + ".");
                             }
-                            retMap.put("输血反应类型", responseTypeString.toString());
+                            responseTypeString.append(responseTypes.getNegative().getName() + responseTypes.getName());
                         }
+                    }
+                    retMap.put("输血反应类型", responseTypeString.toString());
+                    bloodNoteString.append("输血反应类型:" +  responseTypeString.toString() + ";");
+                }
 
-                });
+                if (null != clinicalBlood.getFrequency() && StringUtils.isNotEmpty(clinicalBlood.getFrequency().getName())) {
+                    retMap.put("输血次数", clinicalBlood.getFrequency().getName());
+                    bloodNoteString.append("输血次数:" +  clinicalBlood.getFrequency().getName() + ";");
+                }
+                if (!retMap.containsKey("输血次数") && StringUtils.isEmpty(retMap.get("输血次数"))) {
+                  if(StringUtils.isNotEmpty(retMap.get("输血量(mL)"))){
+                        String amountRet = retMap.get("输血量(mL)");
+                        int count = findString(amountRet, ".");
+                        if(count==0){
+                            count=1;
+                        }
+                        retMap.put("输血次数",(String.valueOf(count)+"次"));
+                      bloodNoteString.append("输血次数:" +  (String.valueOf(count)+"次") + ";");
+                   }
+                }
+                String bloodNoteStr = bloodNoteString.toString();
+                if(bloodNoteStr.endsWith(";")){
+                    bloodNoteStr = bloodNoteStr.substring(0, bloodNoteStr.lastIndexOf(";"));
+                }
+                retMap.put("输血过程记录",(bloodNoteStr));
+
+            });
             }
+    public int findString(String source,String target){
+        //计数器
+        int count = 0;
+        //每次查询开始的位置
+        int fromIndex = 0;
+        while((fromIndex = source.indexOf(target, fromIndex)) != -1){
+            count ++;
+            fromIndex = fromIndex + target.length();
         }
-
-
+        return count;
+    }
 }

+ 40 - 18
structure-center/src/main/java/com/lantone/structure/facade/tran/RescueTran.java

@@ -3,6 +3,7 @@ package com.lantone.structure.facade.tran;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.lantone.common.util.ListUtil;
+import com.lantone.common.util.StringUtil;
 import com.lantone.structure.facade.tran.util.CommonAnalysisUtil;
 import com.lantone.structure.model.doc.RescueDoc;
 import com.lantone.structure.model.entity.*;
@@ -93,14 +94,18 @@ public class RescueTran extends TargetTran {
                             }
 
                         }
-                        retMap.put("检查/检验项目名称", auxiliaryTestString.toString());
-                        retMap.put("检查/检验结果", auxiliaryResultString.toString());
-                       }
+                        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(StringUtils.isNotEmpty( operations.getOperationLocation().getName())){
+                            if(operations.getOperationLocation()!=null && StringUtils.isNotEmpty( operations.getOperationLocation().getName())){
                                 if(rescueLabel.getOperations().size()>1){
                                     operationLocationString.append((operationLocationCount++) + ".");
                                 }
@@ -114,8 +119,13 @@ public class RescueTran extends TargetTran {
                             }
 
                         }
-                        retMap.put("手术及操作名称", operationsString.toString());
-                        retMap.put("手术及操作目标部位名称", operationLocationString.toString());
+                        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("手术及操作名称")+";");
                         }
@@ -126,7 +136,6 @@ public class RescueTran extends TargetTran {
 
                   }
 
-
                     if(ListUtil.isNotEmpty(rescueLabel.getMethods())){
                         for (Method methods : rescueLabel.getMethods()) {
                             if(StringUtils.isNotEmpty(methods.getName())){
@@ -142,8 +151,13 @@ public class RescueTran extends TargetTran {
                                 countString.append(methods.getName()+methods.getCount().getName());
                             }
                         }
-                        retMap.put("操作方法", methodsString.toString());
-                        retMap.put("操作次数", countString.toString());
+                        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("操作方法")+";");
                         }
@@ -153,7 +167,6 @@ public class RescueTran extends TargetTran {
 
                         }
 
-
                     if(ListUtil.isNotEmpty(rescueLabel.getInterventions())){
                         for (Intervention intervention : rescueLabel.getInterventions()) {
                             if(StringUtils.isNotEmpty(intervention.getName())){
@@ -163,12 +176,13 @@ public class RescueTran extends TargetTran {
                                 interventionString.append(intervention.getName());
                             }
                         }
-                        retMap.put("介入物名称",interventionString.toString());
+                        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());
@@ -187,11 +201,11 @@ public class RescueTran extends TargetTran {
                         }
 
                     }
-                    retMap.put("病情变化情况",conditionsString.toString());
+                        if(StringUtil.isNotEmpty(conditionsString.toString())){
+                            retMap.put("病情变化情况",conditionsString.toString());
+                        }
                   }
 
-
-
                     if(ListUtil.isNotEmpty(rescueLabel.getDiagnosis())){
                     for (Diagnosis diagnosis : rescueLabel.getDiagnosis()) {
                         if(StringUtils.isNotEmpty(diagnosis.getName())){
@@ -201,7 +215,9 @@ public class RescueTran extends TargetTran {
                             diagnosisString.append(diagnosis.getName());
                         }
                     }
-                    retMap.put("疾病诊断名称", diagnosisString.toString());
+                        if(StringUtil.isNotEmpty(conditionsString.toString())){
+                            retMap.put("疾病诊断名称", diagnosisString.toString());
+                        }
                   }
 
 
@@ -220,7 +236,13 @@ public class RescueTran extends TargetTran {
                             resMedString.append("抢救药品"+":"+ drugsString.toString()+";");
                         }
                     }
-                    retMap.put("抢救措施",resMedString.toString());
+                    if(StringUtils.isNotEmpty( drugsString.toString())){
+                        String resMedStr = resMedString.toString();
+                        if(resMedStr.endsWith(";")){
+                            resMedStr = resMedStr.substring(0, resMedStr.lastIndexOf(";"));
+                        }
+                        retMap.put("抢救措施",resMedStr);
+                    }
                 }
             });
         }

+ 33 - 5
structure-center/src/main/java/com/lantone/structure/facade/tran/StagesSummaryTran.java

@@ -49,7 +49,7 @@ public class StagesSummaryTran 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
         );
         String retStr = parseBook(text);
@@ -59,21 +59,45 @@ public class StagesSummaryTran extends TargetTran {
             sourceMap.put("小结日期时间",stringDate);
         }
         CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
-        if(sourceMap.containsKey("辅助检查")){
+        if(sourceMap.containsKey("辅助检查")||sourceMap.containsKey("目前诊断")||sourceMap.containsKey("入院诊断")){
+            sourceMap.remove("入院诊断");
             sourceMap.remove("辅助检查");
+            sourceMap.remove("目前诊断");
+        }
+        if(sourceMap.containsKey("诊疗计划")&&StringUtil.isNotEmpty(sourceMap.get("诊疗计划"))){
+            String retString = sourceMap.get("诊疗计划");
+            String Data = parseString(retString);
+            sourceMap.put("诊疗计划",Data);
+
         }
         return sourceMap;
     }
 
+    public static String parseString(String text){
+        if(text.contains("/")){
+            text = text.substring(0,text.lastIndexOf("/"));
+            text= parseString(text);
+        }
+        return text;
+    }
     public static String parseBook(String text){
         String[] sourceStr = text.split("因");
         String[] targetStr = {""};
         String retStr = "";
         if(sourceStr!=null&&sourceStr.length>1){
-           targetStr = sourceStr[1].split("”", 0);
+                 retStr = sourceStr[1].substring( sourceStr[1].indexOf("”")+1);
+              if(retStr.contains("”")){
+                   retStr = retStr.substring(0, retStr.indexOf("”"));
+                   return retStr;
+              }else{
+                  retStr = "";
+              }
+              if(StringUtil.isEmpty(retStr)){
+                  targetStr = sourceStr[1].split("于");
+              }
         }
         if(targetStr!=null&&targetStr.length>1){
-             retStr = targetStr[1];
+             retStr = targetStr[0];
         }
         return retStr;
     };
@@ -201,7 +225,11 @@ public class StagesSummaryTran extends TargetTran {
                     }
 
             }
-                retMap.put("医嘱内容",adviceString.toString());
+                String adviceStr = adviceString.toString();
+                if(adviceStr.endsWith(";")){
+                    adviceStr = adviceStr.substring(0, adviceStr.lastIndexOf(";"));
+                }
+                retMap.put("医嘱内容",adviceStr);
             });
         }
     }

+ 3 - 1
structure-center/src/main/java/com/lantone/structure/model/entity/Type.java

@@ -3,6 +3,8 @@ package com.lantone.structure.model.entity;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @ClassName : Type
  * @Description : 输血类型
@@ -12,5 +14,5 @@ import lombok.Setter;
 @Setter
 @Getter
 public class Type extends General {
-    private Amount amount;//输血量
+    private List<Amount> amount;//输血量
 }