Parcourir la source

Merge remote-tracking branch 'origin/dev-1.2' into dev

louhr il y a 5 ans
Parent
commit
6c6179cb61

+ 51 - 36
dbanaly/src/main/java/com/lantone/qc/dbanaly/facade/comsis/XmlDataAnalysisFacade.java

@@ -127,53 +127,24 @@ public class XmlDataAnalysisFacade {
                         .filter(i -> StringUtil.isNotBlank(behospitalCodeDeptInfoMap.get(i.getBehospitalCode())))
                         .collect(Collectors.toMap(MedicalRecord::getRecId, i -> i.getBehospitalCode()));
 
-        //根据文书记录id集合,分批次找出文书内容,有的文书记录可能没有对应文书内容,如果文书的xml是加密过的,还需要解密
-        List<MedicalRecordContent> medicalRecordContentList = Lists.newArrayList();
+        //根据文书记录id集合,分批次处理
+        List<Map.Entry<Set<String>, String>> keysBehospitalCodeEntryList = Lists.newArrayList();
         int index = 0;
-        medicalRecordQe.select("rec_id", "xml_text");
+        List<String> queryRecIds = null;
+        EncrypDES encrypDES = encryped ? new EncrypDES() : null;
         while (index <= recIds.size() - 1) {
-            QueryWrapper<MedicalRecordContent> medicalRecordContentQe = new QueryWrapper<>();
-            medicalRecordContentQe.eq("is_deleted", "N");
-            medicalRecordContentQe.eq("hospital_id", hospitalId);
             if (index + 1000 > recIds.size() - 1) {
-                medicalRecordContentQe.in("rec_id", recIds.subList(index, recIds.size()));
+                queryRecIds = recIds.subList(index, recIds.size());
             } else {
-                medicalRecordContentQe.in("rec_id", recIds.subList(index, index + 1000));
+                queryRecIds = recIds.subList(index, index + 1000);
             }
-            medicalRecordContentList.addAll(medicalRecordContentService.list(medicalRecordContentQe));
+            keysBehospitalCodeEntryList.addAll(getKeysBehospitalCodeEntryList(hospitalId, modelId, recTitle, sex, queryRecIds, recIdBehospitalCodeMap, encrypDES));
             if (index + 1000 > recIds.size() - 1) {
                 index = recIds.size();
             } else {
                 index = index + 1000;
             }
         }
-        if (ListUtil.isEmpty(medicalRecordContentList)) {
-            return;
-        }
-        if (encryped) {
-            EncrypDES encrypDES = new EncrypDES();
-            medicalRecordContentList.forEach(medicalRecordContent -> {
-                medicalRecordContent.setXmlText(encrypDES.decryptor(medicalRecordContent.getXmlText()));
-            });
-        }
-
-        //1、解析文书记录内容得出键值对,key是从文书的xml中提取的标签集合keys,value为对应的示例病历号;
-        //2、对键值对集合进行分组组装map,key为xml标签集合kesys,value为示例病历号集合;
-        List<Map.Entry<Set<String>, String>> keysBehospitalCodeEntryList = Lists.newArrayList();
-        String xmlText, behospitalCode;
-        for (MedicalRecordContent medicalRecordContent : medicalRecordContentList) {
-            xmlText = medicalRecordContent.getXmlText();
-            if (StringUtil.isBlank(xmlText)) {
-                continue;
-            }
-            behospitalCode = recIdBehospitalCodeMap.get(medicalRecordContent.getRecId());
-            keysBehospitalCodeEntryList.add(
-                    Maps.immutableEntry(
-                            getKeys(hospitalId, modelId, recTitle, sex, xmlText),
-                            behospitalCode
-                    )
-            );
-        }
         if (ListUtil.isEmpty(keysBehospitalCodeEntryList)) {
             return;
         }
@@ -303,6 +274,50 @@ public class XmlDataAnalysisFacade {
         }
     }
 
+    //根据文书记录id集合进行处理
+    private List<Map.Entry<Set<String>, String>> getKeysBehospitalCodeEntryList(long hospitalId, long modelId, String recTitle, String sex, List<String> recIds, Map<String, String> recIdBehospitalCodeMap, EncrypDES encrypDES) throws Exception {
+        List<Map.Entry<Set<String>, String>> ret = Lists.newArrayList();
+
+        //根据文书记录id集合,找出文书内容,有的文书记录可能没有对应文书内容,如果文书的xml是加密过的,还需要解密
+        QueryWrapper<MedicalRecordContent> medicalRecordContentQe = new QueryWrapper<>();
+        medicalRecordContentQe.eq("is_deleted", "N");
+        medicalRecordContentQe.eq("hospital_id", hospitalId);
+        medicalRecordContentQe.in("rec_id", recIds);
+        medicalRecordContentQe.select("rec_id", "xml_text");
+        List<MedicalRecordContent> medicalRecordContentList = medicalRecordContentService.list(medicalRecordContentQe);
+        if (ListUtil.isEmpty(medicalRecordContentList)) {
+            return ret;
+        }
+        if (encryped) {
+            medicalRecordContentList.forEach(medicalRecordContent -> {
+                medicalRecordContent.setXmlText(encrypDES.decryptor(medicalRecordContent.getXmlText()));
+            });
+        }
+
+        //1、解析文书记录内容得出键值对,key是从文书的xml中提取的标签集合keys,value为对应的示例病历号;
+        //2、对键值对集合进行分组组装map,key为xml标签集合kesys,value为示例病历号集合;
+        String xmlText, behospitalCode;
+        for (MedicalRecordContent medicalRecordContent : medicalRecordContentList) {
+            xmlText = medicalRecordContent.getXmlText();
+            if (StringUtil.isBlank(xmlText)) {
+                continue;
+            }
+            behospitalCode = recIdBehospitalCodeMap.get(medicalRecordContent.getRecId());
+            ret.add(
+                    Maps.immutableEntry(
+                            getKeys(hospitalId, modelId, recTitle, sex, xmlText),
+                            behospitalCode
+                    )
+            );
+        }
+
+        //释放内存
+        medicalRecordContentList.clear();
+        System.gc();
+
+        return ret;
+    }
+
     private Set<String> getKeys(long hospitalId, long modelId, String recTitle, String sex, String xml) throws Exception {
         Set<String> keys = new HashSet<>();
         if (hospitalId == 1) {

+ 10 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0454.java

@@ -3,11 +3,13 @@ package com.lantone.qc.kernel.catalogue.behospitalized;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.entity.Diag;
 import com.lantone.qc.pub.model.label.PastLabel;
 import com.lantone.qc.pub.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
 import java.util.Map;
 
 
@@ -39,5 +41,13 @@ public class BEH0454 extends QCCatalogue {
                 || pastLabel.getText().contains("详见原病历")) {
             status.set("0");
         }
+        //既往有任一阳性疾病名称,则认为有健康状况
+        List<Diag> diags = pastLabel.getDiags();
+        for (Diag diag : diags) {
+            if (diag.getNegative() == null) {
+                status.set("0");
+                return;
+            }
+        }
     }
 }