|
@@ -0,0 +1,188 @@
|
|
|
+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.InformedConsentDoc;
|
|
|
+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/3/10 10:12
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public class InformedConsentTran extends TargetTran {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> convert(String text) {
|
|
|
+ InformedConsentDoc informedConsentDoc = new InformedConsentDoc();
|
|
|
+ informedConsentDoc .setText(text);
|
|
|
+ inputInfo.setInformedConsentDoc(informedConsentDoc);
|
|
|
+ Map<String, String> structureMap = cutWord(text);
|
|
|
+ Map<String, String> retMap = new HashMap<String, String>();
|
|
|
+ informedConsentContrast(inputInfo.getInformedConsentDoc(), structureMap);
|
|
|
+ mapKeyContrastCommon(structureMap,stagesContrasts,retMap);
|
|
|
+ return retMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ CommonAnalysisUtil.cutByTitles(text, titles, 0, sourceMap);
|
|
|
+ if(sourceMap.containsKey("联系地址") || sourceMap.containsKey("医生签字") || sourceMap.containsKey("知情选择")
|
|
|
+ || sourceMap.containsKey("医师签名")){
|
|
|
+ sourceMap.remove("联系地址");
|
|
|
+ sourceMap.remove("医生签字");
|
|
|
+ sourceMap.remove("知情选择");
|
|
|
+ sourceMap.remove("医师签名");
|
|
|
+ }
|
|
|
+ return sourceMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void informedConsentContrast( InformedConsentDoc informedConsentDoc, Map<String, String> retMap) {
|
|
|
+ if(informedConsentDoc != null) {
|
|
|
+ String text = informedConsentDoc.getText();
|
|
|
+ String flag = " ";
|
|
|
+ if (text.contains("\n")) {
|
|
|
+ String[] split = text.split("\n");
|
|
|
+ for (int i = 0; i < split.length; i++) {
|
|
|
+ String hero = split[i];
|
|
|
+ if(i == 0 ){
|
|
|
+ if (!hero.contains(flag)) {
|
|
|
+ flag = "_";
|
|
|
+ }
|
|
|
+ if ( hero.contains(flag)) {
|
|
|
+ String[] motton = hero.split(flag);
|
|
|
+ String firStr = motton[0];
|
|
|
+ String secStr = "";
|
|
|
+ if (StringUtil.isNotEmpty(firStr)) {
|
|
|
+ secStr = hero.substring(hero.lastIndexOf(firStr) + firStr.length());
|
|
|
+ if(firStr.contains("_")){
|
|
|
+ firStr = firStr.substring(0, firStr.lastIndexOf("_"));
|
|
|
+ }
|
|
|
+ if(secStr.contains("_")){
|
|
|
+ secStr = secStr.substring(secStr.lastIndexOf("_")+"_".length());
|
|
|
+ }
|
|
|
+ retMap.put("知情同意书编号", firStr);
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(secStr)) {
|
|
|
+ retMap.put("知情同意书名称", secStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hero.contains("医生签字")) {
|
|
|
+ if (StringUtil.isNotEmpty(hero)) {
|
|
|
+ String firRet = "医生签字:";
|
|
|
+ if (!hero.contains(firRet)) {
|
|
|
+ firRet = "医生签字:";
|
|
|
+ }
|
|
|
+ String firStr = hero.substring(hero.lastIndexOf(firRet) + firRet.length());
|
|
|
+ String date = extractDate(firStr);
|
|
|
+ String secStr = "";
|
|
|
+ if (StringUtil.isNotEmpty(date)) {
|
|
|
+ retMap.put("医师签名日期时间", date);
|
|
|
+ secStr = hero.substring(hero.lastIndexOf(firRet) + firRet.length(), hero.lastIndexOf(date));
|
|
|
+ } else {
|
|
|
+ if (firStr.contains("年")) {
|
|
|
+ secStr = firStr.substring(0, firStr.lastIndexOf("年"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(secStr.trim())) {
|
|
|
+ retMap.put("医师签名", secStr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hero.contains("患方签字")) {
|
|
|
+ String firRet = "患方签字:";
|
|
|
+ if (!hero.contains(firRet)) {
|
|
|
+ firRet = "患方签字:";
|
|
|
+ }
|
|
|
+ String firStr = hero.substring(hero.lastIndexOf(firRet) + firRet.length());
|
|
|
+ String date = extractDate(firStr);
|
|
|
+ if (StringUtil.isNotEmpty(date)) {
|
|
|
+ retMap.put("患者/法定代理人签名日期时间", date);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 取/前
|
|
|
+ public static String parseStr(String text){
|
|
|
+ if(text.contains("/")){
|
|
|
+ text = text.substring(0,text.lastIndexOf("/"));
|
|
|
+ text= parseStr(text);
|
|
|
+ }
|
|
|
+ return text;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 抽取文本中的第一个时间
|
|
|
+ *
|
|
|
+ * @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;
|
|
|
+ }
|
|
|
+}
|