Browse Source

1.长兴新需求添加修改:
1.1 质控未在出院三天内完成
1.2 主诉时间应该为阿拉伯数字
1.3 住院30天患者需写“阶段小结”,添加转科记录计算逻辑
1.4 长兴、台州转科记录trans层修改
1.5 出院记录未在24小时内完成修改逻辑
1.6 出院前最后一次病程录修改逻辑
1.7 添加条目:抢救记录6小时内
2.修改之前遗漏bug

hujing 5 years ago
parent
commit
40f9dcbb7c
21 changed files with 635 additions and 246 deletions
  1. 53 0
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH02860.java
  2. 116 15
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0296.java
  3. 5 8
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0597.java
  4. 8 10
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0598.java
  5. 18 15
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0599.java
  6. 50 0
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP02859.java
  7. 13 5
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0148.java
  8. 26 25
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/operationdiscussion/OPE0647.java
  9. 6 5
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0094.java
  10. 4 4
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0595.java
  11. 4 4
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0596.java
  12. 8 4
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0700.java
  13. 48 0
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0725.java
  14. 2 2
      kernel/src/main/resources/application.yml
  15. 1 1
      public/src/main/java/com/lantone/qc/pub/model/InputInfo.java
  16. 11 3
      public/src/main/java/com/lantone/qc/pub/model/doc/transferrecord/TransferRecordDoc.java
  17. 4 4
      trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java
  18. 133 94
      trans/src/main/java/com/lantone/qc/trans/changx/ChangxTransferRecordDocTrans.java
  19. 1 24
      trans/src/main/java/com/lantone/qc/trans/comsis/ModelDocGenerate.java
  20. 122 21
      trans/src/main/java/com/lantone/qc/trans/taizhou/TaiZhouTransferRecordDocTrans.java
  21. 2 2
      trans/src/main/java/com/lantone/qc/trans/taizhou/TaizhouDocTrans.java

+ 53 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH02860.java

@@ -0,0 +1,53 @@
+package com.lantone.qc.kernel.catalogue.behospitalized;
+
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.entity.Clinical;
+import com.lantone.qc.pub.model.entity.PD;
+import com.lantone.qc.pub.model.label.ChiefLabel;
+import com.lantone.qc.pub.util.ListUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+
+/**
+ * @ClassName : BEH02860
+ * @Description :主诉时间应该为阿拉伯数字
+ * @Author : 胡敬
+ * @Date: 2020-04-29 09:57
+ */
+@Component
+public class BEH02860 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        if (inputInfo.getBeHospitalizedDoc() == null) {
+            status.set("0");
+            return;
+        }
+        ChiefLabel chiefLabel = inputInfo.getBeHospitalizedDoc().getChiefLabel();
+        if (chiefLabel == null) {
+            status.set("0");
+            return;
+        }
+        String regex = "[零一二三四五六七八九十百千]";
+        List<PD> pds = chiefLabel.getPds();
+        if (ListUtil.isNotEmpty(pds)) {
+            String name = null, value = null;
+            for (PD pd : pds) {
+                name = pd.getName();
+                value = pd.getValue();
+                if (value != null && Pattern.matches(regex, value)) {
+                    status.set("-1");
+                    return;
+                }
+                if (name != null && Pattern.matches(regex, name)) {
+                    status.set("-1");
+                    return;
+                }
+            }
+        }
+    }
+}

+ 116 - 15
kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0296.java

@@ -5,9 +5,11 @@ import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
 import com.lantone.qc.pub.model.doc.StagesSummaryDoc;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -17,6 +19,7 @@ import java.util.Map;
  * @ClassName : DUT0296
  * @Description : 无阶段小结
  * 住院时间超过1个月需要阶段小结, 出院时间和入院时间做比较,超过一个月查找阶段小结
+ * 住院30天患者需写“阶段小结”,但在住院期间转科的患者,时间应该是从转科那天算起。
  * @Author : 楼辉荣
  * @Date: 2020-03-06 17:28
  */
@@ -24,35 +27,133 @@ import java.util.Map;
 public class DUT0296 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
-
         LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
+        if (leaveHospitalDoc == null) {
+            return;
+        }
+        Map<String, String> structureMap_leave = leaveHospitalDoc.getStructureMap();
+        String beDate = structureMap_leave.get("入院时间"); //2019-12-07 08:48
+        String leaveDate = structureMap_leave.get("出院时间");//2019-12-10 10:49
+        if (StringUtil.isBlank(beDate) || StringUtil.isBlank(leaveDate)) {
+            return;
+        }
         List<StagesSummaryDoc> stagesSummaryDocs = inputInfo.getStagesSummaryDocs();
-        if (leaveHospitalDoc != null) {
-            Map<String, String> structureMap_leave = leaveHospitalDoc.getStructureMap();
-            String be_date = structureMap_leave.get("入院时间"); //2019-12-07 08:48
-            String leave_date = structureMap_leave.get("出院时间");//2019-12-10 10:49
-            if (StringUtil.isNotBlank(be_date) && StringUtil.isNotBlank(leave_date)) {
-                int ffr = ffr(be_date, leave_date);
-                if(ffr >= 31 && (stagesSummaryDocs == null || stagesSummaryDocs.size() == 0)){
+
+        TransferRecordDoc transferRecordDoc = inputInfo.getTransferRecordDocs();//转科记录
+        if (transferRecordDoc != null) {
+            List<TransferRecordDoc> allTransferDocs = transferRecordDoc.getAllTransferDocs();
+            String firstOutRecordDate = getFirstOutRecordDate(allTransferDocs);
+            if (StringUtil.isNotBlank(firstOutRecordDate)) {
+                //入院时间到第一次转出时间,大于30天则报错
+                int dateDifference = dateDifference(beDate, firstOutRecordDate);
+                if (dateDifference > 30 && (stagesSummaryDocs == null || stagesSummaryDocs.size() == 0)) {
+                    status.set("-1");
+                    return;
+                }
+            }
+            String lastInrecordDate = getLastInrecordDate(allTransferDocs);
+            if (StringUtil.isNotBlank(lastInrecordDate)) {
+                //最后一次转入时间到出院时间,大于30天则报错
+                int dateDifference = dateDifference(lastInrecordDate, leaveDate);
+                if (dateDifference > 30 && (stagesSummaryDocs == null || stagesSummaryDocs.size() == 0)) {
                     status.set("-1");
+                    return;
                 }
             }
+            List<String> allRecordPairs = getAllRecordPairs(allTransferDocs);
+            for (String recordPair : allRecordPairs) {
+                String[] recordPairSplit = recordPair.split(",");
+                int dateDifference = dateDifference(recordPairSplit[0], recordPairSplit[1]);
+                if (dateDifference > 30 && (stagesSummaryDocs == null || stagesSummaryDocs.size() == 0)) {
+                    status.set("-1");
+                    return;
+                }
+            }
+        } else {
+            //没有转科记录,直接入院时间和出院时间比
+            int dateDifference = dateDifference(beDate, leaveDate);
+            if (dateDifference >= 31 && (stagesSummaryDocs == null || stagesSummaryDocs.size() == 0)) {
+                status.set("-1");
+            }
         }
     }
 
-    private int ffr(String be_date, String leave_date) {
-        int day=0;
+    /**
+     * 获取第一条转出记录时间
+     *
+     * @param allTransferDocs
+     * @return
+     */
+    private String getFirstOutRecordDate(List<TransferRecordDoc> allTransferDocs) {
+        for (TransferRecordDoc transferDoc : allTransferDocs) {
+            Map<String, String> structureMap = transferDoc.getStructureMap();
+            String outDepartment = structureMap.get("转出科室");
+            if (StringUtil.isBlank(outDepartment)) {
+                //如果转出科室为空,则为转出记录
+                return structureMap.get("转科日期");
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 获取最后一条转入记录
+     *
+     * @param allTransferDocs
+     * @return
+     */
+    private String getLastInrecordDate(List<TransferRecordDoc> allTransferDocs) {
+        for (int i = allTransferDocs.size() - 1; i > 0; i--) {
+            Map<String, String> structureMap = allTransferDocs.get(i).getStructureMap();
+            String outDepartment = structureMap.get("转出科室");
+            if (StringUtil.isNotBlank(outDepartment)) {
+                //如果转出科室不为空,则为转入记录
+                return structureMap.get("转科日期");
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 获取所有转入时间-转出时间 pair
+     *
+     * @param allTransferDocs
+     * @return
+     */
+    private List<String> getAllRecordPairs(List<TransferRecordDoc> allTransferDocs) {
+        List<String> allRecordPairs = new ArrayList<>();
+        for (int i = 0; i < allTransferDocs.size(); i++) {
+            Map<String, String> structureMap = allTransferDocs.get(i).getStructureMap();
+            String outDepartment = structureMap.get("转出科室");
+            if (StringUtil.isNotBlank(outDepartment)) {
+                //如果转出科室不为空,则为转入记录
+                String transferDateInStr = structureMap.get("转科日期");
+                if (i + 1 < allTransferDocs.size()) {
+                    //如果转入记录下一条是转出记录
+                    Map<String, String> nextStructureMap = allTransferDocs.get(i + 1).getStructureMap();
+                    if (StringUtil.isBlank(nextStructureMap.get("转出科室"))) {
+                        //如果转出科室为空,则为转出记录
+                        String transferDateOutStr = nextStructureMap.get("转科日期");
+                        allRecordPairs.add(transferDateInStr + "," + transferDateOutStr);
+                    }
+                }
+            }
+        }
+        return allRecordPairs;
+    }
+
+    private int dateDifference(String beDate, String leaveDate) {
+        int day = 0;
         try {
-            Date date_in = StringUtil.parseDateTime(be_date);
-            Date date_out = StringUtil.parseDateTime(leave_date);
+            Date dateIn = StringUtil.parseDateTime(beDate);
+            Date dateOut = StringUtil.parseDateTime(leaveDate);
             Calendar from = Calendar.getInstance();
-            from.setTime(date_in);
+            from.setTime(dateIn);
             Calendar to = Calendar.getInstance();
-            to.setTime(date_out);
+            to.setTime(dateOut);
             int fromMonth = from.get(Calendar.DAY_OF_YEAR);
             int toMonth = to.get(Calendar.DAY_OF_YEAR);
             day = toMonth - fromMonth;
-
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 5 - 8
kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0597.java

@@ -24,19 +24,16 @@ import java.util.Map;
 public class DUT0597 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
-        List<TransferRecordDoc> transferRecordDocs = inputInfo.getTransferRecordDocs();
-        if (ListUtil.isEmpty(transferRecordDocs)) {
+        TransferRecordDoc transferRecordDoc = inputInfo.getTransferRecordDocs();
+        if (transferRecordDoc == null) {
             return;
         }
         String rollOutRecordDateStr = "", recordDateStr = "";
-        for (TransferRecordDoc transferRecordDoc : transferRecordDocs) {
-            TransferOutDoc transferOutDoc = transferRecordDoc.getTransferOutDoc();
-            if (transferOutDoc == null) {
-                continue;
-            }
+        List<TransferOutDoc> transferOutDocs = transferRecordDoc.getTransferOutDocs();
+        for (TransferOutDoc transferOutDoc : transferOutDocs) {
             Map<String, String> transferOutStructureMap = transferOutDoc.getStructureMap();
             rollOutRecordDateStr = transferOutStructureMap.get("转科日期");
-            recordDateStr = transferOutStructureMap.get("书写时间");
+            recordDateStr = transferOutStructureMap.get("记录日期");
             if (CatalogueUtil.isEmpty(rollOutRecordDateStr) || CatalogueUtil.isEmpty(recordDateStr)) {
                 continue;
             }

+ 8 - 10
kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0598.java

@@ -4,6 +4,7 @@ import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
 import com.lantone.qc.pub.util.ListUtil;
@@ -24,19 +25,16 @@ import java.util.Map;
 public class DUT0598 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
-        List<TransferRecordDoc> transferRecordDocs = inputInfo.getTransferRecordDocs();
-        if (ListUtil.isEmpty(transferRecordDocs)) {
+        TransferRecordDoc transferRecordDoc = inputInfo.getTransferRecordDocs();
+        if (transferRecordDoc == null) {
             return;
         }
+        List<TransferIntoDoc> transferIntoDocs = transferRecordDoc.getTransferIntoDocs();
         String rollInRecordDateStr = "", recordDateStr = "";
-        for (TransferRecordDoc transferRecordDoc : transferRecordDocs) {
-            TransferOutDoc transferOutDoc = transferRecordDoc.getTransferOutDoc();
-            if (transferOutDoc == null) {
-                continue;
-            }
-            Map<String, String> transferOutStructureMap = transferOutDoc.getStructureMap();
-            rollInRecordDateStr = transferOutStructureMap.get("患者于");
-            recordDateStr = transferOutStructureMap.get("书写时间");
+        for (TransferIntoDoc transferIntoDoc : transferIntoDocs) {
+            Map<String, String> transferOutStructureMap = transferIntoDoc.getStructureMap();
+            rollInRecordDateStr = transferOutStructureMap.get("转科日期");
+            recordDateStr = transferOutStructureMap.get("记录日期");
             if (CatalogueUtil.isEmpty(rollInRecordDateStr) || CatalogueUtil.isEmpty(recordDateStr)) {
                 continue;
             }

+ 18 - 15
kernel/src/main/java/com/lantone/qc/kernel/catalogue/dutyshiftsystem/DUT0599.java

@@ -5,6 +5,7 @@ import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
 import com.lantone.qc.pub.util.DateUtil;
@@ -12,6 +13,7 @@ import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -27,30 +29,28 @@ import java.util.Map;
 public class DUT0599 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
-        List<TransferRecordDoc> transferRecordDocs = inputInfo.getTransferRecordDocs();
+        TransferRecordDoc transferRecordDoc = inputInfo.getTransferRecordDocs();
         List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
-        if (ListUtil.isEmpty(transferRecordDocs) || ListUtil.isEmpty(threeLevelWardDocs)) {
+        if (transferRecordDoc == null || ListUtil.isEmpty(threeLevelWardDocs)) {
             return;
         }
         //所有查房记录的日期天
-        List<Integer> wardRecordDayList = getWardRecordDay(threeLevelWardDocs);
+        List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
+        List<Date> wardRecordDayList = getWardRecordDay(allDoctorWradDocs);
         String rollInRecordDateStr = "";
         //转入日期后应该有的查房记录的日期天
-        List<Integer> rollInDay = null;
-        for (TransferRecordDoc transferRecordDoc : transferRecordDocs) {
-            TransferOutDoc transferOutDoc = transferRecordDoc.getTransferOutDoc();
-            if (transferOutDoc == null) {
-                continue;
-            }
-            Map<String, String> transferOutStructureMap = transferOutDoc.getStructureMap();
-            rollInRecordDateStr = transferOutStructureMap.get("患者于");
+        List<Date> rollInDay = null;
+        List<TransferIntoDoc> transferIntoDocs = transferRecordDoc.getTransferIntoDocs();
+        for (TransferIntoDoc transferIntoDoc : transferIntoDocs) {
+            Map<String, String> transferOutStructureMap = transferIntoDoc.getStructureMap();
+            rollInRecordDateStr = transferOutStructureMap.get("转科日期");
             if (CatalogueUtil.isEmpty(rollInRecordDateStr)) {
                 continue;
             }
             Date rollInRecordDate = StringUtil.parseDateTime(rollInRecordDateStr);
             rollInDay = new ArrayList<>();
             for (int i = 1; i <= 3; i++) {
-                int wardRecordDay = DateUtil.getDay(DateUtil.addDate(rollInRecordDate, i));
+                Date wardRecordDay = DateUtil.dateZeroClear(DateUtil.addDate(rollInRecordDate, i));
                 rollInDay.add(wardRecordDay);
             }
             if (!wardRecordDayList.containsAll(rollInDay)) {
@@ -65,17 +65,20 @@ public class DUT0599 extends QCCatalogue {
      *
      * @param threeLevelWardDocs
      */
-    private List<Integer> getWardRecordDay(List<ThreeLevelWardDoc> threeLevelWardDocs) {
-        List<Integer> dateRecordDay = new ArrayList<>();
+    private List<Date> getWardRecordDay(List<ThreeLevelWardDoc> threeLevelWardDocs) {
+        List<Date> dateRecordDay = new ArrayList<>();
         String recordTime = "";
         for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
             Map<String, String> rescueStructureMap = threeLevelWardDoc.getStructureMap();
             recordTime = rescueStructureMap.get("查房日期");
+            if (StringUtil.isBlank(recordTime)){
+                continue;
+            }
             Date recordDate = StringUtil.parseDateTime(recordTime);
             if (recordDate == null) {
                 continue;
             }
-            dateRecordDay.add(DateUtil.getDay(recordDate));
+            dateRecordDay.add(DateUtil.dateZeroClear(recordDate));
         }
         return dateRecordDay;
     }

+ 50 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP02859.java

@@ -0,0 +1,50 @@
+package com.lantone.qc.kernel.catalogue.firstpagerecord;
+
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
+import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * @ClassName : FIRP02859
+ * @Description :质控未在出院三天内完成
+ * @Author : 胡敬
+ * @Date: 2020-04-29 09:43
+ */
+@Component
+public class FIRP02859 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
+        LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
+        if (firstPageRecordDoc == null || leaveHospitalDoc == null) {
+            status.set("0");
+            return;
+        }
+        Map<String, String> firstStructureMap = firstPageRecordDoc.getStructureMap();
+        String qcDateStr = firstStructureMap.get("质控日期");
+        Map<String, String> leaveStructureMap = leaveHospitalDoc.getStructureMap();
+        String leaveDateStr = leaveStructureMap.get("出院时间");
+        if (StringUtil.isBlank(qcDateStr) || StringUtil.isBlank(leaveDateStr)) {
+            status.set("0");
+            return;
+        }
+        Date qcDate = StringUtil.parseDateTime(qcDateStr);
+        Date leaveDate = StringUtil.parseDateTime(leaveDateStr);
+        if (qcDate == null || leaveDate == null) {
+            status.set("0");
+            return;
+        }
+        boolean overTime = CatalogueUtil.compareTime(leaveDate, qcDate, 72 * 60L);
+        if (!overTime) {
+            //质控日期在出院时间三天内完成
+            status.set("0");
+        }
+    }
+}

+ 13 - 5
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0148.java

@@ -1,6 +1,7 @@
 package com.lantone.qc.kernel.catalogue.leavehospital;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.DeathRecordDoc;
@@ -9,6 +10,8 @@ import com.lantone.qc.pub.util.DateUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
+
 /**
  * @Description: 出院记录未在患者出院前完成
  * @author: rengb
@@ -29,12 +32,17 @@ public class LEA0148 extends QCCatalogue {
         } else {
             String timeQm = leaveHospitalDoc.getStructureMap().get("签名时间");
             String timeCy = leaveHospitalDoc.getStructureMap().get("出院时间");
-            if (StringUtil.isNotBlank(timeQm)
-                    && StringUtil.isNotBlank(timeCy)
-                    && DateUtil.parseDate(timeQm).getTime() <= DateUtil.parseDate(timeCy).getTime()) {
-                status.set("0");
+            if (StringUtil.isNotBlank(timeQm) && StringUtil.isNotBlank(timeCy)) {
+                Date timeQmDate = StringUtil.parseDateTime(timeQm);
+                Date timeCyDate = StringUtil.parseDateTime(timeCy);
+                if (timeQmDate == null && timeCyDate == null) {
+                    status.set("0");
+                    return;
+                }
+                if (!CatalogueUtil.compareTime(timeCyDate, timeQmDate, 24 * 60L)) {
+                    status.set("0");
+                }
             }
         }
     }
-
 }

+ 26 - 25
kernel/src/main/java/com/lantone/qc/kernel/catalogue/operationdiscussion/OPE0647.java

@@ -9,6 +9,7 @@ import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -22,35 +23,35 @@ import java.util.Map;
 public class OPE0647 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
-//        boolean isOperativePatient = true;//是手术患者(暂时默认是)
-//        if (isOperativePatient) {
-            List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
-        if(operationDocs == null || operationDocs.size() == 0){
+        //        boolean isOperativePatient = true;//是手术患者(暂时默认是)
+        //        if (isOperativePatient) {
+        List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
+        if (operationDocs == null || operationDocs.size() == 0) {
             status.set("0");
             return;
         }
-            if (operationDocs.size() == 0) {
-                return;
+        for (OperationDoc operationDoc : operationDocs) {
+            OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
+            if (operationRecordDoc == null) {
+                continue;
+            }
+            Map<String, String> operationRecordStructureMap = operationRecordDoc.getStructureMap();
+            String operationEndDateStr = operationRecordStructureMap.get("手术结束时间");
+            String operationRecordDateStr = operationRecordStructureMap.get("记录时间");
+            if (CatalogueUtil.isEmpty(operationEndDateStr) || CatalogueUtil.isEmpty(operationRecordDateStr)) {
+                continue;
             }
-            for (OperationDoc operationDoc : operationDocs) {
-                OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
-                if (operationRecordDoc == null) {
-                    continue;
-                }
-                Map<String, String> operationRecordStructureMap = operationRecordDoc.getStructureMap();
-                String operationEndDateStr = operationRecordStructureMap.get("手术结束时间");
-                String operationRecordDateStr = operationRecordStructureMap.get("记录时间");
-                if (CatalogueUtil.isEmpty(operationEndDateStr) || CatalogueUtil.isEmpty(operationRecordDateStr)) {
-                    continue;
-                }
-                boolean compareTime = CatalogueUtil.compareTime(StringUtil.parseDateTime(operationEndDateStr),
-                        StringUtil.parseDateTime(operationRecordDateStr),
-                        (long) (24 * 60));
-                if (compareTime) {
-                    status.set("-1");
-                    return;
-                }
+            Date operationEndDate = StringUtil.parseDateTime(operationEndDateStr);
+            Date operationRecordDate = StringUtil.parseDateTime(operationRecordDateStr);
+            if (operationEndDate == null || operationRecordDate == null) {
+                continue;
             }
-//        }
+            boolean compareTime = CatalogueUtil.compareTime(operationEndDate, operationRecordDate, 24 * 60L);
+            if (compareTime) {
+                status.set("-1");
+                return;
+            }
+        }
+        //        }
     }
 }

+ 6 - 5
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0094.java

@@ -28,7 +28,7 @@ public class THR0094 extends QCCatalogue {
         }
 
         String sign = inputInfo.getFirstCourseRecordDoc().getStructureMap().get("记录医师");
-        sign = (null==sign)?"":sign.trim();
+        sign = (null == sign) ? "" : sign.trim();
 
         RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
         Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
@@ -36,10 +36,11 @@ public class THR0094 extends QCCatalogue {
             return;
         }
         Map<String, String> doctor = (Map) surgeon.get(sign);
-        String occup = doctor.get("occup");
-        if (StringUtils.isNotEmpty(occup) && "1".equals(occup)) {
-            status.set("0");
-            return;
+        if (doctor != null) {
+            String occup = doctor.get("occup");
+            if (StringUtils.isNotEmpty(occup) && "1".equals(occup)) {
+                status.set("0");
+            }
         }
     }
 }

+ 4 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0595.java

@@ -28,9 +28,9 @@ public class THR0595 extends QCCatalogue {
             return;
         }
         //所有查房记录的日期天
-        List<Integer> dateRecordDay = new ArrayList<>();
+        List<Date> dateRecordDay = new ArrayList<>();
         //危重患者应该有的查房记录的日期天
-        List<Integer> criticallyDay = new ArrayList<>();
+        List<Date> criticallyDay = new ArrayList<>();
         Date criticallyStartDate = null, criticallyEndDate = null;
         String recordTime = "", content = "";
         List<ThreeLevelWardDoc> allDoctorWradDocs = inputInfo.getThreeLevelWardDocs().get(0).getAllDoctorWradDocs();//查房记录
@@ -47,7 +47,7 @@ public class THR0595 extends QCCatalogue {
             } else if (content.contains("病情稳定") || content.contains("病情好转")) {
                 criticallyEndDate = recordDate;
             }
-            dateRecordDay.add(DateUtil.getDay(recordDate));
+            dateRecordDay.add(DateUtil.dateZeroClear(recordDate));
         }
         if (criticallyStartDate == null || criticallyEndDate == null) {
             return;
@@ -55,7 +55,7 @@ public class THR0595 extends QCCatalogue {
         int daynum = DateUtil.getDay(criticallyEndDate) - DateUtil.getDay(criticallyStartDate);
         for (int i = 1; i <= daynum; i++) {
             if (i % 2 == 0) {
-                int wardDay = DateUtil.getDay(DateUtil.addDate(criticallyStartDate, i));
+                Date wardDay = DateUtil.dateZeroClear(DateUtil.addDate(criticallyStartDate, i));
                 criticallyDay.add(wardDay);
             }
         }

+ 4 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0596.java

@@ -28,9 +28,9 @@ public class THR0596 extends QCCatalogue {
             return;
         }
         //所有查房记录的日期天
-        List<Integer> dateRecordDay = new ArrayList<>();
+        List<Date> dateRecordDay = new ArrayList<>();
         //危重患者应该有的查房记录的日期天
-        List<Integer> criticallyDay = new ArrayList<>();
+        List<Date> criticallyDay = new ArrayList<>();
         Date criticallyStartDate = null, criticallyEndDate = null;
         String recordTime = "", content = "";
         List<ThreeLevelWardDoc> allDoctorWradDocs = inputInfo.getThreeLevelWardDocs().get(0).getAllDoctorWradDocs();//查房记录
@@ -47,14 +47,14 @@ public class THR0596 extends QCCatalogue {
             } else if (content.contains("病情稳定") || content.contains("病情好转")) {
                 criticallyEndDate = recordDate;
             }
-            dateRecordDay.add(DateUtil.getDay(recordDate));
+            dateRecordDay.add(DateUtil.dateZeroClear(recordDate));
         }
         if (criticallyStartDate == null || criticallyEndDate == null) {
             return;
         }
         int daynum = DateUtil.getDay(criticallyEndDate) - DateUtil.getDay(criticallyStartDate);
         for (int i = 1; i <= daynum; i++) {
-            int wardDay = DateUtil.getDay(DateUtil.addDate(criticallyStartDate, i));
+            Date wardDay = DateUtil.dateZeroClear(DateUtil.addDate(criticallyStartDate, i));
             criticallyDay.add(wardDay);
         }
         if (!dateRecordDay.containsAll(criticallyDay)) {

+ 8 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0700.java

@@ -1,8 +1,6 @@
 package com.lantone.qc.kernel.catalogue.threelevelward;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.CatalogueUtil;
-import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
@@ -29,11 +27,17 @@ public class THR0700 extends QCCatalogue {
             }
             ThreeLevelWardDoc lastWardDoc = allDoctorWradDocs.get(allDoctorWradDocs.size() - 1);
             Map<String, String> structureMap = lastWardDoc.getStructureMap();
+            String recordTitle = structureMap.get("查房标题");
             String conditionRecord = structureMap.get("病情记录");
-            if (StringUtil.isBlank(conditionRecord)) {
+            if (StringUtil.isBlank(recordTitle) || StringUtil.isBlank(conditionRecord)) {
+                status.set("0");
                 return;
             }
-            if (conditionRecord.contains("上级医师")) {
+            if (recordTitle.contains("主治")
+                    || recordTitle.contains("主任")
+                    || recordTitle.contains("主刀")) {
+                status.set("0");
+            } else if (conditionRecord.contains("上级医师")) {
                 status.set("0");
             }
         }

+ 48 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0725.java

@@ -0,0 +1,48 @@
+package com.lantone.qc.kernel.catalogue.threelevelward;
+
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.RescueDoc;
+import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @ClassName : THR0725
+ * @Description : 抢救记录未在抢救开始后6小时内完成
+ * @Author : 胡敬
+ * @Date: 2020-04-29 11:42
+ */
+@Component
+public class THR0725 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        List<RescueDoc> rescueDocs = inputInfo.getRescueDocs();
+        if (ListUtil.isEmpty(rescueDocs)) {
+            return;
+        }
+        for (RescueDoc rescueDoc : rescueDocs) {
+            Map<String, String> rescueStructureMap = rescueDoc.getStructureMap();
+            String rescueTime = rescueStructureMap.get("抢救时间");
+            String recordTime = rescueStructureMap.get("记录日期");
+            if (StringUtil.isBlank(rescueTime) || StringUtil.isBlank(recordTime)) {
+                continue;
+            }
+            Date rescueTimeDate = StringUtil.parseDateTime(rescueTime);
+            Date recordTimeDate = StringUtil.parseDateTime(recordTime);
+            if (rescueTimeDate == null || recordTimeDate == null) {
+                continue;
+            }
+            if (CatalogueUtil.compareTime(rescueTimeDate, recordTimeDate, 6 * 60L)) {
+                status.set("-1");
+                return;
+            }
+        }
+    }
+}

+ 2 - 2
kernel/src/main/resources/application.yml

@@ -25,10 +25,10 @@ spring:
         max-idle: 8
 
 CRF:
-  url: http://192.168.2.234:3456/api/mr_info_ex/entity_predict
+  url: http://192.168.3.150:3456/api/mr_info_ex/entity_predict
 
 Similarity:
-  url: http://192.168.2.234:3456/api/mr_info_ex/similarity
+  url: http://192.168.3.150:3456/api/mr_info_ex/similarity
 
 
 logging:          # 日志

+ 1 - 1
public/src/main/java/com/lantone/qc/pub/model/InputInfo.java

@@ -35,7 +35,7 @@ public class InputInfo {
     //手术
     private List<OperationDoc> operationDocs = new ArrayList<>();
     //转科记录
-    private List<TransferRecordDoc> transferRecordDocs = new ArrayList<>();
+    private TransferRecordDoc transferRecordDocs;
     //入院记录
     private BeHospitalizedDoc beHospitalizedDoc;
     //输血/血制品病程记录

+ 11 - 3
public/src/main/java/com/lantone/qc/pub/model/doc/transferrecord/TransferRecordDoc.java

@@ -1,8 +1,12 @@
 package com.lantone.qc.pub.model.doc.transferrecord;
 
+import com.lantone.qc.pub.model.doc.ModelDoc;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @Description: 转科记录
  * @author: rengb
@@ -10,10 +14,14 @@ import lombok.Setter;
  */
 @Getter
 @Setter
-public class TransferRecordDoc {
+public class TransferRecordDoc extends ModelDoc {
 
     private String transferRecordName;
-    private TransferIntoDoc transferIntoDoc;
-    private TransferOutDoc transferOutDoc;
+    //所有转科记录
+    private List<TransferRecordDoc> allTransferDocs = new ArrayList<>();
+    //所有转入记录
+    private List<TransferIntoDoc> transferIntoDocs = new ArrayList<>();
+    //所有转出记录
+    private List<TransferOutDoc> transferOutDocs = new ArrayList<>();
 
 }

+ 4 - 4
trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java

@@ -29,10 +29,10 @@ public class ChangxDocTrans extends DocTrans {
                 ChangxOperationDocTrans operationDocTrans = new ChangxOperationDocTrans();
                 inputInfo.setOperationDocs(operationDocTrans.extract(i));
             }
-            //            if (i.getTitle().equals("转科记录")) {
-            //                ChangxTransferRecordDocTrans transferRecordDocTrans = new ChangxTransferRecordDocTrans();
-            //                inputInfo.setTransferRecordDocs(transferRecordDocTrans.extract(i));
-            //            }
+            if (i.getTitle().equals("转科")) {
+                ChangxTransferRecordDocTrans transferRecordDocTrans = new ChangxTransferRecordDocTrans();
+                inputInfo.setTransferRecordDocs(transferRecordDocTrans.extract(i));
+            }
             if (i.getTitle().equals("入院记录")) {
                 ChangxBeHospitalizedDocTrans beHospitalizedDocTrans = new ChangxBeHospitalizedDocTrans();
                 inputInfo.setBeHospitalizedDoc(beHospitalizedDocTrans.extract(i));

+ 133 - 94
trans/src/main/java/com/lantone/qc/trans/changx/ChangxTransferRecordDocTrans.java

@@ -2,7 +2,6 @@ package com.lantone.qc.trans.changx;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
@@ -10,12 +9,17 @@ import com.lantone.qc.pub.model.vo.MedrecVo;
 import com.lantone.qc.pub.util.ListUtil;
 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 java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.TreeMap;
 
 /**
  * @Description: 转科记录文档生成
@@ -25,30 +29,88 @@ import java.util.Set;
 public class ChangxTransferRecordDocTrans extends ModelDocTrans {
 
     @Override
-    public List<TransferRecordDoc> extract(MedrecVo medrecVo) {
-        List<TransferRecordDoc> retList = Lists.newArrayList();
+    public TransferRecordDoc extract(MedrecVo medrecVo) {
+        TransferRecordDoc transferRecordDoc = new TransferRecordDoc();
 
         Map<String, List<String>> contentMap = (Map) medrecVo.getContent().get("content");
         if (contentMap == null) {
-            return retList;
+            return transferRecordDoc;
         }
-
-        Map<String, TransferIntoDoc> transferIntoDocMap = getTransferIntoDocMap(contentMap.get("转入"));
-        Map<String, TransferOutDoc> transferOutDocMap = getTransferOutDocMap(contentMap.get("转出"));
-
-        Set<String> transferRecordNameSet = Sets.newHashSet();
-        transferRecordNameSet.addAll(transferIntoDocMap.keySet());
-        transferRecordNameSet.addAll(transferOutDocMap.keySet());
-
-        transferRecordNameSet.forEach(transferRecordName -> {
-            TransferRecordDoc transferRecordDoc = new TransferRecordDoc();
-            transferRecordDoc.setTransferRecordName(transferRecordName);
-            transferRecordDoc.setTransferIntoDoc(transferIntoDocMap.get(transferRecordName));
-            transferRecordDoc.setTransferOutDoc(transferOutDocMap.get(transferRecordName));
-            retList.add(transferRecordDoc);
+        List<String> into = contentMap.get("转入记录");
+        List<String> out = contentMap.get("转出记录");
+        List<String> all = new ArrayList<>();
+        all.addAll(into);
+        all.addAll(out);
+        Map<String, TransferIntoDoc> transferIntoDocMap = getTransferIntoDocMap(into);
+        Map<String, TransferOutDoc> transferOutDocMap = getTransferOutDocMap(out);
+        Map<String, TransferRecordDoc> transferAllDocMap = getTransferAllDocMap(all);
+
+        //转入
+        Map<Date, TransferIntoDoc> dateRecordIn = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 升序排列
+                return o1.compareTo(o2);
+            }
+        });
+        for (TransferIntoDoc transferIntoDoc : transferIntoDocMap.values()) {
+            Map<String, String> structureMap = transferIntoDoc.getStructureMap();
+            String inDateStr = structureMap.get("转科日期");
+            if (StringUtil.isBlank(inDateStr)) {
+                continue;
+            }
+            Date inDate = StringUtil.parseDateTime(inDateStr);
+            if (inDate == null) {
+                continue;
+            }
+            dateRecordIn.put(inDate, transferIntoDoc);
+        }
+        transferRecordDoc.setTransferIntoDocs(new ArrayList<>(dateRecordIn.values()));
+        //转出
+        Map<Date, TransferOutDoc> dateRecordOut = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 升序排列
+                return o1.compareTo(o2);
+            }
+        });
+        for (TransferOutDoc transferOutDoc : transferOutDocMap.values()) {
+            Map<String, String> structureMap = transferOutDoc.getStructureMap();
+            String outDateStr = structureMap.get("转科日期");
+            if (StringUtil.isBlank(outDateStr)) {
+                continue;
+            }
+            Date outDate = StringUtil.parseDateTime(outDateStr);
+            if (outDate == null) {
+                continue;
+            }
+            dateRecordOut.put(outDate, transferOutDoc);
+        }
+        transferRecordDoc.setTransferOutDocs(new ArrayList<>(dateRecordOut.values()));
+
+        //全部转科记录
+        Map<Date, TransferRecordDoc> dateRecordAll = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 升序排列
+                return o1.compareTo(o2);
+            }
         });
+        for (TransferRecordDoc transferRecordAllDoc : transferAllDocMap.values()) {
+            Map<String, String> structureMap = transferRecordAllDoc.getStructureMap();
+            String transferDateStr = structureMap.get("转科日期");
+            if (StringUtil.isBlank(transferDateStr)) {
+                continue;
+            }
+            Date transferDate = StringUtil.parseDateTime(transferDateStr);
+            if (transferDate == null) {
+                continue;
+            }
+            dateRecordAll.put(transferDate, transferRecordAllDoc);
+        }
+        transferRecordDoc.setAllTransferDocs(new ArrayList<>(dateRecordAll.values()));
 
-        return retList;
+        return transferRecordDoc;
     }
 
 
@@ -74,49 +136,48 @@ public class ChangxTransferRecordDocTrans extends ModelDocTrans {
     }
 
     private TransferIntoDoc getTransferIntoDoc(String content) {
-        Map<String, String> pageData = Preproc.extract_doc_pub(true, transferInto_pageDataTitles, content);
-        pageData.put("病程记录内容",
-                pageData.get("病程记录内容")
-                        .replace(pageData.get("病程记录时间"), "")
-                        .replace(pageData.get("病程记录名称"), "")
-        );
-
-        List<String> targetTitles = Lists.newArrayList();
-        transferInto_sourceTitles.forEach(sourceTitle -> {
-            String targetTitle = "";
-            for (int index = 0; index < sourceTitle.length(); index++) {
-                if (index == sourceTitle.length() - 1) {
-                    targetTitle += sourceTitle.substring(index, index + 1);
-                } else {
-                    targetTitle += sourceTitle.substring(index, index + 1) + "[\\s\\p{Zs}]*";
-                }
-            }
-            targetTitles.add(targetTitle);
-        });
+        Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
 
-        Map<String, String> sourceMap = Preproc.extract_doc_pub(true, targetTitles, content);
-        sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
-
-        TransferIntoDoc transferIntoDoc = ModelDocGenerate.transferIntoDocGen(sourceMap);
+//        sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
+        TransferIntoDoc transferIntoDoc = new TransferIntoDoc();
         transferIntoDoc.setText(content);
-        transferIntoDoc.setPageData((Map) pageData);
+        transferIntoDoc.setStructureMap(structureMap);
+        transferIntoDoc.setPageData((Map)xmlNodeValueMap);
 
         return transferIntoDoc;
     }
 
-    private List<String> transferInto_pageDataTitles = Lists.newArrayList(
-            "病程记录时间",
-            "病程记录名称",
-            "病程记录内容",
-            "记录医师"
-    );
-    private List<String> transferInto_sourceTitles = Lists.newArrayList(
-            "病程记录时间",
-            "病程记录名称",
-            "病程记录内容",
-            "记录时间",
-            "记录医师"
-    );
+    /**************************************************全部*******************************************************/
+    private Map<String, TransferRecordDoc> getTransferAllDocMap(List<String> contents) {
+        Map<String, TransferRecordDoc> retMap = Maps.newHashMap();
+        if (ListUtil.isEmpty(contents)) {
+            return retMap;
+        }
+        int index = 1;
+        String transferRecordName = null;
+        for (String content : contents) {
+            if (StringUtil.isBlank(content)) {
+                continue;
+            }
+            transferRecordName = index + "";
+            TransferRecordDoc transferRecordDoc = getTransferAllDoc(content);
+            transferRecordDoc.setTransferRecordName(transferRecordName);
+            retMap.put(transferRecordName, transferRecordDoc);
+            index++;
+        }
+        return retMap;
+    }
+
+    private TransferRecordDoc getTransferAllDoc(String content) {
+        Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
+        TransferRecordDoc transferAllDoc = new TransferRecordDoc();
+        transferAllDoc.setText(content);
+        transferAllDoc.setStructureMap(structureMap);
+        transferAllDoc.setPageData((Map) xmlNodeValueMap);
+        return transferAllDoc;
+    }
 
 
     /**************************************************转出*******************************************************/
@@ -141,48 +202,26 @@ public class ChangxTransferRecordDocTrans extends ModelDocTrans {
     }
 
     private TransferOutDoc getTransferOutDoc(String content) {
-        Map<String, String> pageData = Preproc.extract_doc_pub(true, transferOut_pageDataTitles, content);
-        pageData.put("病程记录内容",
-                pageData.get("病程记录内容")
-                        .replace(pageData.get("病程记录时间"), "")
-                        .replace(pageData.get("病程记录名称"), "")
-        );
-
-        List<String> targetTitles = Lists.newArrayList();
-        transferOut_sourceTitles.forEach(sourceTitle -> {
-            String targetTitle = "";
-            for (int index = 0; index < sourceTitle.length(); index++) {
-                if (index == sourceTitle.length() - 1) {
-                    targetTitle += sourceTitle.substring(index, index + 1);
-                } else {
-                    targetTitle += sourceTitle.substring(index, index + 1) + "[\\s\\p{Zs}]*";
-                }
-            }
-            targetTitles.add(targetTitle);
-        });
+        Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue("//DocObjContent//Region", content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
 
-        Map<String, String> sourceMap = Preproc.extract_doc_pub(true, targetTitles, content);
-        sourceMap.put("记录时间", sourceMap.get("病程记录时间"));
-
-        TransferOutDoc transferOutDoc = ModelDocGenerate.transferOutDocGen(sourceMap);
+        TransferOutDoc transferOutDoc = new TransferOutDoc();
         transferOutDoc.setText(content);
-        transferOutDoc.setPageData((Map) pageData);
+        transferOutDoc.setStructureMap(structureMap);
+        transferOutDoc.setPageData((Map) xmlNodeValueMap);
 
         return transferOutDoc;
     }
 
-    private List<String> transferOut_pageDataTitles = Lists.newArrayList(
-            "病程记录时间",
-            "病程记录名称",
-            "病程记录内容",
-            "记录医师"
-    );
-    private List<String> transferOut_sourceTitles = Lists.newArrayList(
-            "病程记录时间",
-            "病程记录名称",
-            "病程记录内容",
-            "记录时间",
-            "记录医师"
+    private List<String> keyContrasts = Lists.newArrayList(
+            "转出日期=转科日期",
+            "转入日期=转科日期",
+            "转出日期=转科日期",
+            "姓名++++患者姓名=姓名",
+            "签名++++=医师签名",
+            "++++入院日期=入院日期",
+            "入院诊断++++初步诊断=初步诊断",
+            "转入目的++++目的=转入目的",
+            "转出目的++++目的=转出目的"
     );
-
 }

+ 1 - 24
trans/src/main/java/com/lantone/qc/trans/comsis/ModelDocGenerate.java

@@ -26,6 +26,7 @@ import com.lantone.qc.pub.model.doc.operation.OperationSafetyChecklistDoc;
 import com.lantone.qc.pub.model.doc.operation.PreoperativeDiscussionDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
+import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
 import com.lantone.qc.pub.model.label.CaseCharacteristicLabel;
 import com.lantone.qc.pub.model.label.ChiefLabel;
 import com.lantone.qc.pub.model.label.DiagLabel;
@@ -148,30 +149,6 @@ public class ModelDocGenerate {
         return operationSafetyChecklistDoc;
     }
 
-    /**
-     * 转科记录-转入
-     *
-     * @param structureMap
-     * @return
-     */
-    public static TransferIntoDoc transferIntoDocGen(Map<String, String> structureMap) {
-        TransferIntoDoc transferIntoDoc = new TransferIntoDoc();
-        transferIntoDoc.setStructureMap(structureMap);
-        return transferIntoDoc;
-    }
-
-    /**
-     * 转科记录-转出
-     *
-     * @param structureMap
-     * @return
-     */
-    public static TransferOutDoc transferOutDocGen(Map<String, String> structureMap) {
-        TransferOutDoc transferOutDoc = new TransferOutDoc();
-        transferOutDoc.setStructureMap(structureMap);
-        return transferOutDoc;
-    }
-
     /**
      * 入院记录
      *

+ 122 - 21
trans/src/main/java/com/lantone/qc/trans/taizhou/TaiZhouTransferRecordDocTrans.java

@@ -10,12 +10,18 @@ import com.lantone.qc.pub.model.vo.MedrecVo;
 import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
+import com.lantone.qc.trans.comsis.ModelDocGenerate;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
+import com.lantone.qc.trans.comsis.Preproc;
 import com.lantone.qc.trans.taizhou.util.TzXmlUtil;
 
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 
 /**
  * @Description: 转科记录文档生成
@@ -24,31 +30,88 @@ import java.util.Set;
  */
 public class TaiZhouTransferRecordDocTrans extends ModelDocTrans {
 
-    @Override
-    public List<TransferRecordDoc> extract(MedrecVo medrecVo) {
-        List<TransferRecordDoc> retList = Lists.newArrayList();
+    public TransferRecordDoc extract(MedrecVo medrecVo) {
+        TransferRecordDoc transferRecordDoc = new TransferRecordDoc();
 
         Map<String, List<String>> contentMap = (Map) medrecVo.getContent().get("content");
         if (contentMap == null) {
-            return retList;
+            return transferRecordDoc;
         }
-
-        Map<String, TransferIntoDoc> transferIntoDocMap = getTransferIntoDocMap(contentMap.get("转入"));
-        Map<String, TransferOutDoc> transferOutDocMap = getTransferOutDocMap(contentMap.get("转出"));
-
-        Set<String> transferRecordNameSet = Sets.newHashSet();
-        transferRecordNameSet.addAll(transferIntoDocMap.keySet());
-        transferRecordNameSet.addAll(transferOutDocMap.keySet());
-
-        transferRecordNameSet.forEach(transferRecordName -> {
-            TransferRecordDoc transferRecordDoc = new TransferRecordDoc();
-            transferRecordDoc.setTransferRecordName(transferRecordName);
-            transferRecordDoc.setTransferIntoDoc(transferIntoDocMap.get(transferRecordName));
-            transferRecordDoc.setTransferOutDoc(transferOutDocMap.get(transferRecordName));
-            retList.add(transferRecordDoc);
+        List<String> into = contentMap.get("转入记录");
+        List<String> out = contentMap.get("转出记录");
+        List<String> all = new ArrayList<>();
+        all.addAll(into);
+        all.addAll(out);
+        Map<String, TransferIntoDoc> transferIntoDocMap = getTransferIntoDocMap(into);
+        Map<String, TransferOutDoc> transferOutDocMap = getTransferOutDocMap(out);
+        Map<String, TransferRecordDoc> transferAllDocMap = getTransferAllDocMap(all);
+
+        //转入
+        Map<Date, TransferIntoDoc> dateRecordIn = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 升序排列
+                return o1.compareTo(o2);
+            }
+        });
+        for (TransferIntoDoc transferIntoDoc : transferIntoDocMap.values()) {
+            Map<String, String> structureMap = transferIntoDoc.getStructureMap();
+            String inDateStr = structureMap.get("转科日期");
+            if (StringUtil.isBlank(inDateStr)) {
+                continue;
+            }
+            Date inDate = StringUtil.parseDateTime(inDateStr);
+            if (inDate == null) {
+                continue;
+            }
+            dateRecordIn.put(inDate, transferIntoDoc);
+        }
+        transferRecordDoc.setTransferIntoDocs(new ArrayList<>(dateRecordIn.values()));
+        //转出
+        Map<Date, TransferOutDoc> dateRecordOut = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 升序排列
+                return o1.compareTo(o2);
+            }
         });
+        for (TransferOutDoc transferOutDoc : transferOutDocMap.values()) {
+            Map<String, String> structureMap = transferOutDoc.getStructureMap();
+            String outDateStr = structureMap.get("转科日期");
+            if (StringUtil.isBlank(outDateStr)) {
+                continue;
+            }
+            Date outDate = StringUtil.parseDateTime(outDateStr);
+            if (outDate == null) {
+                continue;
+            }
+            dateRecordOut.put(outDate, transferOutDoc);
+        }
+        transferRecordDoc.setTransferOutDocs(new ArrayList<>(dateRecordOut.values()));
+
+        //全部转科记录
+        Map<Date, TransferRecordDoc> dateRecordAll = new TreeMap<>(new Comparator<Date>() {
+            @Override
+            public int compare(Date o1, Date o2) {
+                // 升序排列
+                return o1.compareTo(o2);
+            }
+        });
+        for (TransferRecordDoc transferRecordAllDoc : transferAllDocMap.values()) {
+            Map<String, String> structureMap = transferRecordAllDoc.getStructureMap();
+            String transferDateStr = structureMap.get("转科日期");
+            if (StringUtil.isBlank(transferDateStr)) {
+                continue;
+            }
+            Date transferDate = StringUtil.parseDateTime(transferDateStr);
+            if (transferDate == null) {
+                continue;
+            }
+            dateRecordAll.put(transferDate, transferRecordAllDoc);
+        }
+        transferRecordDoc.setAllTransferDocs(new ArrayList<>(dateRecordAll.values()));
 
-        return retList;
+        return transferRecordDoc;
     }
 
 
@@ -74,16 +137,48 @@ public class TaiZhouTransferRecordDocTrans extends ModelDocTrans {
     }
 
     private TransferIntoDoc getTransferIntoDoc(String content) {
+        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
         Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(TzXmlUtil.getXmlToMapForTZ(content), transferInto_keyContrasts);
 
         TransferIntoDoc transferIntoDoc = new TransferIntoDoc();
+        transferIntoDoc.setText(content);
         transferIntoDoc.setStructureMap(structureMap);
-
+        transferIntoDoc.setPageData((Map)sourceMap);
         return transferIntoDoc;
     }
 
     private List<String> transferInto_keyContrasts = Lists.newArrayList();
 
+    /**************************************************全部*******************************************************/
+    private Map<String, TransferRecordDoc> getTransferAllDocMap(List<String> contents) {
+        Map<String, TransferRecordDoc> retMap = Maps.newHashMap();
+        if (ListUtil.isEmpty(contents)) {
+            return retMap;
+        }
+        int index = 1;
+        String transferRecordName = null;
+        for (String content : contents) {
+            if (StringUtil.isBlank(content)) {
+                continue;
+            }
+            transferRecordName = index + "";
+            TransferRecordDoc transferRecordDoc = getTransferAllDoc(content);
+            transferRecordDoc.setTransferRecordName(transferRecordName);
+            retMap.put(transferRecordName, transferRecordDoc);
+            index++;
+        }
+        return retMap;
+    }
+
+    private TransferRecordDoc getTransferAllDoc(String content) {
+        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
+        Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(TzXmlUtil.getXmlToMapForTZ(content), transferInto_keyContrasts);
+        TransferRecordDoc transferAllDoc = new TransferRecordDoc();
+        transferAllDoc.setText(content);
+        transferAllDoc.setStructureMap(structureMap);
+        transferAllDoc.setPageData((Map)sourceMap);
+        return transferAllDoc;
+    }
 
     /**************************************************转出*******************************************************/
     private Map<String, TransferOutDoc> getTransferOutDocMap(List<String> contents) {
@@ -107,14 +202,20 @@ public class TaiZhouTransferRecordDocTrans extends ModelDocTrans {
     }
 
     private TransferOutDoc getTransferOutDoc(String content) {
+        Map<String, String> sourceMap = TzXmlUtil.getXmlToMapForTZ(content);
         Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(TzXmlUtil.getXmlToMapForTZ(content), transferOut_keyContrasts);
 
         TransferOutDoc transferOutDoc = new TransferOutDoc();
+        transferOutDoc.setText(content);
         transferOutDoc.setStructureMap(structureMap);
+        transferOutDoc.setPageData((Map)sourceMap);
 
         return transferOutDoc;
     }
 
-    private List<String> transferOut_keyContrasts = Lists.newArrayList();
+    private List<String> transferOut_keyContrasts = Lists.newArrayList(
+            "书写日期=记录日期",
+            "本人姓名=姓名"
+    );
 
 }

+ 2 - 2
trans/src/main/java/com/lantone/qc/trans/taizhou/TaizhouDocTrans.java

@@ -34,9 +34,9 @@ public class TaizhouDocTrans extends DocTrans {
                     TaiZhouOperationDocTrans operationDocTrans = new TaiZhouOperationDocTrans();
                     inputInfo.setOperationDocs(operationDocTrans.extract(i));
                     break;
-                case "转科记录":
+                case "转科":
                     TaiZhouTransferRecordDocTrans transferRecordDocTrans = new TaiZhouTransferRecordDocTrans();
-                    /*inputInfo.setTransferRecordDocs(transferRecordDocTrans.extract(i));*/
+                    inputInfo.setTransferRecordDocs(transferRecordDocTrans.extract(i));
                     break;
                 case "入院记录":
                     TaiZhouBeHospitalizedDocTrans beHospitalizedDocTrans = new TaiZhouBeHospitalizedDocTrans();