Browse Source

长兴查房记录修改

rengb 5 năm trước cách đây
mục cha
commit
87d1c54446

+ 94 - 24
trans/src/main/java/com/lantone/qc/trans/changx/ChangxThreeLevelWardDocTrans.java

@@ -1,14 +1,18 @@
 package com.lantone.qc.trans.changx;
 
 import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.ward.AttendingDoctorWardDoc;
+import com.lantone.qc.pub.model.doc.ward.DirectorDoctorWardDoc;
+import com.lantone.qc.pub.model.doc.ward.GeneralDoctorWardDoc;
 import com.lantone.qc.pub.model.vo.MedrecVo;
 import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
 import com.lantone.qc.trans.changx.util.CxXmlUtil;
-import com.lantone.qc.trans.comsis.ModelDocGenerate;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import com.lantone.qc.trans.comsis.Preproc;
+import org.apache.commons.lang3.StringUtils;
 
 import java.util.List;
 import java.util.Map;
@@ -24,43 +28,109 @@ public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
     public List<ThreeLevelWardDoc> extract(MedrecVo medrecVo) {
         List<ThreeLevelWardDoc> retList = Lists.newArrayList();
         List<String> contents = (List) medrecVo.getContent().get("content");
+        ThreeLevelWardDoc threeLevelWardDoc = new ThreeLevelWardDoc();
         contents.forEach(content -> {
-            retList.add(getThreeLevelWardDoc(content));
+            classifyThreeLevelWardDoc(threeLevelWardDoc, content);
         });
+        retList.add(threeLevelWardDoc);
         return retList;
     }
 
-    private ThreeLevelWardDoc getThreeLevelWardDoc(String content) {
+    private void classifyThreeLevelWardDoc(ThreeLevelWardDoc threeLevelWardDoc, String content) {
+        Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
+        structureMap.put("查房日期", structureMap.get("记录时间"));
+
+        Map<String, String> cutWordMap = Maps.newHashMap();
         String text = CxXmlUtil.getTextByNodePath(content, "//DocObjContent/Region/Content_Text");
-        if (StringUtil.isBlank(text)) {
-            text = CxXmlUtil.getTextByNodePath(content, "//DocObjContent/Region");
+        if (StringUtil.isNotBlank(text)) {
+            if (StringUtil.isBlank(structureMap.get("病情记录"))) {
+                structureMap.put("病情记录", text);
+            }
+            cutWordMap = Preproc.getCutWordMap(true, sourceTitles, text);
+            if (StringUtil.isBlank(structureMap.get("记录医师"))) {
+                structureMap.put("记录医师", cutWordMap.get("医师签名"));
+            }
         }
-        Map<String, String> cutWordMap = Preproc.getCutWordMap(true, sourceTitles, text);
-        Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
-        cutWordMap.putAll(xmlNodeValueMap);
-        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(cutWordMap, keyContrasts);
-        structureMap.put("记录时间", structureMap.get("记录日期"));
-        structureMap.put("查房日期", structureMap.get("记录日期"));
-        structureMap.put("病情记录", text);
-        int endIndex = text.indexOf("查房记录");
-        if (endIndex > 0) {
-            String title = text.substring(0, endIndex);
-            title = title.substring(title.lastIndexOf(" ") + 1) + "查房记录";
-            structureMap.put("查房标题", title);
+
+        //总的查房记录 汇总
+        ThreeLevelWardDoc allDoctorWradDoc = new ThreeLevelWardDoc();
+        allDoctorWradDoc.setStructureMap(structureMap);
+        allDoctorWradDoc.setPageData((Map) xmlNodeValueMap);
+        threeLevelWardDoc.addAllDoctorWradDoc(allDoctorWradDoc);
+
+        //主任医师查房
+        DirectorDoctorWardDoc directorDoctorWardDoc = findDirectorDoctorWardDoc(xmlNodeValueMap, structureMap);
+        if (directorDoctorWardDoc != null) {
+            threeLevelWardDoc.addDirectorDoctorWardDoc(findDirectorDoctorWardDoc(xmlNodeValueMap, structureMap));
+        }
+        //主治医师查房
+        AttendingDoctorWardDoc attendingDoctorWardDoc = findAttendingDoctorWardDoc(xmlNodeValueMap, structureMap);
+        if (attendingDoctorWardDoc != null) {
+            threeLevelWardDoc.addAttendingDoctorWardDoc(attendingDoctorWardDoc);
+        }
+        //普通医师查房
+        if (directorDoctorWardDoc == null && attendingDoctorWardDoc == null) {
+            GeneralDoctorWardDoc generalDoctorWardDoc = new GeneralDoctorWardDoc();
+            generalDoctorWardDoc.setStructureMap(structureMap);
+            generalDoctorWardDoc.setPageData((Map) xmlNodeValueMap);
+            threeLevelWardDoc.addGeneralDoctorWardDoc(generalDoctorWardDoc);
+        }
+    }
+
+    /**
+     * 主任医师查房
+     *
+     * @param sourceMap
+     * @param structureMap
+     */
+    private DirectorDoctorWardDoc findDirectorDoctorWardDoc(Map<String, String> sourceMap, Map<String, String> structureMap) {
+        String title = structureMap.get("查房标题");
+        title = subTitle(title);    //标题有代字
+
+        DirectorDoctorWardDoc directorDoctorWardDoc = null;
+        if (StringUtils.isNotEmpty(title) && title.contains("主任")) {
+            directorDoctorWardDoc = new DirectorDoctorWardDoc();
+            directorDoctorWardDoc.setStructureMap(structureMap);
+            directorDoctorWardDoc.setPageData((Map) sourceMap);
+        }
+        return directorDoctorWardDoc;
+    }
+
+    /**
+     * 主治医师查房
+     *
+     * @param sourceMap
+     * @param structureMap
+     */
+    private AttendingDoctorWardDoc findAttendingDoctorWardDoc(Map<String, String> sourceMap, Map<String, String> structureMap) {
+        String title = structureMap.get("查房标题");
+        title = subTitle(title);    //标题有代字
+        AttendingDoctorWardDoc attendingDoctorWardDoc = null;
+        if (StringUtils.isNotEmpty(title) && title.contains("主治")) {
+            attendingDoctorWardDoc = new AttendingDoctorWardDoc();
+            attendingDoctorWardDoc.setStructureMap(structureMap);
+            attendingDoctorWardDoc.setPageData((Map) sourceMap);
+        }
+        return attendingDoctorWardDoc;
+    }
+
+    private String subTitle(String srcText) {
+        if (StringUtil.isNotBlank(srcText) && srcText.contains("代") && srcText.indexOf("代") != srcText.length() - 1) {
+            srcText = srcText.substring(srcText.indexOf("代") + 1);
         }
-        ThreeLevelWardDoc threeLevelWardDoc = ModelDocGenerate.threeLevelWardDocGen(structureMap);
-        threeLevelWardDoc.setText(text);
-        threeLevelWardDoc.setPageData((Map) xmlNodeValueMap);
-        return threeLevelWardDoc;
+        return srcText;
     }
 
     private List<String> sourceTitles = Lists.newArrayList(
-            "记录医生"
+            "医师签名"
     );
 
     private List<String> keyContrasts = Lists.newArrayList(
-            "记录医生=记录医师",
-            "签名++++=记录医师"
+            "病程记录标题=查房标题",
+            "在此输入查房记录=病情记录",
+            "签名++++=记录医师",
+            "记录日期=记录时间"
     );
 
 }