|
@@ -4,11 +4,10 @@ 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.FirstCourseRecordDoc;
|
|
|
import com.lantone.structure.model.doc.consultation.ConsultationDoc;
|
|
|
+import com.lantone.structure.model.doc.consultation.ConsultationRecordDoc;
|
|
|
import com.lantone.structure.util.MapUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
@@ -27,7 +26,9 @@ public class ConsultationTran extends TargetTran {
|
|
|
public Map<String, String> convert(String text) {
|
|
|
List<ConsultationDoc> consultationDocs = new ArrayList<ConsultationDoc>();
|
|
|
ConsultationDoc consultationDoc = new ConsultationDoc();
|
|
|
- consultationDoc.getConsultationRecordDoc().setText(text);
|
|
|
+ ConsultationRecordDoc consultationRecordDoc = new ConsultationRecordDoc();
|
|
|
+ consultationRecordDoc .setText(text);
|
|
|
+ consultationDoc.setConsultationRecordDoc(consultationRecordDoc);
|
|
|
consultationDocs.add(consultationDoc);
|
|
|
inputInfo.setConsultationDocs(consultationDocs);
|
|
|
Map<String, String> structureMap = cutWord(text);
|
|
@@ -38,13 +39,18 @@ public class ConsultationTran extends TargetTran {
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
+ Lists.newArrayList("其病历简述如下","会诊理由","会诊目的","会诊理由及目的","日期","目前诊断考虑","会诊结论","会诊意见","科室"), text);
|
|
|
CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
|
|
|
+ if(sourceMap.containsKey("日期")){
|
|
|
+ sourceMap.remove("日期");
|
|
|
+ }
|
|
|
return sourceMap;
|
|
|
}
|
|
|
|
|
@@ -80,80 +86,166 @@ public class ConsultationTran extends TargetTran {
|
|
|
public void consultationContrast( List<ConsultationDoc> consultationDocs, Map<String, String> retMap) {
|
|
|
if(consultationDocs != null) {
|
|
|
String text = consultationDocs.get(0).getConsultationRecordDoc().getText();
|
|
|
- if(text.contains("病例特点:")){
|
|
|
- String str = text.substring(0, text.indexOf("病例特点:"));
|
|
|
- str = extractDate(str);
|
|
|
- if(StringUtil.isNotEmpty(str)){
|
|
|
- retMap.put("记录日期时间",str);
|
|
|
- }
|
|
|
- }
|
|
|
- if(StringUtil.isNotEmpty(retMap.get("病例特点"))) {
|
|
|
- String specical = retMap.get("病例特点");
|
|
|
+ if(text.contains("\n")){
|
|
|
+ String[] split = text.split("\n");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String hero = split[i];
|
|
|
+ if(hero.contains("医院") && hero.length()<10){
|
|
|
+ if(StringUtil.isNotEmpty(hero)){
|
|
|
+ retMap.put("会诊医师所在医疗机构名称",hero);
|
|
|
+ }
|
|
|
+ }if(hero.contains("日期:")){
|
|
|
+ String firRet = hero.substring(hero.indexOf("日期:")+"日期:".length());
|
|
|
+ if(StringUtil.isNotEmpty(firRet)){
|
|
|
+ retMap.put("会诊日期时间",firRet);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //会诊医师签名
|
|
|
+ String data = "";
|
|
|
+ String ret = "";
|
|
|
+ if(text.contains("科室:")){
|
|
|
+ data = text.substring(text.lastIndexOf("科室:")+"科室:".length());
|
|
|
+ if(data.contains("医师:")){
|
|
|
+ ret = data.substring(data.lastIndexOf("医师:")+"医师:".length());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(ret.trim())) {
|
|
|
+ retMap.put("会诊医师签名",ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ //辅助检查结果
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("其病历简述如下"))) {
|
|
|
+ String specical = retMap.get("其病历简述如下");
|
|
|
String retStr = "";
|
|
|
- if (specical.contains("“")) {
|
|
|
- String[] split = specical.split("“");
|
|
|
+ if (specical.contains("辅助检查:")) {
|
|
|
+ String[] split = specical.split("辅助检查:");
|
|
|
if (split.length > 1) {
|
|
|
retStr = split[1];
|
|
|
}
|
|
|
- if (retStr.contains("”")) {
|
|
|
- String[] splits = retStr.split("”");
|
|
|
- if (splits.length > 1) {
|
|
|
- retStr = splits[0];
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
if(StringUtil.isNotEmpty(retStr)){
|
|
|
- retMap.put("主诉",retStr);
|
|
|
+ retMap.put("辅助检查结果",retStr);
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
+ //西医诊断名称
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("目前诊断考虑"))) {
|
|
|
+ String firStr = retMap.get("目前诊断考虑");
|
|
|
+ retMap.put("西医诊断名称",firStr);
|
|
|
+ }else{
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("其病历简述如下"))){
|
|
|
+ String specical = retMap.get("其病历简述如下");
|
|
|
+ String retStr = "";
|
|
|
+ if (specical.contains("诊断为:")) {
|
|
|
+ retStr = specical.substring( specical.lastIndexOf("诊断为:")+"诊断为:".length());
|
|
|
+ }
|
|
|
+ if (specical.contains("辅助检查:")) {
|
|
|
+ retStr = retStr.substring(0,retStr.lastIndexOf("辅助检查:"));
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(retStr)) {
|
|
|
+ retMap.put("西医诊断名称",retStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ // 会诊意见
|
|
|
+ if(StringUtil.isEmpty(retMap.get("会诊意见")) && StringUtil.isNotEmpty(retMap.get("会诊结论"))) {
|
|
|
+ String result = retMap.get("会诊结论");
|
|
|
+ String firStr = text.substring(text.lastIndexOf("会诊结论:")+"会诊结论:".length(), text.lastIndexOf("科室:"));
|
|
|
+ String tip = "";
|
|
|
+ if(firStr.contains("\n")){
|
|
|
+ String[] split = firStr.split("\n");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ if( split[i].contains("医院")){
|
|
|
+ tip = split[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(tip)){
|
|
|
+ String retData = result.substring(0, result.lastIndexOf(tip));
|
|
|
+ retMap.put("会诊意见",retData);
|
|
|
}
|
|
|
+
|
|
|
+ retMap.remove("会诊结论");
|
|
|
}
|
|
|
|
|
|
- if(text.contains("诊疗计划:")){
|
|
|
- String str = text.substring(text.lastIndexOf("诊疗计划:") + "诊疗计划:".length());
|
|
|
- if(str.contains("\n")){
|
|
|
- String[] split = str.split("\n");
|
|
|
- for (int i = 0; i < split.length; i++) {
|
|
|
- if(split[i].contains("/") && split[i].length()<=15){
|
|
|
- str = str.substring(0,str.lastIndexOf(split[i]));
|
|
|
- retMap.put("诊疗计划",str);
|
|
|
- }else{
|
|
|
- String date = extractDate(split[i]);
|
|
|
- if(StringUtil.isNotEmpty(date)){
|
|
|
- str = str.substring(0, str.indexOf(date));
|
|
|
- retMap.put("诊疗计划",str);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- StringBuffer sb = new StringBuffer();
|
|
|
- if(text.contains("鉴别诊断:")){
|
|
|
- String str = text.substring(text.lastIndexOf("鉴别诊断:") + "鉴别诊断:".length());
|
|
|
- if(str.contains("诊疗计划:")){
|
|
|
- str = str.split("诊疗计划:")[0];
|
|
|
+ String[] firSplit = text.split("\n");
|
|
|
+
|
|
|
+ //区别
|
|
|
+ if(firSplit.length>0){
|
|
|
+ String deptStr = "";
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ String firStr = firSplit[i];
|
|
|
+ if(firStr.contains("请求")){
|
|
|
+ deptStr = firStr.substring(firStr.indexOf("请求")+"请求".length());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(deptStr)){
|
|
|
+ retMap.put("会诊科室名称",deptStr);
|
|
|
+ }
|
|
|
}
|
|
|
- Boolean flag = true;
|
|
|
- if(str.contains("\n")){
|
|
|
- String[] split = str.split("\n");
|
|
|
- for (int i = 0; i < split.length; i++) {
|
|
|
- if(split[i].contains(":")){
|
|
|
- String[] splits = split[i].split(":");
|
|
|
- sb.append(splits[0]);
|
|
|
- flag = false;
|
|
|
+
|
|
|
+ for (int i = 0; i < firSplit.length-4; i++) {
|
|
|
+ String firStr = firSplit[i];
|
|
|
+ if(firStr.contains("医师:")){
|
|
|
+ String firRet = firStr.substring(0, firStr.indexOf("医师:"));
|
|
|
+ String retStr = "";
|
|
|
+ Boolean flag = true;
|
|
|
+ if(flag && firRet.contains("科")){
|
|
|
+ retStr = firRet.substring(0, firRet.indexOf("科")+"科".length());
|
|
|
+ if(firRet.contains(")")){
|
|
|
+ retStr = firRet.substring(0, firRet.indexOf(")")+")".length());
|
|
|
+ }
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ if( flag && firRet.contains("区")){
|
|
|
+ retStr = firRet.substring(0, firRet.indexOf("区")+"区".length());
|
|
|
+ if(firRet.contains(")")){
|
|
|
+ retStr = firRet.substring(0, firRet.indexOf(")")+")".length());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(retStr)) {
|
|
|
+ retMap.put("会诊申请科室",retStr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(StringUtil.isNotEmpty(sb.toString())){
|
|
|
- retMap.put("鉴别诊断-西医诊断名称",sb.toString());
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("会诊目的")) && StringUtil.isNotEmpty(retMap.get("会诊申请科室")) ){
|
|
|
+ String firStr = retMap.get("会诊目的");
|
|
|
+ String secStr = retMap.get("会诊申请科室");
|
|
|
+ if(firStr.contains(secStr)){
|
|
|
+ String retData = firStr.substring(0, firStr.lastIndexOf(secStr));
|
|
|
+ if(StringUtil.isNotEmpty(retData)){
|
|
|
+ retMap.put("会诊目的",retData);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if(flag){
|
|
|
- String firStr = retMap.get("鉴别诊断");
|
|
|
- retMap.put("鉴别诊断-西医诊断名称",firStr);
|
|
|
- retMap.remove("鉴别诊断");
|
|
|
+ if(StringUtil.isEmpty(retMap.get("会诊目的")) || StringUtil.isEmpty(retMap.get("会诊理由")) && StringUtil.isNotEmpty(retMap.get("会诊理由及目的"))) {
|
|
|
+ String firStr = retMap.get("会诊理由及目的");
|
|
|
+ String specialName = retMap.get("会诊申请科室");
|
|
|
+ if(firStr.contains(specialName)){
|
|
|
+ firStr = firStr.substring(0, firStr.lastIndexOf(specialName));
|
|
|
+ retMap.put("会诊目的",firStr);
|
|
|
+ retMap.put("会诊理由",firStr);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+ retMap.remove("会诊理由及目的");
|
|
|
}
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty("日期")){
|
|
|
+ retMap.remove("日期");
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty("科室")){
|
|
|
+ retMap.remove("科室");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|