|
@@ -0,0 +1,226 @@
|
|
|
|
+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.operation.OperationDoc;
|
|
|
|
+import com.lantone.structure.model.doc.operation.PreoperativeDiscussionDoc;
|
|
|
|
+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/2/26 14:52
|
|
|
|
+ */
|
|
|
|
+@Slf4j
|
|
|
|
+public class PreoperativeDiscussionTran extends TargetTran {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, String> convert(String text) {
|
|
|
|
+ List<OperationDoc> operationDocs = new ArrayList<>();
|
|
|
|
+ OperationDoc operationDoc = new OperationDoc();
|
|
|
|
+ PreoperativeDiscussionDoc preoperativeDiscussionDoc = new PreoperativeDiscussionDoc();
|
|
|
|
+ preoperativeDiscussionDoc.setText(text);
|
|
|
|
+ operationDoc.setPreoperativeDiscussionDoc(preoperativeDiscussionDoc);
|
|
|
|
+ operationDocs.add(operationDoc);
|
|
|
|
+ inputInfo.setOperationDocs(operationDocs);
|
|
|
|
+ // aiProcess();
|
|
|
|
+ // ============================封装完成==============================
|
|
|
|
+ Map<String, String> structureMap = cutWord(text);
|
|
|
|
+ Map<String, String> retMap = new HashMap<String, String>();
|
|
|
|
+ pDContrast(inputInfo.getOperationDocs(), structureMap);
|
|
|
|
+ mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
|
|
|
|
+ return retMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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.remove("手术方式");
|
|
|
|
+ }
|
|
|
|
+ return sourceMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private List<String> stagesContrasts = Lists.newArrayList(
|
|
|
|
+ "简要病情=诊断依据",
|
|
|
|
+ "手术指征=手术指征",
|
|
|
|
+ "手术指征=手术适应证",
|
|
|
|
+ "手术禁忌=手术禁忌症",
|
|
|
|
+ "拟实施手术名称=拟实施手术及操作名称",
|
|
|
|
+ "防范措施=注意事项",
|
|
|
|
+ "防范措施=手术要点"
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ public void pDContrast(List<OperationDoc> operationDocs,Map<String, String> retMap) {
|
|
|
|
+ String text = operationDocs.get(0).getPreoperativeDiscussionDoc().getText();
|
|
|
|
+ //小结日期时间
|
|
|
|
+ String sumdDate = extractDate(text);
|
|
|
|
+ if(StringUtil.isNotEmpty(sumdDate)){
|
|
|
|
+ retMap.put("小结日期时间",sumdDate);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //病历摘要 诊断依据
|
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("简要病情"))) {
|
|
|
|
+ String simCaseRet = retMap.get("简要病情");
|
|
|
|
+ retMap.put("病历摘要",simCaseRet);
|
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("入院后辅助检查"))) {
|
|
|
|
+ retMap.put("病历摘要",simCaseRet+" "+"入院后辅助检查:"+retMap.get("入院后辅助检查"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //辅助检查结果
|
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("简要病情"))) {
|
|
|
|
+ String simCase = retMap.get("简要病情");
|
|
|
|
+ String helpSee = "";
|
|
|
|
+ if(simCase.contains("辅助检查:")) {
|
|
|
|
+ helpSee = simCase.substring(simCase.indexOf("辅助检查:")+5);
|
|
|
|
+ retMap.put("辅助检查结果",helpSee);
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("入院后辅助检查"))) {
|
|
|
|
+ retMap.put("辅助检查结果",helpSee+" "+"入院后辅助检查:"+retMap.get("入院后辅助检查"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("简要病情"))) {
|
|
|
|
+ retMap.remove("简要病情");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isNotEmpty(retMap.get("入院后辅助检查"))) {
|
|
|
|
+ retMap.remove("入院后辅助检查");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //手术禁忌
|
|
|
|
+ if(text.contains("手术禁忌:")) {
|
|
|
|
+ String opration = text.substring(text.indexOf("手术禁忌:") + 5);
|
|
|
|
+ String s = opration.split("\n")[0];
|
|
|
|
+ retMap.put("手术禁忌",s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //手术指征
|
|
|
|
+ if(text.contains("手术指征:")) {
|
|
|
|
+ String opration = text.substring(text.indexOf("手术指征:") + 5);
|
|
|
|
+ String s = opration.split("\n")[0];
|
|
|
|
+ if(!retMap.get("手术指征").equals(s)){
|
|
|
|
+ retMap.put("手术指征",s);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //拟实施手术及操作日期时间
|
|
|
|
+ if(text.contains("拟定于")) {
|
|
|
|
+ String opration = text.substring(text.indexOf("拟定于"));
|
|
|
|
+ String date = extractDate(opration);
|
|
|
|
+ retMap.put("拟实施手术及操作日期时间",date);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //手术审批医师
|
|
|
|
+ String oprationDoc = text.substring(text.indexOf("手术审批医师:" )+ 7).trim();
|
|
|
|
+ if(StringUtil.isEmpty(retMap.get("手术审批医师"))) {
|
|
|
|
+ String oprationSign = "";
|
|
|
|
+ if(oprationDoc.contains("医师签名")){
|
|
|
|
+ oprationSign = text.substring(text.indexOf("手术审批医师:") + 7, text.indexOf("医师签名")).trim();
|
|
|
|
+ }else{
|
|
|
|
+ if(oprationDoc.contains("年") ||oprationDoc.contains( "-")){
|
|
|
|
+ String subStr= text.substring(text.indexOf("手术审批医师:")+7);
|
|
|
|
+ oprationSign = subStr.split("\n")[0].trim();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ retMap.put("手术审批医师",oprationSign);
|
|
|
|
+ }else{
|
|
|
|
+ String trim = "";
|
|
|
|
+ if(oprationDoc.contains("医师签名")){
|
|
|
|
+ trim = oprationDoc.substring(0, oprationDoc.indexOf("医师签名")).trim();
|
|
|
|
+ }else{
|
|
|
|
+ trim = oprationDoc.split("\n")[0].trim();
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isNotEmpty(trim)){
|
|
|
|
+ retMap.put("手术审批医师",trim);
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isEmpty(retMap.get("手术审批医师").trim())){
|
|
|
|
+ retMap.remove("手术审批医师");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //医师签名
|
|
|
|
+ if(text.contains("医师签名:")) {
|
|
|
|
+ String sign = text.substring(text.indexOf("医师签名:")+5).trim();
|
|
|
|
+ String docSign = "";
|
|
|
|
+ if(sign.contains("年") ||sign.contains( "-")){
|
|
|
|
+ String subStr= text.substring(text.indexOf("医师签名:")+5);
|
|
|
|
+ docSign = subStr.split("\n")[0].trim();
|
|
|
|
+ }
|
|
|
|
+ if(StringUtil.isNotEmpty(docSign)){
|
|
|
|
+ retMap.put("医师签名",docSign);
|
|
|
|
+ }else{
|
|
|
|
+ retMap.remove("医师签名");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String sub = text.substring(text.lastIndexOf("手术审批医师:"));
|
|
|
|
+ String date = extractDate(sub);
|
|
|
|
+ if(StringUtil.isNotEmpty(date)){
|
|
|
|
+ retMap.put("签名日期时间",date);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 抽取文本中的第一个时间
|
|
|
|
+ *
|
|
|
|
+ * @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;
|
|
|
|
+ }
|
|
|
|
+}
|