Jelajahi Sumber

北仑:转入转出逻辑更改

wangsy 4 tahun lalu
induk
melakukan
3fbe968a10

+ 35 - 13
kernel/src/main/java/com/lantone/qc/kernel/catalogue/beilun/dutyshiftsystem/DUT0597.java

@@ -1,5 +1,6 @@
 package com.lantone.qc.kernel.catalogue.beilun.dutyshiftsystem;
 
+import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
@@ -7,11 +8,13 @@ import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferOutDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
 import com.lantone.qc.pub.util.StringUtil;
+import org.apache.commons.lang3.time.DateUtils;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @ClassName : DUT0597
@@ -27,27 +30,46 @@ public class DUT0597 extends QCCatalogue {
         if (transferRecordDoc == null) {
             return;
         }
-        String rollOutRecordDateStr = "", recordDateStr = "";
+        String rollOutRecordDateStr = "", recordDateStr = "", removeDate = "";
         List<TransferOutDoc> transferOutDocs = transferRecordDoc.getTransferOutDocs();
-        if (inputInfo.getMedicalRecordInfoDoc() != null) {
-            Map<String, String> medicalRecordInfoStructureMap = inputInfo.getMedicalRecordInfoDoc().getStructureMap();
-            //转入时间
-            rollOutRecordDateStr = medicalRecordInfoStructureMap.get("transOutTime");
-            for (TransferOutDoc transferOutDoc : transferOutDocs) {
-                Map<String, String> transferOutStructureMap = transferOutDoc.getStructureMap();
-//                rollOutRecordDateStr = transferOutStructureMap.get("转科日期");
-                recordDateStr = transferOutStructureMap.get("病历日期");
-                if (CatalogueUtil.isEmpty(rollOutRecordDateStr) || CatalogueUtil.isEmpty(recordDateStr)) {
+        if (transferOutDocs == null || transferOutDocs.get(0).getStructureMap() == null) {
+            return;
+        }
+        //转入时间
+        rollOutRecordDateStr = transferOutDocs.get(0).getStructureMap().get("转出时间");
+        if (StringUtil.isBlank(rollOutRecordDateStr)) {
+            return;
+        }
+        String[] split = rollOutRecordDateStr.replace("[", "").replace("]", "").trim().split(",");
+//        List<String> dateLists = Arrays.asList(split);
+        List<String> dateLists = Lists.newArrayList();
+        for (String date : split) {
+            dateLists.add(date);
+        }
+        dateLists = dateLists.stream().sorted().collect(Collectors.toList());
+        for (TransferOutDoc transferOutDoc : transferOutDocs) {
+            Boolean isRemove = false;
+            Map<String, String> transferOutStructureMap = transferOutDoc.getStructureMap();
+            recordDateStr = transferOutStructureMap.get("病历日期");
+            for (String date : dateLists) {
+                if (CatalogueUtil.isEmpty(date) || CatalogueUtil.isEmpty(recordDateStr)) {
                     continue;
                 }
-                Date rollOutRecordDate = StringUtil.parseDateTime(rollOutRecordDateStr);
+                Date rollOutRecordDate = StringUtil.parseDateTime(date);
                 Date recordDate = StringUtil.parseDateTime(recordDateStr);
-                if (rollOutRecordDate != null && recordDate != null && rollOutRecordDate.before(recordDate)) {
+                if (rollOutRecordDate == null || recordDate == null || rollOutRecordDate.after(recordDate)
+                        || DateUtils.isSameDay(rollOutRecordDate, recordDate)) {
+                    isRemove = true;
+                    removeDate = date;
+                    break;
+                } else {
                     status.set("-1");
                     return;
                 }
             }
+            if (isRemove) {
+                dateLists.remove(removeDate);
+            }
         }
-
     }
 }

+ 53 - 19
kernel/src/main/java/com/lantone/qc/kernel/catalogue/beilun/dutyshiftsystem/DUT0598.java

@@ -1,5 +1,6 @@
 package com.lantone.qc.kernel.catalogue.beilun.dutyshiftsystem;
 
+import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.pub.model.InputInfo;
@@ -8,11 +9,14 @@ import com.lantone.qc.pub.model.doc.transferrecord.TransferIntoDoc;
 import com.lantone.qc.pub.model.doc.transferrecord.TransferRecordDoc;
 import com.lantone.qc.pub.util.StringUtil;
 import org.apache.commons.lang3.time.DateUtils;
+import org.jsoup.helper.DataUtil;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @ClassName : DUT0598
@@ -29,30 +33,60 @@ public class DUT0598 extends QCCatalogue {
             return;
         }
         List<TransferIntoDoc> transferIntoDocs = transferRecordDoc.getTransferIntoDocs();
-        String rollInRecordDateStr = "", recordDateStr = "";
-        if (inputInfo.getMedicalRecordInfoDoc() != null) {
-            Map<String, String> medicalRecordInfoStructureMap = inputInfo.getMedicalRecordInfoDoc().getStructureMap();
-            //转入时间
-            rollInRecordDateStr = medicalRecordInfoStructureMap.get("transInTime");
-
-            for (TransferIntoDoc transferIntoDoc : transferIntoDocs) {
-                Map<String, String> transferOutStructureMap = transferIntoDoc.getStructureMap();
-//                rollInRecordDateStr = transferOutStructureMap.get("转科日期");
-                recordDateStr = transferOutStructureMap.get("病历日期");
-                if (CatalogueUtil.isEmpty(rollInRecordDateStr) || CatalogueUtil.isEmpty(recordDateStr)) {
+        String rollInRecordDateStr = "", recordDateStr = "", removeDate = "";
+        Date rollOutRecordDate = null, recordDate = null;
+        if (transferIntoDocs == null || transferIntoDocs.get(0).getStructureMap() == null) {
+            return;
+        }
+        //转入时间
+        rollInRecordDateStr = transferIntoDocs.get(0).getStructureMap().get("转入时间");
+        if (StringUtil.isBlank(rollInRecordDateStr)) {
+            return;
+        }
+        String[] split = rollInRecordDateStr.replace("[", "").replace("]", "").trim().split(",");
+//        List<String> dateLists = Arrays.asList(split);
+        List<String> dateLists = Lists.newArrayList();
+        for (String date : split) {
+            dateLists.add(date);
+        }
+        dateLists = dateLists.stream().sorted().collect(Collectors.toList());
+        for (TransferIntoDoc transferIntoDoc : transferIntoDocs) {
+            Map<String, Date> maps = new HashMap<>();
+            Map<String, String> transferOutStructureMap = transferIntoDoc.getStructureMap();
+            recordDateStr = transferOutStructureMap.get("病历日期");
+            for (String date : dateLists) {
+                if (CatalogueUtil.isEmpty(date) || CatalogueUtil.isEmpty(recordDateStr)) {
                     continue;
                 }
-                Date rollOutRecordDate = StringUtil.parseDateTime(rollInRecordDateStr);
-                Date recordDate = StringUtil.parseDateTime(recordDateStr);
-                if (rollOutRecordDate != null && recordDate != null && rollOutRecordDate.before(recordDate)) {
-                    boolean compareTime = CatalogueUtil.compareTime(rollOutRecordDate, recordDate, (long) 24 * 60);
-                    DateUtils.isSameDay(rollOutRecordDate, recordDate);
-                    if (compareTime) {
-                        status.set("-1");
-                        return;
+                //转入日期
+                rollOutRecordDate = StringUtil.parseDateTime(date);
+                //记录日期
+                recordDate = StringUtil.parseDateTime(recordDateStr);
+                if (rollOutRecordDate != null && recordDate != null &&
+                        (rollOutRecordDate.before(recordDate) || DateUtils.isSameDay(rollOutRecordDate, recordDate))) {
+                    if (maps.size() == 0) {
+                        removeDate = date;
+                        maps.put("转入时间", rollOutRecordDate);
+                        maps.put("记录时间", recordDate);
+                    } else {
+                        if (recordDate.getTime() - rollOutRecordDate.getTime() < maps.get("记录时间").getTime() - maps.get("转入时间").getTime()) {
+                            removeDate = date;
+                            maps.put("转入时间", rollOutRecordDate);
+                        }
                     }
                 }
             }
+
+            if (maps.size() != 0) {
+                boolean compareTime = CatalogueUtil.compareTime(maps.get("转入时间"), maps.get("记录时间"), (long) 24 * 60);
+                boolean sameDay = DateUtils.isSameDay(maps.get("转入时间"), maps.get("记录时间"));
+                dateLists.remove(removeDate);
+                if (compareTime && !sameDay) {
+                    status.set("-1");
+                    return;
+                }
+            }
         }
     }
+
 }

+ 19 - 11
trans/src/main/java/com/lantone/qc/trans/beilun/BeiLunTransferRecordDocTrans.java

@@ -17,13 +17,7 @@ import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.MapUtils;
 
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.*;
 
 /**
  * @Description: 转科记录文档生成
@@ -155,7 +149,7 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
 
     private TransferIntoDoc getTransferIntoDoc(Map<String, Object> contentMap) {
         String content = contentMap.get("xmlText").toString();
-        Map<String, String> structureMap = null;
+        Map<String, String> structureMap = new HashMap<>();
         if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
             structureMap = (Map) FastJsonUtils.getJsonToMap(content);
         } else {
@@ -169,6 +163,8 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
                 structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
             }
         }
+        //存入转入时间
+        getTransDate(contentMap.get("transferInDate"), "转入时间", structureMap);
         if (MapUtils.isNotEmpty(structureMap)) {
             TransferIntoDoc transferIntoDoc = new TransferIntoDoc();
             transferIntoDoc.setStructureMap(structureMap);
@@ -179,7 +175,6 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
         }
     }
 
-
     /**************************************************全部*******************************************************/
     private Map<String, TransferRecordDoc> getTransferAllDocMap(List<Map<String, Object>> contentMaps) {
         Map<String, TransferRecordDoc> retMap = Maps.newHashMap();
@@ -209,7 +204,7 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
 
     private TransferRecordDoc getTransferAllDoc(Map<String, Object> contentMap) {
         String content = contentMap.get("xmlText").toString();
-        Map<String, String> structureMap = null;
+        Map<String, String> structureMap = new HashMap<>();
         if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
             structureMap = (Map) FastJsonUtils.getJsonToMap(content);
         } else {
@@ -223,6 +218,10 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
                 structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
             }
         }
+        //存入转入时间
+        getTransDate(contentMap.get("transferInDate"), "转入时间", structureMap);
+        //存入转出时间
+        getTransDate(contentMap.get("transferOutDate"), "转出时间", structureMap);
         if (MapUtils.isNotEmpty(structureMap)) {
             TransferRecordDoc transferAllDoc = new TransferRecordDoc();
             transferAllDoc.setStructureMap(structureMap);
@@ -263,7 +262,7 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
 
     private TransferOutDoc getTransferOutDoc(Map<String, Object> contentMap) {
         String content = contentMap.get("xmlText").toString();
-        Map<String, String> structureMap = null;
+        Map<String, String> structureMap = new HashMap<>();
         if (contentMap.get("isParsed") != null && "1".equals(contentMap.get("isParsed").toString())) {
             structureMap = (Map) FastJsonUtils.getJsonToMap(content);
         } else {
@@ -277,6 +276,8 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
                 structureMap.put("病历号", contentMap.get("behospitalCode") == null ? null : contentMap.get("behospitalCode").toString());
             }
         }
+        //存入转出时间
+        getTransDate(contentMap.get("transferOutDate"), "转出时间", structureMap);
         if (MapUtils.isNotEmpty(structureMap)) {
             TransferOutDoc transferOutDoc = new TransferOutDoc();
             transferOutDoc.setStructureMap(structureMap);
@@ -287,6 +288,13 @@ public class BeiLunTransferRecordDocTrans extends ModelDocTrans {
         }
     }
 
+    //存入转入转出时间
+    private void getTransDate(Object transferDates, String dateStr, Map<String, String> structureMap) {
+        if (transferDates != null) {
+            structureMap.put(dateStr, transferDates.toString());
+        }
+    }
+
     private List<String> keyContrasts = Lists.newArrayList(
             "医师签名=记录医生",
             "病历标题=标题",