|
@@ -13,6 +13,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:
|
|
@@ -31,7 +33,7 @@ public class RescueTran extends TargetTran {
|
|
|
inputInfo.setRescueDocs(rescueDocList);
|
|
|
aiProcess();
|
|
|
Map<String, String> structureMap = cutWord(text);
|
|
|
- rescueContrast(inputInfo.getRescueDocs(), structureMap);
|
|
|
+ rescueContrast(text,inputInfo.getRescueDocs(), structureMap);
|
|
|
return structureMap;
|
|
|
}
|
|
|
|
|
@@ -49,7 +51,7 @@ public class RescueTran extends TargetTran {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void rescueContrast( List<RescueDoc> rescueDocs,Map<String, String> retMap) {
|
|
|
+ public void rescueContrast(String text, List<RescueDoc> rescueDocs,Map<String, String> retMap) {
|
|
|
if(ListUtil.isNotEmpty(rescueDocs)){
|
|
|
rescueDocs.forEach(rescueDoc -> {
|
|
|
int auxiliaryCount = 1;
|
|
@@ -181,15 +183,20 @@ public class RescueTran extends TargetTran {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(ListUtil.isNotEmpty(rescueLabel.getConditions())){
|
|
|
+ List<String> strDate = new ArrayList<>();
|
|
|
+ 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());
|
|
|
+ for (Condition condition : rescueLabel.getConditions()) {
|
|
|
+ if(null != condition.getPd() && StringUtils.isNotEmpty( condition.getPd().getValue())){
|
|
|
+ strDate.add(condition.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());
|
|
|
+ if(ListUtil.isNotEmpty(strDate)){
|
|
|
+ retMap.put("抢救开始日期时间",strDate.get(0));
|
|
|
+ if(strDate.size()>1){
|
|
|
+ retMap.put("抢救结束日期时间",strDate.get(strDate.size()-1));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
for (Condition conditions : rescueLabel.getConditions()) {
|
|
@@ -205,6 +212,19 @@ public class RescueTran extends TargetTran {
|
|
|
retMap.put("病情变化情况",conditionsString.toString());
|
|
|
}
|
|
|
}
|
|
|
+ if(StringUtils.isNotEmpty(retMap.get("抢救开始日期时间")) && !(retMap.get("抢救开始日期时间").contains("年") || retMap.get("抢救开始日期时间").contains("-"))){
|
|
|
+ String date = extractDate(text);
|
|
|
+ if(StringUtils.isNotEmpty(date.trim())){
|
|
|
+ retMap.put("抢救开始日期时间",date+" "+retMap.get("抢救开始日期时间"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(retMap.get("抢救结束日期时间")) && !(retMap.get("抢救结束日期时间").contains("年") || retMap.get("抢救结束日期时间").contains("-"))){
|
|
|
+ String date = extractDate(text);
|
|
|
+ if(StringUtils.isNotEmpty(date.trim())){
|
|
|
+ retMap.put("抢救结束日期时间",date+" "+retMap.get("抢救结束日期时间"));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if(ListUtil.isNotEmpty(rescueLabel.getDiagnosis())){
|
|
|
for (Diagnosis diagnosis : rescueLabel.getDiagnosis()) {
|
|
@@ -247,4 +267,24 @@ public class RescueTran extends TargetTran {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 抽取文本中的第一个时间
|
|
|
+ *
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
}
|