Przeglądaj źródła

北仑:增加对日常病程录的解析处理

wangsy 4 lat temu
rodzic
commit
3a2950a974

+ 76 - 76
trans/src/main/java/com/lantone/qc/trans/beilun/BeiLunThreeLevelWardDocTrans.java

@@ -22,12 +22,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.*;
 
 /**
  * @Description: 查房记录文档生成
@@ -39,6 +34,7 @@ import java.util.regex.Pattern;
 public class BeiLunThreeLevelWardDocTrans extends ModelDocTrans {
 
     private List<OperationDoc> operationDocs;
+    private List<String> containList = Arrays.asList("查房", "主任", "主治", "主刀", "日常病程", "病程记录", "术后第");
 
     @Override
     public List<ThreeLevelWardDoc> extract(MedrecVo medrecVo) {
@@ -57,77 +53,88 @@ public class BeiLunThreeLevelWardDocTrans extends ModelDocTrans {
     }
 
     private void classifyThreeLevelWardDoc(ThreeLevelWardDoc threeLevelWardDoc, Map<String, Object> contentMap) {
-        String content = contentMap.get("xmlText").toString();
-        Map<String, String> structureMap = null;
-        if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
-            structureMap = (Map) FastJsonUtils.getJsonToMap(content);
-        } else {
-            String recTitle = contentMap.get("recTitle").toString();
-            String recTypeId = contentMap.get("recTypeId").toString();
-            BeiLunHtmlAnalysis beiLunHtmlAnalysis = new BeiLunThreeLevelWardHtmlAnalysis();
-            Map<String, String> sourceMap = beiLunHtmlAnalysis.analysis(content, recTitle, recTypeId);
-            if (MapUtils.isNotEmpty(sourceMap)) {
-                structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
-                structureMap.put("记录编号", contentMap.get("recId").toString());
-                structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
+        if (contentMap.get("recTitle") != null && StringUtil.isNotBlank(contentMap.get("recTitle").toString())) {
+            boolean flag = false;
+            for (String word : containList) {
+                if (contentMap.get("recTitle").toString().contains(word)) {
+                    flag = true;
+                    break;
+                }
             }
-        }
-        if (MapUtils.isEmpty(structureMap)) {
-            return;
-        }
+            if (flag) {
+                String content = contentMap.get("xmlText").toString();
+                Map<String, String> structureMap = null;
+                if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
+                    structureMap = (Map) FastJsonUtils.getJsonToMap(content);
+                } else {
+                    String recTitle = contentMap.get("recTitle").toString();
+                    String recTypeId = contentMap.get("recTypeId").toString();
+                    BeiLunHtmlAnalysis beiLunHtmlAnalysis = new BeiLunThreeLevelWardHtmlAnalysis();
+                    Map<String, String> sourceMap = beiLunHtmlAnalysis.analysis(content, recTitle, recTypeId);
+                    if (MapUtils.isNotEmpty(sourceMap)) {
+                        structureMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
+                        structureMap.put("记录编号", contentMap.get("recId").toString());
+                        structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
+                    }
+                }
+                if (MapUtils.isEmpty(structureMap)) {
+                    return;
+                }
 
-        if (structureMap.containsKey("病情记录")) {
-            structureMap.put("病情记录", structureMap.get("病情记录").replace(" ", ""));
-        }
-        //structureMap.put("查房日期", structureMap.get("记录时间"));
+                if (structureMap.containsKey("病情记录")) {
+                    structureMap.put("病情记录", structureMap.get("病情记录").replace(" ", ""));
+                }
+                //structureMap.put("查房日期", structureMap.get("记录时间"));
 
-        /*Map<String, String> cutWordMap = Maps.newHashMap();
-        String text = CxXmlUtil.getXmlText(content);
-        if (StringUtil.isNotBlank(text)) {
-            if (StringUtil.isBlank(structureMap.get("病情记录"))) {
-                structureMap.put("病情记录", text);
-            }
-            cutWordMap = Preproc.getCutWordMap(true, sourceTitles, text);
-            if (StringUtil.isBlank(structureMap.get("记录医师"))) {
-                Pattern p = Pattern.compile("^[^\\u4e00-\\u9fa5]+$");//分词结果如果不包含中文为日期,则不覆盖
-                if (StringUtil.isNotEmpty(cutWordMap.get("医师签名"))) {
-                    Matcher m = p.matcher(cutWordMap.get("医师签名"));
-                    if (!m.matches()) {
-                        structureMap.put("记录医师", cutWordMap.get("医师签名"));
+                /*Map<String, String> cutWordMap = Maps.newHashMap();
+                String text = CxXmlUtil.getXmlText(content);
+                if (StringUtil.isNotBlank(text)) {
+                    if (StringUtil.isBlank(structureMap.get("病情记录"))) {
+                        structureMap.put("病情记录", text);
                     }
-                }
-                if (StringUtil.isNotEmpty(cutWordMap.get("记录医生"))) {
-                    Matcher m = p.matcher(cutWordMap.get("记录医生"));
-                    if (!m.matches()) {
-                        structureMap.put("记录医师", cutWordMap.get("记录医生"));
+                    cutWordMap = Preproc.getCutWordMap(true, sourceTitles, text);
+                    if (StringUtil.isBlank(structureMap.get("记录医师"))) {
+                        Pattern p = Pattern.compile("^[^\\u4e00-\\u9fa5]+$");//分词结果如果不包含中文为日期,则不覆盖
+                        if (StringUtil.isNotEmpty(cutWordMap.get("医师签名"))) {
+                            Matcher m = p.matcher(cutWordMap.get("医师签名"));
+                            if (!m.matches()) {
+                                structureMap.put("记录医师", cutWordMap.get("医师签名"));
+                            }
+                        }
+                        if (StringUtil.isNotEmpty(cutWordMap.get("记录医生"))) {
+                            Matcher m = p.matcher(cutWordMap.get("记录医生"));
+                            if (!m.matches()) {
+                                structureMap.put("记录医师", cutWordMap.get("记录医生"));
+                            }
+                        }
                     }
                 }
-            }
-        }
-         */
+                 */
 
-        //总的查房记录 汇总
-        ThreeLevelWardDoc allDoctorWradDoc = new ThreeLevelWardDoc();
-        allDoctorWradDoc.setStructureMap(structureMap);
-        allDoctorWradDoc.setPageData((Map) structureMap);
-        threeLevelWardDoc.addAllDoctorWradDoc(allDoctorWradDoc);
+                //总的查房记录 汇总
+                ThreeLevelWardDoc allDoctorWradDoc = new ThreeLevelWardDoc();
+                allDoctorWradDoc.setStructureMap(structureMap);
+                allDoctorWradDoc.setPageData((Map) structureMap);
+                threeLevelWardDoc.addAllDoctorWradDoc(allDoctorWradDoc);
 
-        //主任医师查房
-        DirectorDoctorWardDoc directorDoctorWardDoc = findDirectorDoctorWardDoc(structureMap);
-        if (directorDoctorWardDoc != null) {
-            threeLevelWardDoc.addDirectorDoctorWardDoc(findDirectorDoctorWardDoc(structureMap));
-        }
-        //主治医师查房
-        AttendingDoctorWardDoc attendingDoctorWardDoc = findAttendingDoctorWardDoc(structureMap);
-        if (attendingDoctorWardDoc != null) {
-            threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
-        }
-        //普通医师查房
-        if (directorDoctorWardDoc == null && attendingDoctorWardDoc == null) {
-            GeneralDoctorWardDoc generalDoctorWardDoc = new GeneralDoctorWardDoc();
-            generalDoctorWardDoc.setStructureMap(structureMap);
-            generalDoctorWardDoc.setPageData((Map) structureMap);
-            threeLevelWardDoc.addGeneralDoctorWardDoc(generalDoctorWardDoc);
+                //主任医师查房
+                DirectorDoctorWardDoc directorDoctorWardDoc = findDirectorDoctorWardDoc(structureMap);
+                if (directorDoctorWardDoc != null) {
+                    threeLevelWardDoc.addDirectorDoctorWardDoc(findDirectorDoctorWardDoc(structureMap));
+                }
+                //主治医师查房
+                AttendingDoctorWardDoc attendingDoctorWardDoc = findAttendingDoctorWardDoc(structureMap);
+                if (attendingDoctorWardDoc != null) {
+                    threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
+                }
+                //普通医师查房
+                if (directorDoctorWardDoc == null && attendingDoctorWardDoc == null) {
+                    GeneralDoctorWardDoc generalDoctorWardDoc = new GeneralDoctorWardDoc();
+                    generalDoctorWardDoc.setStructureMap(structureMap);
+                    generalDoctorWardDoc.setPageData((Map) structureMap);
+                    threeLevelWardDoc.addGeneralDoctorWardDoc(generalDoctorWardDoc);
+                }
+            }
         }
     }
 
@@ -253,13 +260,6 @@ public class BeiLunThreeLevelWardDocTrans extends ModelDocTrans {
             director = content.substring(0, content.indexOf(","));
         }
         return director.contains("主治");
-//        Pattern p = Pattern.compile("(?<=主治医师).+?(?=住院医师)");
-//        Matcher m = p.matcher(content);
-//        String result = "";
-//        while (m.find()) {
-//            result = m.group().trim();
-//        }
-//        return StringUtil.isNotEmpty(result.replace(":", "").replace(":", ""));
     }
 
     private String subTitle(String srcText) {

+ 82 - 2
trans/src/main/java/com/lantone/qc/trans/beilun/BeilunDocTrans.java

@@ -1,5 +1,7 @@
 package com.lantone.qc.trans.beilun;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.TypeReference;
 import com.google.common.collect.Lists;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.vo.MedrecVo;
@@ -8,9 +10,9 @@ import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.DocTrans;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
+import lombok.extern.slf4j.Slf4j;
 
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -19,11 +21,25 @@ import java.util.stream.Collectors;
  * @Author : 楼辉荣
  * @Date: 2020-03-03 19:47
  */
+@Slf4j
 public class BeilunDocTrans extends DocTrans {
 
     @Override
     protected InputInfo extract(QueryVo queryVo) {
         InputInfo inputInfo = new InputInfo();
+        for (MedrecVo i : queryVo.getMedrec()) {
+            if (i.getTitle() != null && i.getTitle().equals("查房记录")) {
+                List<Map<String, Object>> contentMaps = (List) i.getContent().get("content");
+                contentMaps.forEach(contentMap -> {
+                    try {
+                        threeLevelWardAnalyse(queryVo, contentMaps, contentMap);
+                    } catch (Exception e) {
+                        log.error(e.getMessage(), e);
+                    }
+                });
+            }
+        }
+
         for (MedrecVo i : queryVo.getMedrec()) {
             if (i.getTitle() != null) {
                 if (i.getTitle().equals("会诊")) {
@@ -260,4 +276,68 @@ public class BeilunDocTrans extends DocTrans {
         }
     }
 
+    private void threeLevelWardAnalyse(QueryVo queryVo, List<Map<String, Object>> contentMaps, Map<String, Object> contentMap) {
+        String recTitle = contentMap.get("recTitle").toString();
+        if (StringUtil.isNotBlank(recTitle)) {
+            if (recTitle.contains("会诊记录")) {
+                consultationAnalyseMap(queryVo, contentMaps, contentMap, "会诊记录");
+            }
+            if (recTitle.contains("输血制品病程") || recTitle.contains("输血记录") || recTitle.contains("输血病程记录")) {
+                commonAnalyseList(queryVo, contentMaps, contentMap, "输血/血制品病程记录");
+            }
+            if (recTitle.contains("输血") && (recTitle.contains("评价") || recTitle.contains("评估"))) {
+                commonAnalyseList(queryVo, contentMaps, contentMap, "输血后效果评价");
+            }
+            if (recTitle.contains("术后首次") && recTitle.contains("病程")) {
+                consultationAnalyseMap(queryVo, contentMaps, contentMap, "术后首次病程及谈话记录");
+            }
+            if (recTitle.contains("危急值") && recTitle.contains("记录")) {
+                commonAnalyseList(queryVo, contentMaps, contentMap, "危急值记录");
+            }
+        }
+    }
+
+    //(List)
+    private void commonAnalyseList(QueryVo queryVo, List<Map<String, Object>> contentMaps, Map<String, Object> contentMap, String recTitle) {
+        for (MedrecVo i : queryVo.getMedrec()) {
+            if (recTitle.contains(i.getTitle())) {
+                List<Map<String, Object>> specialContent = new ArrayList<>();
+                Map<String, Object> keyContent = i.getContent();
+                try {
+                    specialContent = JSON.parseObject(JSON.toJSONString(keyContent.get("content")), new TypeReference<List<Map<String, Object>>>() {
+                    });
+                    specialContent.add(contentMap);
+                    keyContent.put("content", specialContent);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    //(Map)
+    private void consultationAnalyseMap(QueryVo queryVo, List<Map<String, Object>> contentMaps, Map<String, Object> contentMap, String recTitle) {
+        for (MedrecVo i : queryVo.getMedrec()) {
+            if (recTitle.contains(i.getTitle())) {
+                Map<String, List<Map<String, Object>>> specialContent = new LinkedHashMap<>();
+                List<Map<String, Object>> recordContentDTOS = new ArrayList<>();
+                recordContentDTOS.add(contentMap);
+
+                Map<String, Object> keyContent = i.getContent();
+                try {
+                    specialContent = JSON.parseObject(JSON.toJSONString(keyContent.get("content")), new TypeReference<Map<String, List<Map<String, Object>>>>() {
+                    });
+                    if (specialContent.containsKey(recTitle)) {
+                        specialContent.get(recTitle).add(contentMap);
+                    } else {
+                        specialContent.put(recTitle, recordContentDTOS);
+                    }
+                    keyContent.put("content", specialContent);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
 }