Kaynağa Gözat

Merge remote-tracking branch 'origin/hb/beilun' into hb/beilun

hecc 3 yıl önce
ebeveyn
işleme
5459857be6
26 değiştirilmiş dosya ile 803 ekleme ve 261 silme
  1. 4 4
      dbanaly/src/main/resources/application-test.yml
  2. 5 0
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/clinicalblood/CLI0304.java
  3. 2 1
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/clinicalblood/CLI03063.java
  4. 18 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC03230.java
  5. 18 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC03231.java
  6. 17 1
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC03232.java
  7. 101 9
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0190.java
  8. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0209.java
  9. 8 9
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/ningbozhenhai/clinicalblood/CLI0566.java
  10. 212 0
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/ningbozhenhai/crisisvaluereport/CRI0382.java
  11. 3 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/ningbozhenhai/firstpagerecord/FIRP0178.java
  12. 22 20
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03112.java
  13. 62 53
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03233.java
  14. 67 46
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03234.java
  15. 68 48
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03235.java
  16. 53 44
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03236.java
  17. 62 1
      kernel/src/main/java/com/lantone/qc/kernel/util/RegexUtil.java
  18. 1 1
      kernel/src/main/resources/bootstrap.yml
  19. 2 1
      kernel/src/main/resources/medicine.properties
  20. 13 0
      public/src/main/java/com/lantone/qc/pub/util/DateUtil.java
  21. 1 9
      public/src/main/resources/chinesemedicine.json
  22. 1 1
      public/src/main/resources/chinesemedicineyinpian.json
  23. 2 1
      trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/DeathRecordDocTrans.java
  24. 55 0
      trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/util/CommonAnalysisUtil.java
  25. 1 1
      trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/util/DeathRecordHtmlAnalysis.java
  26. 3 3
      trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/util/FirstCourseRecordHtmlAnalysis.java

+ 4 - 4
dbanaly/src/main/resources/application-test.yml

@@ -5,7 +5,7 @@ spring:
     druid:
       lantone:
         driver-class-name: com.mysql.jdbc.Driver
-        url: jdbc:mysql://192.168.2.237:3307/qc_wenfuyi_20220510?useUnicode=true&characterEncoding=utf8&useSSL=false
+        url: jdbc:mysql://192.168.2.237:3307/qc_wenfuyi?useUnicode=true&characterEncoding=utf8&useSSL=false
         username: root
         password: lantone
         initial-size: 8
@@ -28,9 +28,9 @@ spring:
     database:
       cache: 10 # cache索引
       token: 10 # Token索引
-    host: 192.168.2.126  #Redis服务器地址
-    port: 6379 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
-    password: lantone # Redis服务器连接密码(默认为空)
+    host: 192.168.2.237  #Redis服务器地址
+    port: 63791 # Redis服务器连接端口(本地环境端口6378,其他环境端口是6379)
+    password: emrais # Redis服务器连接密码(默认为空)
     lettuce:
       pool:
         max-active: 8 # 连接池最大连接数(使用负值表示没有限制)

+ 5 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/clinicalblood/CLI0304.java

@@ -136,6 +136,11 @@ public class CLI0304 extends QCCatalogue {
                 .filter(i -> StringUtil.isNotBlank(i.getStructureMap().get("医嘱项目名称"))
                         && (!i.getStructureMap().get("医嘱项目名称").contains("预约"))
                         && RegexUtil.getRegexRes(i.getStructureMap().get("医嘱项目名称"), regex5))
+                .filter(i -> StringUtil.isBlank(i.getStructureMap().get("医嘱处方类型"))
+                        ||(StringUtil.isNotBlank(i.getStructureMap().get("医嘱处方类型"))
+                        && !i.getStructureMap().get("医嘱处方类型").equals("化验")
+                        && !i.getStructureMap().get("医嘱处方类型").equals("检验")
+                        && !i.getStructureMap().get("医嘱处方类型").equals("检查")))
                 .collect(Collectors.toList());
         if (ListUtil.isNotEmpty(clinicalBloodDAList)) {
             if (ListUtil.isNotEmpty(filterDAList)) {

+ 2 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/clinicalblood/CLI03063.java

@@ -118,6 +118,7 @@ public class CLI03063 extends QCCatalogue {
         switch (Content.hospital_Id) {
             case "7":               //厦门
             case "20":
+            case "34":
             case "35":
             case "15":
                 return "病历日期";
@@ -125,4 +126,4 @@ public class CLI03063 extends QCCatalogue {
                 return "记录时间";
         }
     }
-}
+}

+ 18 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC03230.java

@@ -5,6 +5,7 @@ import com.lantone.qc.kernel.util.RegexUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
+import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
@@ -26,6 +27,7 @@ public class FIRC03230 extends QCCatalogue {
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
         if (firstCourseRecordDoc == null) {
             status.set("0");
             return;
@@ -35,13 +37,27 @@ public class FIRC03230 extends QCCatalogue {
         String diagnoseText = firstCourseRecordDoc.getStructureMap() != null
                 ? firstCourseRecordDoc.getStructureMap().get("诊断依据")
                 : "";
+        String diagText2 = firstCourseRecordDoc.getStructureMap() != null
+                ? firstCourseRecordDoc.getStructureMap().get("初步诊断")
+                : "";
+        String firstPageDiagText = firstPageRecordDoc == null ? ""
+                : (firstPageRecordDoc.getStructureMap() != null
+                ? firstPageRecordDoc.getStructureMap().get("中医门急诊诊断")
+                : "");
+
+        //先判断是否下了中医诊断,没有则通过 或 判断病案首页门急诊诊断是否下诊断,"-"为空,没有则通过
+        if ((StringUtil.isBlank(diagText2) || !diagText2.contains("中医诊断"))
+                && (StringUtil.isBlank(firstPageDiagText) || !RegexUtil.getRegexRes(firstPageDiagText, "[\\u4E00-\\u9FA5]+"))) {
+            status.set("0");
+            return;
+        }
 
         if (StringUtil.isBlank(text) && StringUtil.isBlank(diagnoseText)) {
             status.set("0");
             return;
         }
         String regex1 = "辨证|辨病|论治|中医辨病辨证依据";
-        String regex2 = "(中医辨病辨证依据|(辨[^。,;。,;]{0,5}证[^。,;。,;]{0,5}依据))[。,;:。,;:\\d]{0,}[\\u4E00-\\u9FA5A-Za-z]+";
+        String regex2 = "(中医辨病辨证依据|(辨[^。,;。,;]{0,5}证[^。,;。,;]{0,5}依据))[^。。;]{0,}[\\u4E00-\\u9FA5A-Za-z]+";
 
         if ((StringUtil.isNotBlank(text) && RegexUtil.getRegexRes(text, regex1))
                 || (StringUtil.isNotBlank(diagnoseText) && RegexUtil.getRegexRes(diagnoseText, regex2))) {
@@ -53,4 +69,4 @@ public class FIRC03230 extends QCCatalogue {
         }
 
     }
-}
+}

+ 18 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC03231.java

@@ -6,6 +6,7 @@ import com.lantone.qc.kernel.util.RegexUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
+import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
@@ -26,6 +27,7 @@ public class FIRC03231 extends QCCatalogue {
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
         if (firstCourseRecordDoc == null) {
             status.set("0");
             return;
@@ -35,13 +37,27 @@ public class FIRC03231 extends QCCatalogue {
         String diagText = firstCourseRecordDoc.getStructureMap() != null
                 ? firstCourseRecordDoc.getStructureMap().get("鉴别诊断")
                 : "";
+        String diagText2 = firstCourseRecordDoc.getStructureMap() != null
+                ? firstCourseRecordDoc.getStructureMap().get("初步诊断")
+                : "";
+        String firstPageDiagText = firstPageRecordDoc == null ? ""
+                : (firstPageRecordDoc.getStructureMap() != null
+                ? firstPageRecordDoc.getStructureMap().get("中医门急诊诊断")
+                : "");
+
+        //先判断是否下了中医诊断,没有则通过 或 判断病案首页门急诊诊断是否下诊断,"-"为空,没有则通过
+        if ((StringUtil.isBlank(diagText2) || !diagText2.contains("中医诊断"))
+                && (StringUtil.isBlank(firstPageDiagText) || !RegexUtil.getRegexRes(firstPageDiagText, "[\\u4E00-\\u9FA5]+"))) {
+            status.set("0");
+            return;
+        }
 
         if (StringUtil.isBlank(text) && StringUtil.isBlank(diagText)) {
             status.set("0");
             return;
         }
         String regex1 = "中医鉴别诊断|(中医[^。,;。,;]{0,5}鉴别)";
-        String regex2 = "(中医鉴别诊断|(中医[^。,;。,;]{0,5}鉴别))[。,;:。,;:\\d]{0,}[\\u4E00-\\u9FA5A-Za-z]+";
+        String regex2 = "(中医鉴别诊断|(中医[^。,;。,;]{0,5}鉴别))[^。。;]{0,}[\\u4E00-\\u9FA5A-Za-z]+";
 
         if ((StringUtil.isNotBlank(text) && RegexUtil.getRegexRes(text, regex1))
                 || (StringUtil.isNotBlank(diagText) && RegexUtil.getRegexRes(diagText, regex2))) {
@@ -53,4 +69,4 @@ public class FIRC03231 extends QCCatalogue {
         }
 
     }
-}
+}

+ 17 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC03232.java

@@ -6,6 +6,7 @@ import com.lantone.qc.kernel.util.RegexUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
+import com.lantone.qc.pub.model.doc.FirstPageRecordDoc;
 import com.lantone.qc.pub.model.label.CaseCharacteristicLabel;
 import com.lantone.qc.pub.model.label.DiagnosisLabel;
 import com.lantone.qc.pub.util.StringUtil;
@@ -30,6 +31,7 @@ public class FIRC03232 extends QCCatalogue {
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
         if (firstCourseRecordDoc == null) {
             status.set("0");
             return;
@@ -42,6 +44,20 @@ public class FIRC03232 extends QCCatalogue {
         String caseCharacteristicText = firstCourseRecordDoc.getStructureMap() != null
                 ? firstCourseRecordDoc.getStructureMap().get("病例特点")
                 : "";
+        String diagText2 = firstCourseRecordDoc.getStructureMap() != null
+                ? firstCourseRecordDoc.getStructureMap().get("初步诊断")
+                : "";
+        String firstPageDiagText = firstPageRecordDoc == null ? ""
+                : (firstPageRecordDoc.getStructureMap() != null
+                ? firstPageRecordDoc.getStructureMap().get("中医门急诊诊断")
+                : "");
+
+        //先判断是否下了中医诊断,没有则通过 或 判断病案首页门急诊诊断是否下诊断,"-"为空,没有则通过
+        if ((StringUtil.isBlank(diagText2) || !diagText2.contains("中医诊断"))
+                && (StringUtil.isBlank(firstPageDiagText) || !RegexUtil.getRegexRes(firstPageDiagText, "[\\u4E00-\\u9FA5]+"))) {
+            status.set("0");
+            return;
+        }
 
         //病历特点
         CaseCharacteristicLabel caseCharacteristicLabel = firstCourseRecordDoc.getCaseCharacteristicLabel();
@@ -73,4 +89,4 @@ public class FIRC03232 extends QCCatalogue {
         }
 
     }
-}
+}

+ 101 - 9
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0190.java

@@ -2,16 +2,20 @@ 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.kernel.util.RegexUtil;
 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.ClinicalBloodDoc;
+import com.lantone.qc.pub.model.doc.LisDoc;
+import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @ClassName : FIRP0190
@@ -22,18 +26,106 @@ import java.util.Map;
 @Component
 public class FIRP0190 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        /**
+         * 1.首先获取[病案首页]>>[RH/Rh血型/Rh],若文书不在或字段未填写,直接返回。
+         * 2.查看内容填写是否为(阴性/阳性/阴/阳/不详/未查/1/2/3/4).若为否则报错。
+         * 3.获取病历内存在【输血*记录】文书,或【病案首页>>血费】>0,填写(不详/未查/3/4/-),则报规则。
+         * 4.若病历内存在包含(血型鉴定/Rh血型鉴定/血型)化验检查报告单,找报告单内明细项[Rh血型/RhD血型/Rh(D)/Rh/Rh(D)血型/Rh(D)]结果值,和首页对比是否一致,
+         *   同义词需转换,如[阴性/阴/1/-/-/(-)/(-)]相同,[阳性/阳/2/+/+/(+)/(+)]相同,不一致则触发规则。若未获得血型化验结果,则返回(或内测时能提示未成功获取血型化验结果)
+         * 5.若病历内存在【输血*记录】时,"获取结构化数据的"输注种类、血型、数量"若是没有则获取【Rh/Rh(D)/Rh血型/Rh(D)血型/Rh(D)】",然后判断其含(阴性/阳性/阴/阳/(-)/(+))次数,以次数多的为准。
+         *   如果所有输血记录都没有rh记录(阴性/阳性/阴/阳/(-)/(+)),则不报错。若找到,跟首页[RH/Rh血型/Rh]对比是否一致,同义词需转换,如[阴性/阴/1/-/-/(-)/(-)]相同,[阳性/阳/2/+/+/(+)/(+)]相同,
+         *   不一致则触发规则,未找到或空不比较
+         */
         status.set("0");
-        if (inputInfo.getFirstPageRecordDoc() == null || inputInfo.getFirstPageRecordDoc().getStructureMap() == null
-                || inputInfo.getClinicalBloodDocs().size() == 0) {
+        if (inputInfo.getFirstPageRecordDoc() == null || inputInfo.getFirstPageRecordDoc().getStructureMap() == null) {
             return;
         }
         Map<String, String> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureMap();
         List<ClinicalBloodDoc> clinicalBloodDocList = inputInfo.getClinicalBloodDocs();
+        List<LisDoc> lisDocs = inputInfo.getLisDocs();
         String rhFactor = firstpageStructureMap.get(Content.rhFactor);
         if (CatalogueUtil.isEmpty(rhFactor)) {
             return;
         }
-        int matchSum = 0, noRhSum = 0;
+
+        String regex = "阴性|阳性|阴|阳|不详|未查|1|2|3|4";
+        String regexNegative = "阴性|阴|1|\\-|\\-|\\(\\-\\)|(\\-)";
+        String regexPositive = "阳性|阳|2|\\+|\\+|\\(\\+\\)|(\\+)";
+        String regexLis = "血型鉴定|Rh血型鉴定|血型";
+        String regexLisDetail = "Rh血型|RhD血型|Rh(D)|Rh|Rh\\(D\\)血型|Rh\\(D\\)";
+        String regexResult = "阴性|阳性|阴|阳|\\(\\-\\)|\\(\\+\\)|(\\-)|(\\+)";
+
+        if (!RegexUtil.getRegexRes(rhFactor, regex)) {
+            status.set("-1");
+            return;
+        }
+
+        //获取病历内存在【输血*记录】文书,【病案首页>>血费】>0,填写(不详/未查/3/4/-),则报规则。
+        String regex1 = "不详|未查|3|4|-";
+        if (ListUtil.isEmpty(clinicalBloodDocList)
+                || (firstpageStructureMap.containsKey("血费")
+                && BigDecimal.valueOf(Double.valueOf(firstpageStructureMap.get("血费"))).compareTo(BigDecimal.ZERO) == 1)) {
+            if (RegexUtil.getRegexRes(rhFactor, regex1)) {
+                status.set("-1");
+                return;
+            }
+        }
+
+        if (ListUtil.isNotEmpty(lisDocs)) {
+
+
+            List<LisDoc> filterLisDocs = lisDocs.stream()
+                    .filter(i -> RegexUtil.getRegexRes(i.getStructureMap().get("报告名称"), regexLis))
+                    .filter(i -> RegexUtil.getRegexRes(i.getStructureMap().get("报告名称"), regexLisDetail))
+                    .collect(Collectors.toList());
+
+            for (LisDoc lisDoc : filterLisDocs) {
+                String lisResult = lisDoc.getStructureMap().get("检验结果");
+                if (CatalogueUtil.isEmpty(lisResult)) {
+                    continue;
+                }
+                if ((RegexUtil.getRegexRes(rhFactor, regexNegative) && RegexUtil.getRegexRes(lisResult, regexNegative))
+                        || (RegexUtil.getRegexRes(rhFactor, regexPositive) && RegexUtil.getRegexRes(lisResult, regexPositive))) {
+                    continue;
+                } else {
+                    status.set("-1");
+                    return;
+                }
+            }
+        }
+
+        for (ClinicalBloodDoc clinicalBloodDoc : clinicalBloodDocList) {
+            String bloodType = clinicalBloodDoc.getStructureMap().get("输注种类、血型、数量");
+            if (StringUtil.isBlank(bloodType)) {
+                // 台州无“输注种类、血型、数量”,匹配“Rh血型”
+                bloodType = (clinicalBloodDoc.getStructureMap().containsKey("Rh") ? clinicalBloodDoc.getStructureMap().get("Rh") : "")
+                        + (clinicalBloodDoc.getStructureMap().containsKey("Rh(D)") ? clinicalBloodDoc.getStructureMap().get("Rh(D)") : "")
+                        + (clinicalBloodDoc.getStructureMap().containsKey("Rh(D)") ? clinicalBloodDoc.getStructureMap().get("Rh(D)") : "")
+                        + (clinicalBloodDoc.getStructureMap().containsKey("Rh血型") ? clinicalBloodDoc.getStructureMap().get("Rh血型") : "")
+                        + (clinicalBloodDoc.getStructureMap().containsKey("Rh(D)血型") ? clinicalBloodDoc.getStructureMap().get("Rh(D)血型") : "")
+                        + (clinicalBloodDoc.getStructureMap().containsKey("Rh(D)血型") ? clinicalBloodDoc.getStructureMap().get("Rh(D)血型") : "");
+            }
+            if (CatalogueUtil.isEmpty(bloodType)) {
+                continue;
+            }
+
+            List<String> matchStrs = RegexUtil.getRegexRes(bloodType, regexResult, true);
+            if (ListUtil.isEmpty(matchStrs)) {
+                return;
+            }
+
+            for (String matchStr : matchStrs) {
+                if ((RegexUtil.getRegexRes(rhFactor, regexNegative) && RegexUtil.getRegexRes(rhFactor, regexNegative))
+                        || (RegexUtil.getRegexRes(rhFactor, regexPositive) && RegexUtil.getRegexRes(rhFactor, regexPositive))) {
+                    continue;
+                } else {
+                    status.set("-1");
+                    return;
+                }
+            }
+        }
+
+        /*int matchSum = 0, noRhSum = 0;
         for (ClinicalBloodDoc clinicalBloodDoc : clinicalBloodDocList) {
             String bloodType = clinicalBloodDoc.getStructureMap().get("输注种类、血型、数量");
             if (StringUtil.isBlank(bloodType)) {
@@ -54,15 +146,15 @@ public class FIRP0190 extends QCCatalogue {
             if (bloodType.contains(rh) ||
                     bloodType.contains(CatalogueUtil.removeSpecialChar(rhFactor))) {
                 matchSum++;
-                return ;
+                return;
             }
         }
-        /* 如果所有输血记录都没有rh记录(阴、阳),则不报错 */
-        if (noRhSum == clinicalBloodDocList.size()){
+        *//* 如果所有输血记录都没有rh记录(阴、阳),则不报错 *//*
+        if (noRhSum == clinicalBloodDocList.size()) {
             return;
         }
         if (matchSum == 0) {
             status.set("-1");
-        }
+        }*/
     }
-}
+}

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0209.java

@@ -20,7 +20,7 @@ import java.util.Map;
 @Component
 public class FIRP0209 extends QCCatalogue {
 
-    private List<String> containList = Arrays.asList("退(离)休人员","农民", "家务", "自由职业者", "个体经营者", "无业人员", "儿童");
+    private List<String> containList = Arrays.asList("退(离)休人员","退(离)休人员","农民", "家务", "自由职业者", "个体经营者", "无业人员", "儿童","学生");
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
@@ -41,4 +41,4 @@ public class FIRP0209 extends QCCatalogue {
             }
         }
     }
-}
+}

+ 8 - 9
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/ningbozhenhai/clinicalblood/CLI0566.java

@@ -22,24 +22,23 @@ public class CLI0566 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         status.set("0");
         List<ClinicalBloodDoc> clinicalBloodDocs = inputInfo.getClinicalBloodDocs();
-        if(ListUtil.isEmpty(clinicalBloodDocs)){
+        if (ListUtil.isEmpty(clinicalBloodDocs)) {
             return;
         }
-        if(clinicalBloodDocs != null && clinicalBloodDocs.size()>0){
-            for (ClinicalBloodDoc cliB:clinicalBloodDocs) {
+        if (clinicalBloodDocs != null && clinicalBloodDocs.size() > 0) {
+            for (ClinicalBloodDoc cliB : clinicalBloodDocs) {
                 Map<String, String> cliBStructureMap = cliB.getStructureMap();
-                if(cliBStructureMap.containsKey("记录医生")){
-                    if(StringUtils.isEmpty(cliBStructureMap.get("记录医生"))){
+                if (cliBStructureMap.containsKey("记录医生") || cliBStructureMap.containsKey("医生签名")) {
+                    if (StringUtils.isEmpty(cliBStructureMap.get("记录医生"))
+                            && StringUtils.isEmpty(cliBStructureMap.get("医生签名"))) {
                         status.set("-1");
                         break;
                     }
-                }else {
+                } else {
                     status.set("-1");
                     break;
                 }
-
             }
         }
-
     }
-}
+}

+ 212 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/ningbozhenhai/crisisvaluereport/CRI0382.java

@@ -0,0 +1,212 @@
+package com.lantone.qc.kernel.catalogue.hospital.ningbozhenhai.crisisvaluereport;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.client.SimilarityServiceClient;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.CrisisInfoDoc;
+import com.lantone.qc.pub.model.doc.CrisisValueReportDoc;
+import com.lantone.qc.pub.model.entity.Annotation;
+import com.lantone.qc.pub.model.vo.SimilarityVo;
+import com.lantone.qc.pub.util.DateUtil;
+import com.lantone.qc.pub.util.StringUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @Description : 危急值记录未在接到危急值报告后6小时内完成
+ * @Author : zhaops
+ * @Date 2022/8/2 13:36
+ */
+@Component
+public class CRI0382 extends QCCatalogue {
+    @Autowired
+    SimilarityServiceClient similarityServiceClient;
+
+    @Override
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        //无危急值结构化信息
+        List<CrisisInfoDoc> crisisInfoDocs = inputInfo.getCrisisInfoDocs();
+        if (crisisInfoDocs == null || crisisInfoDocs.size() == 0) {
+            return;
+        }
+        //有结构化信息但无危急值文书,如果报告时间都未超过6小时 允许无文书
+        boolean isOutTime = false;
+        Date currentDate = new Date();
+        int timeCha = 21600000;
+        String[] dateFormats = new String[] { "yyyy年MM月dd日HH时mm分", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm" };
+        for (CrisisInfoDoc crisisInfoDoc : crisisInfoDocs) {
+            String reptTime = crisisInfoDoc.getStructureMap().get("报告时间");
+            if (StringUtils.isNotEmpty(reptTime)) {
+                if (currentDate.getTime() - StringUtil.parseDateTime(reptTime, dateFormats).getTime() > timeCha) {
+                    isOutTime = true;
+                }
+            }
+        }
+        ;
+        if (isOutTime == false) {   //所有文书都未超过6小时,规则直接通过
+            return;
+        }
+
+        List<CrisisValueReportDoc> crisisValueReportDocs = inputInfo.getCrisisValueReportDocs();
+        //如果有危急值结构化数据 但无文书则直接提醒无危急值报告
+        if (crisisValueReportDocs == null || crisisValueReportDocs.size() == 0) {
+            status.set("-1");
+            return;
+        }
+        List<String> findCrisises = new ArrayList<>();
+        List<String> allCrisises = new ArrayList<>();
+        crisisInfoDocs.forEach(crisisInfoDoc -> {
+            String reptTime = crisisInfoDoc.getStructureMap().get("报告时间");
+            String crisisName = crisisInfoDoc.getStructureMap().get("危急结果值");
+            String crisisNm = "";
+            String companyNum = "";
+            /*if (crisisName.contains("项目为")) {
+                crisisName = crisisName.substring(crisisName.indexOf("项目为") + 3);
+            }
+            if (crisisName.contains(",结果:")) {
+                crisisNm = crisisName.split(",结果:")[0];
+                companyNum = crisisName.split(",结果:")[1];
+                if (StringUtil.isNotBlank(companyNum) && companyNum.contains("单位:")) {
+                    companyNum = companyNum.replaceAll("单位:", "");
+                }
+            }
+            if (crisisName.matches("[\\s\\S]*[(?==)][^,;,;。]{0,8}(?=秒)[\\s\\S]*")) {
+                crisisName = crisisName.split("=")[0];
+            }*/
+
+            //匹配文书检验结果书写格式
+            crisisName = StringUtil.removeBlank(crisisName)
+                    .replaceAll("(\\|(R|r)ange:\\d+(\\.\\d+)?(-|-)\\d+(\\.\\d+)?(;|;))", ",")
+                    .replaceAll("=", ":");
+            allCrisises.add(reptTime);
+            if (StringUtils.isNotEmpty(reptTime)) {
+                //当前时间和报告时间未超过6小时,规则通过
+                if (currentDate.getTime() - StringUtil.parseDateTime(reptTime, dateFormats).getTime() < timeCha) {
+                    findCrisises.add(reptTime);
+                } else {
+                    for (CrisisValueReportDoc crisisValueReportDoc : crisisValueReportDocs) {
+                        String recordTimeStr = crisisValueReportDoc.getStructureMap().get("病历日期");
+                        String docReptContent = crisisValueReportDoc.getStructureMap().get("病情分析及处理");
+                        String pattern = "\\d{4}年\\d{1,2}月\\d{1,2}日\\d{1,2}时\\d{1,2}分";
+                        Pattern r = Pattern.compile(pattern);
+                        Matcher m = r.matcher(docReptContent);
+                        Date reptDate = StringUtil.parseDateTime(reptTime, dateFormats);
+
+                        Boolean reptTimeMatch = false;
+                        while (m.find()) {
+                            if (DateUtil.getFirstTimeOfMinute(reptDate).getTime() == StringUtil.parseDateTime(m.group()).getTime()) {
+                                reptTimeMatch = true;
+                            }
+                        }
+                        //超声:添加文本相似度去比较病情分析及处理
+                        boolean flag = getLikeRate(submitContent(StringUtil.removeBlank(docReptContent))
+                                , StringUtil.removeBlank(crisisName));
+                        if ((StringUtil.parseDateTime(recordTimeStr, dateFormats).getTime() - StringUtil.parseDateTime(reptTime, dateFormats).getTime()) < timeCha
+                                && reptTimeMatch
+                                && (StringUtil.removeBlank(docReptContent).contains(StringUtil.removeBlank(crisisName)))
+                                || flag) {
+                            findCrisises.add(reptTime);
+                            break;
+                        }
+                    }
+                }
+            }
+        });
+
+        if (findCrisises.size() != allCrisises.size()) {
+            status.set("-1");
+            allCrisises.forEach(reptTime -> {
+                String criticalValueName = "";
+                if (!findCrisises.contains(reptTime) && !info.get().contains(reptTime)) {
+                    for (CrisisInfoDoc crisisInfoDoc : crisisInfoDocs) {
+                        if (reptTime.equals(crisisInfoDoc.getStructureMap().get("报告时间"))) {
+                            criticalValueName = crisisInfoDoc.getStructureMap().get("危急值名称");
+                        }
+                    }
+                    if (StringUtils.isEmpty(info.get())) {
+                        info.set(reptTime + " 危急值名称(" + criticalValueName + ")");
+                    } else {
+                        info.set(info.get() + "; " + reptTime + " 危急值名称(" + criticalValueName + ")");
+                    }
+                }
+            });
+        }
+    }
+
+    /**
+     * @Author songxl
+     * @Description 内容截取
+     * @Date 2021/3/29
+     * @Param [content]
+     * @Return java.lang.String
+     * @MethodName submitContent
+     */
+    private String submitContent(String content) {
+        if (StringUtil.isNotBlank(content)) {
+            if (content.contains("具体为")) {
+                content = content.split("具体为")[1];
+            }
+            if (content.contains("处理意见")) {
+                content = content.split("处理意见")[0];
+            }
+        }
+        return content;
+
+    }
+
+    /**
+     * @Author songxl
+     * @Description 获取文本相似度
+     * @Date 2021/3/29
+     * @Param [text_1, text_2]
+     * @Return boolean
+     * @MethodName getFlag
+     */
+    private boolean getLikeRate(String text_1, String text_2) {
+        if (text_1.contains("超声")) {
+            JSONArray similarContent = new JSONArray();
+            JSONObject detailContent = new JSONObject();
+            detailContent.put("text_1", text_1);
+            detailContent.put("text_2", text_2);
+            similarContent.add(detailContent);
+            //存储CRF完整所需结构数据
+            SimilarityVo similarityVo = new SimilarityVo();
+            similarityVo.setData(similarContent);
+            //获取CRF模型返回数据
+            JSONArray data = getAnnotation(similarityServiceClient, similarityVo).getData();
+            double likeRate = 0d;
+            if (data.size() > 0) {
+                JSONObject dataContent = data.getJSONObject(0);
+                likeRate = dataContent.getDoubleValue("like_rate");
+            }
+            if (likeRate > 0.8) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private Annotation getAnnotation(SimilarityServiceClient similarityServiceClient, SimilarityVo similarityVo) {
+        Annotation annotation = new Annotation();
+        try {
+            String annotation_str = similarityServiceClient.getAnnotation(similarityVo);
+            annotation = JSON.parseObject(annotation_str, Annotation.class);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return annotation;
+        }
+    }
+}

+ 3 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/hospital/ningbozhenhai/firstpagerecord/FIRP0178.java

@@ -110,9 +110,10 @@ public class FIRP0178 extends QCCatalogue {
     private List<String> getFirstPageDiag(List<Map<String, String>> dischargeDiag) {
         List<String> firstpageDiag = new ArrayList<>();
         for (int i = 0; i < dischargeDiag.size(); i++) {
-            if ("主要诊断".equals(dischargeDiag.get(i).get("诊断类别"))) {
+            //病案首页不区分主诊断和其他诊断,出院小结仍然区分
+            /*if ("主要诊断".equals(dischargeDiag.get(i).get("诊断类别"))) {
                 continue;
-            }
+            }*/
             String diagnoseName = dischargeDiag.get(i).get(Content.diagnoseName);
             if (StringUtil.isBlank(diagnoseName) || "-".equals(diagnoseName)) { // 诊断名称为空不算
                 continue;

+ 22 - 20
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03112.java

@@ -42,7 +42,7 @@ public class THR03112 extends QCCatalogue {
                             String daItemName = doctorAdviceDocStructureMap.get(Content.medicalOrderName);
                             String nameSs = doctorAdviceDocStructureMap.get("医嘱处方类型");
                             if (StringUtil.isNotEmpty(daItemName) && StringUtil.isNotEmpty(nameSs)) {
-                                if (dateStr(daItemName) && (nameSs.equals("检查")||nameSs.equals("RAD")|| nameSs.equals("放射医嘱"))) {
+                                if (dateStr(daItemName) && (nameSs.equals("检查") || nameSs.equals("RAD") || nameSs.equals("放射医嘱"))) {
                                     flag = true;
                                     status.set("-1");
                                 }
@@ -52,7 +52,7 @@ public class THR03112 extends QCCatalogue {
                 }
             }
         }
-        if(flag) {
+        if (flag) {
             List<PacsDoc> pacsDocs = inputInfo.getPacsDocs();
             if (ListUtil.isNotEmpty(pacsDocs)) {
                 for (PacsDoc pacsDoc : pacsDocs) {
@@ -62,7 +62,8 @@ public class THR03112 extends QCCatalogue {
                     String str2 = structureMap.get("报告名称");
                     String str3 = structureMap.get("观察记录");
                     String str4 = structureMap.get("检查结果诊断");
-                    if (dateStrBg(str) || dateStrBg(str1) || dateStrBg(str2) || dateStrBg(str3) || dateStrBg(str4)) {
+                    String str5 = structureMap.get("检查类型名称");
+                    if (dateStrBg(str) || dateStrBg(str1) || dateStrBg(str2) || dateStrBg(str3) || dateStrBg(str4) || dateStrBg(str5)) {
                         status.set("0");
                         return;
                     }
@@ -71,30 +72,31 @@ public class THR03112 extends QCCatalogue {
         }
     }
 
-    private boolean dateStr(String str){
-        if(StringUtil.isEmpty(str)){
+    private boolean dateStr(String str) {
+        if (StringUtil.isEmpty(str)) {
             return false;
         }
-        if (str.contains("MR") || str.contains("磁共振")||str.contains("核磁")) {
+        if (str.contains("MR") || str.contains("磁共振") || str.contains("核磁")) {
             List<String> notMRList = Content.notMRList;
             for (String list : notMRList) {
-                if(!str.contains(list)){
+                if (!str.contains(list)) {
                     return true;
                 }
             }
         }
         return false;
     }
-    private boolean dateStrBg(String str){
-        if(StringUtil.isEmpty(str)){
+
+    private boolean dateStrBg(String str) {
+        if (StringUtil.isEmpty(str)) {
             return false;
         }
-        boolean MrCf=false;
-        boolean jsj=false;
+        boolean MrCf = false;
+        boolean jsj = false;
         ArrayList<String> cfStrings = new ArrayList<>();
-        String rex2="[\\s\\S]{0,5}(?=MR)[\\s\\S]{1,10}";
+        String rex2 = "[\\s\\S]{0,5}(?=MR)[\\s\\S]{1,10}";
         //需要判断同时存在MR和MRS等情况的发生
-        if(str.contains("MR")) {
+        if (str.contains("MR")) {
             Matcher matcher = Pattern.compile(rex2).matcher(str);
             while (matcher.find()) {
                 String group = matcher.group();
@@ -105,24 +107,24 @@ public class THR03112 extends QCCatalogue {
                 for (String notCT : notMRList) {
                     for (int i = 0; i < cfStrings.size(); i++) {
                         String cfStr = cfStrings.get(i);
-                        if(cfStr.contains(notCT)){
+                        if (cfStr.contains(notCT)) {
                             cfStrings.remove(i);
                             continue;
                         }
                     }
                 }
-                if(cfStrings.size()>0){
-                    MrCf=true;
+                if (cfStrings.size() > 0) {
+                    MrCf = true;
                 }
             }
 
         }
-        if ( str.contains("磁共振")||str.contains("核磁")) {
-            jsj= true;
+        if (str.contains("磁共振") || str.contains("核磁")) {
+            jsj = true;
         }
-        if(jsj||MrCf){
+        if (jsj || MrCf) {
             return true;
         }
         return false;
     }
-}
+}

+ 62 - 53
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03233.java

@@ -11,7 +11,6 @@ import com.lantone.qc.pub.model.doc.DoctorAdviceDoc;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
 import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
-import com.lantone.qc.pub.model.label.ThreeLevelWardLabel;
 import com.lantone.qc.pub.util.DateUtil;
 import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
@@ -94,74 +93,84 @@ public class THR03233 extends QCCatalogue {
             return;
         }
 
-        List<Date> dateList = date.stream().map(i -> StringUtil.parseDateTime(i))
+        List<Date> dateList = date.stream().map(i -> DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i)))
                 .filter(Objects::nonNull)
+                .distinct()
                 .sorted(Comparator.comparing(i -> i))
                 .collect(Collectors.toList());
 
-        Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(0), -1));
-        Date endDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(dateList.size() - 1), 2));
-
         String regex = "四诊|神色|神态|面色|形态|语声|气息|舌象|舌|苔|脉|血虚|气血";
 
-        //首次诊疗计划
-        if (null != firstCourseRecordDoc) {
-            String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
-            Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
-            if (StringUtil.isNotBlank(treatPlan)
-                    && (!treatPlanDate.after(startDate)
-                    || !treatPlanDate.before(endDate))
-                    && RegexUtil.getRegexRes(treatPlan, regex, 2)) {
-                status.set("0");
-                return;
-            }
-            if (null != firstCourseRecordDoc.getTreatPlanLabel()
-                    && firstCourseRecordDoc.getTreatPlanLabel().getText().contains("四诊")) {
-                status.set("0");
-                return;
-            }
+        if (ListUtil.isEmpty(dateList)) {
+            status.set("0");
+            return;
         }
+        for (Date daDate : dateList) {
+            Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(daDate, -1));
+            Date endDate = DateUtil.getLastTimeOfDay(DateUtil.addDate(daDate, 2));
+            Boolean exist = false;
+
+            //首次诊疗计划
+            if (null != firstCourseRecordDoc) {
+                String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
+                Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
+                if (StringUtil.isNotBlank(treatPlan)
+                        && (treatPlanDate.getTime() >= startDate.getTime() && treatPlanDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(treatPlan, regex, 2)) {
+                    exist = true;
+                    continue;
+                }
+                if (null != firstCourseRecordDoc.getTreatPlanLabel()
+                        && firstCourseRecordDoc.getTreatPlanLabel().getText().contains("四诊")) {
+                    exist = true;
+                    continue;
+                }
+            }
 
-        //查房记录
-        if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-            threeLevelWardDocs = threeLevelWardDocs.stream()
-                    .filter(Objects::nonNull)
-                    .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
-                    .filter(i -> !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).after(startDate)
-                            || !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).before(endDate))
-                    .collect(Collectors.toList());
+            //查房记录
             if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-                for (ThreeLevelWardDoc item : threeLevelWardDocs) {
-                    if (RegexUtil.getRegexRes(item.getStructureMap().get("病情记录"), regex, 2)) {
-                        status.set("0");
-                        return;
-                    }
-
-                    //todo 模型记录四诊(暂不处理)
-                    List<ThreeLevelWardLabel> threeLevelWardLabel = item.getThreeLevelWardLabel();
+                List<ThreeLevelWardDoc> threeLevelWardDocs_match = threeLevelWardDocs.stream()
+                        .filter(Objects::nonNull)
+                        .filter(i -> ListUtil.isNotEmpty(i.getAllDoctorWradDocs()))
+                        .flatMap(i -> i.getAllDoctorWradDocs().stream())
+                        .distinct()
+                        .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
+                        .filter(i -> StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() >= startDate.getTime()
+                                && StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() <= endDate.getTime())
+                        .filter(i -> RegexUtil.getRegexRes(i.getStructureMap().get("病情记录"), regex, 2))
+                        .collect(Collectors.toList());
+                if (ListUtil.isNotEmpty(threeLevelWardDocs_match)) {
+                    exist = true;
+                    continue;
                 }
+
+                //todo 模型记录四诊(暂不处理)
+                //List<ThreeLevelWardLabel> threeLevelWardLabel = item.getThreeLevelWardLabel();
             }
-        }
 
-        //出院小结
-        if (null != leaveHospitalDoc) {
-            String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
-            Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("出院日期")));
-            if (StringUtil.isNotBlank(leaveHosText)
-                    && (!leaveHospitalDate.after(startDate)
-                    || !leaveHospitalDate.before(endDate))
-                    && RegexUtil.getRegexRes(leaveHosText, regex, 2)) {
-                status.set("0");
-                return;
+            //出院小结
+            if (null != leaveHospitalDoc) {
+                String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
+                Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(leaveHospitalDoc.getStructureMap().get("日期")));
+                if (StringUtil.isNotBlank(leaveHosText)
+                        && (leaveHospitalDate.getTime() >= startDate.getTime() && leaveHospitalDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(leaveHosText, regex, 2)) {
+                    exist = true;
+                    continue;
+                }
+                if (null != leaveHospitalDoc.getLeaveHospitalDoctorAdviceLabel()
+                        && leaveHospitalDoc.getLeaveHospitalDoctorAdviceLabel().getText().contains("四诊")) {
+                    exist = true;
+                    continue;
+                }
             }
-            if (null != leaveHospitalDoc.getLeaveHospitalDoctorAdviceLabel()
-                    && leaveHospitalDoc.getLeaveHospitalDoctorAdviceLabel().getText().contains("四诊")) {
-                status.set("0");
+
+            if (!exist) {
+                status.set("-1");
                 return;
             }
         }
-
-        status.set("-1");
+        status.set("0");
         return;
     }
 }

+ 67 - 46
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03234.java

@@ -4,7 +4,6 @@ package com.lantone.qc.kernel.catalogue.threelevelward;
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.RegexUtil;
-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.DoctorAdviceDoc;
@@ -16,10 +15,9 @@ import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -61,9 +59,21 @@ public class THR03234 extends QCCatalogue {
             return;
         }
 
+        List<String> chinesemedicineyinpian = Lists.newArrayList();
+        Properties properties = new Properties();
+        InputStream in = Thread.currentThread().getContextClassLoader()
+                .getResourceAsStream("medicine.properties");
+        try {
+            properties.load(new InputStreamReader(in, "UTF-8"));
+        } catch (Exception e) {
+
+        }
+        String medicineStr = properties.getProperty("chinesemedicineyinpian");
+        if (StringUtil.isNotBlank(medicineStr)) {
+            chinesemedicineyinpian = Arrays.stream(medicineStr.split(",")).collect(Collectors.toList());
+        }
         Boolean isRecord = false;
         List<DoctorAdviceDoc> recordList = Lists.newLinkedList();
-        List<String> chinesemedicineyinpian = Content.CHINESEMEDICINEYINPIAN;
         for (DoctorAdviceDoc item : doctorAdviceDocs) {
             if (null != item.getStructureMap()) {
                 if (RegexUtil.getRegexListRes(item.getStructureMap().get("医嘱项目名称"), chinesemedicineyinpian)) {
@@ -91,61 +101,72 @@ public class THR03234 extends QCCatalogue {
             return;
         }
 
-        List<Date> dateList = date.stream().map(i -> StringUtil.parseDateTime(i))
+        List<Date> dateList = date.stream().map(i -> DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i)))
                 .filter(Objects::nonNull)
+                .distinct()
                 .sorted(Comparator.comparing(i -> i))
                 .collect(Collectors.toList());
 
-        Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(0), -1));
-        Date endDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(dateList.size() - 1), 2));
 
         String regex = "中医辨病辨证依据|中医辩证";
 
-        //首次诊疗计划
-        if (null != firstCourseRecordDoc) {
-            String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
-            Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
-            if (StringUtil.isNotBlank(treatPlan)
-                    && (!treatPlanDate.after(startDate)
-                    || !treatPlanDate.before(endDate))
-                    && RegexUtil.getRegexRes(treatPlan, regex, 2)) {
-                status.set("0");
-                return;
-            }
+        if (ListUtil.isEmpty(dateList)) {
+            status.set("0");
+            return;
         }
+        for (Date daDate : dateList) {
+            Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(daDate, -1));
+            Date endDate = DateUtil.getLastTimeOfDay(DateUtil.addDate(daDate, 2));
+            Boolean exist = false;
+
+            //首次诊疗计划
+            if (null != firstCourseRecordDoc) {
+                String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
+                Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
+                if (StringUtil.isNotBlank(treatPlan)
+                        && (treatPlanDate.getTime() >= startDate.getTime() && treatPlanDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(treatPlan, regex)) {
+                    exist = true;
+                    continue;
+                }
+            }
 
-        //查房记录
-        if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-            threeLevelWardDocs = threeLevelWardDocs.stream()
-                    .filter(Objects::nonNull)
-                    .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
-                    .filter(i -> !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).after(startDate)
-                            || !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).before(endDate))
-                    .collect(Collectors.toList());
+            //查房记录
             if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-                for (ThreeLevelWardDoc item : threeLevelWardDocs) {
-                    if (RegexUtil.getRegexRes(item.getStructureMap().get("病情记录"), regex, 2)) {
-                        status.set("0");
-                        return;
-                    }
+                List<ThreeLevelWardDoc> threeLevelWardDocs_match = threeLevelWardDocs.stream()
+                        .filter(Objects::nonNull)
+                        .filter(i -> ListUtil.isNotEmpty(i.getAllDoctorWradDocs()))
+                        .flatMap(i -> i.getAllDoctorWradDocs().stream())
+                        .distinct()
+                        .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
+                        .filter(i -> StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() >= startDate.getTime()
+                                && StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() <= endDate.getTime())
+                        .filter(i -> RegexUtil.getRegexRes(i.getStructureMap().get("病情记录"), regex))
+                        .collect(Collectors.toList());
+                if (ListUtil.isNotEmpty(threeLevelWardDocs_match)) {
+                    exist = true;
+                    continue;
                 }
             }
-        }
 
-        //出院小结
-        if (null != leaveHospitalDoc) {
-            String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
-            Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("出院日期")));
-            if (StringUtil.isNotBlank(leaveHosText)
-                    && (!leaveHospitalDate.after(startDate)
-                    || !leaveHospitalDate.before(endDate))
-                    && RegexUtil.getRegexRes(leaveHosText, regex, 2)) {
-                status.set("0");
+            //出院小结
+            if (null != leaveHospitalDoc) {
+                String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
+                Date leaveHospitalDate = StringUtil.parseDateTime(leaveHospitalDoc.getStructureMap().get("日期"));
+                if (StringUtil.isNotBlank(leaveHosText)
+                        && (leaveHospitalDate.getTime() >= startDate.getTime() && leaveHospitalDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(leaveHosText, regex)) {
+                    exist = true;
+                    continue;
+                }
+            }
+
+            if (!exist) {
+                status.set("-1");
                 return;
             }
         }
-
-        status.set("-1");
+        status.set("0");
         return;
     }
-}
+}

+ 68 - 48
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03235.java

@@ -4,7 +4,6 @@ package com.lantone.qc.kernel.catalogue.threelevelward;
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.RegexUtil;
-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.DoctorAdviceDoc;
@@ -16,10 +15,9 @@ import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -61,12 +59,25 @@ public class THR03235 extends QCCatalogue {
             return;
         }
 
-        List<String> chineseMedicineyinpian = Content.CHINESEMEDICINEYINPIAN;
+        List<String> chinesemedicineyinpian = Lists.newArrayList();
+        Properties properties = new Properties();
+        InputStream in = Thread.currentThread().getContextClassLoader()
+                .getResourceAsStream("medicine.properties");
+        try {
+            properties.load(new InputStreamReader(in, "UTF-8"));
+        } catch (Exception e) {
+
+        }
+        String medicineStr = properties.getProperty("chinesemedicineyinpian");
+        if (StringUtil.isNotBlank(medicineStr)) {
+            chinesemedicineyinpian = Arrays.stream(medicineStr.split(",")).collect(Collectors.toList());
+        }
+
         Boolean isRecord = false;
         List<DoctorAdviceDoc> recordList = Lists.newLinkedList();
         for (DoctorAdviceDoc item : doctorAdviceDocs) {
             if (null != item.getStructureMap()) {
-                if (RegexUtil.getRegexListRes(item.getStructureMap().get("医嘱项目名称"), chineseMedicineyinpian)) {
+                if (RegexUtil.getRegexListRes(item.getStructureMap().get("医嘱项目名称"), chinesemedicineyinpian)) {
                     if (!recordList.contains(item)) {
                         recordList.add(item);
                     }
@@ -91,61 +102,70 @@ public class THR03235 extends QCCatalogue {
             return;
         }
 
-        List<Date> dateList = date.stream().map(i -> StringUtil.parseDateTime(i))
+        List<Date> dateList = date.stream().map(i -> DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i)))
                 .filter(Objects::nonNull)
+                .distinct()
                 .sorted(Comparator.comparing(i -> i))
                 .collect(Collectors.toList());
 
-        Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(0), -1));
-        Date endDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(dateList.size() - 1), 2));
-
         String regex = "治则|治为则|治法";
-
-        //首次诊疗计划
-        if (null != firstCourseRecordDoc) {
-            String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
-            Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
-            if (StringUtil.isNotBlank(treatPlan)
-                    && (!treatPlanDate.after(startDate)
-                    || !treatPlanDate.before(endDate))
-                    && RegexUtil.getRegexRes(treatPlan, regex, 2)) {
-                status.set("0");
-                return;
-            }
+        if (ListUtil.isEmpty(dateList)) {
+            status.set("0");
+            return;
         }
+        for (Date daDate : dateList) {
+            Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(daDate, -1));
+            Date endDate = DateUtil.getLastTimeOfDay(DateUtil.addDate(daDate, 2));
+            Boolean exist = false;
+
+            //首次诊疗计划
+            if (null != firstCourseRecordDoc) {
+                String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
+                Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
+                if (StringUtil.isNotBlank(treatPlan)
+                        && (treatPlanDate.getTime() >= startDate.getTime() && treatPlanDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(treatPlan, regex)) {
+                    exist = true;
+                    continue;
+                }
+            }
 
-        //查房记录
-        if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-            threeLevelWardDocs = threeLevelWardDocs.stream()
-                    .filter(Objects::nonNull)
-                    .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
-                    .filter(i -> !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).after(startDate)
-                            || !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).before(endDate))
-                    .collect(Collectors.toList());
+            //查房记录
             if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-                for (ThreeLevelWardDoc item : threeLevelWardDocs) {
-                    if (RegexUtil.getRegexRes(item.getStructureMap().get("病情记录"), regex, 2)) {
-                        status.set("0");
-                        return;
-                    }
+                List<ThreeLevelWardDoc> threeLevelWardDocs_match = threeLevelWardDocs.stream()
+                        .filter(Objects::nonNull)
+                        .filter(i -> ListUtil.isNotEmpty(i.getAllDoctorWradDocs()))
+                        .flatMap(i -> i.getAllDoctorWradDocs().stream())
+                        .distinct()
+                        .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
+                        .filter(i -> StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() >= startDate.getTime()
+                                && StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() <= endDate.getTime())
+                        .filter(i -> RegexUtil.getRegexRes(i.getStructureMap().get("病情记录"), regex))
+                        .collect(Collectors.toList());
+                if (ListUtil.isNotEmpty(threeLevelWardDocs_match)) {
+                    exist = true;
+                    continue;
                 }
             }
-        }
 
-        //出院小结
-        if (null != leaveHospitalDoc) {
-            String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
-            Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("出院日期")));
-            if (StringUtil.isNotBlank(leaveHosText)
-                    && (!leaveHospitalDate.after(startDate)
-                    || !leaveHospitalDate.before(endDate))
-                    && RegexUtil.getRegexRes(leaveHosText, regex, 2)) {
-                status.set("0");
+            //出院小结
+            if (null != leaveHospitalDoc) {
+                String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
+                Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(leaveHospitalDoc.getStructureMap().get("日期")));
+                if (StringUtil.isNotBlank(leaveHosText)
+                        && (leaveHospitalDate.getTime() >= startDate.getTime() && leaveHospitalDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(leaveHosText, regex)) {
+                    exist = true;
+                    continue;
+                }
+            }
+
+            if (!exist) {
+                status.set("-1");
                 return;
             }
         }
-
-        status.set("-1");
+        status.set("0");
         return;
 
     }

+ 53 - 44
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03236.java

@@ -4,7 +4,6 @@ package com.lantone.qc.kernel.catalogue.threelevelward;
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.RegexUtil;
-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.DoctorAdviceDoc;
@@ -60,8 +59,8 @@ public class THR03236 extends QCCatalogue {
 
 
         String regex1 = "口服|静滴|静推";
-        List<String> chineseMedicine = Content.CHINESEMEDICINE;
-        /*Lists.newArrayList();
+        List<String> chineseMedicine = Lists.newArrayList();//Content.CHINESEMEDICINE;
+
         Properties properties = new Properties();
         InputStream in = Thread.currentThread().getContextClassLoader()
                 .getResourceAsStream("medicine.properties");
@@ -74,7 +73,7 @@ public class THR03236 extends QCCatalogue {
         if (StringUtil.isNotBlank(medicineStr)) {
             chineseMedicine = Arrays.stream(medicineStr.split(",")).collect(Collectors.toList());
         }
-        */
+
 
         Boolean isRecord = false;
         List<DoctorAdviceDoc> recordList = Lists.newLinkedList();
@@ -108,61 +107,71 @@ public class THR03236 extends QCCatalogue {
             return;
         }
 
-        List<Date> dateList = date.stream().map(i -> StringUtil.parseDateTime(i))
+        List<Date> dateList = date.stream().map(i -> DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i)))
                 .filter(Objects::nonNull)
+                .distinct()
                 .sorted(Comparator.comparing(i -> i))
                 .collect(Collectors.toList());
 
-        Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(0), -1));
-        Date endDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(dateList.get(dateList.size() - 1), 2));
-
         String regex = "中医辨病辨证依据|中医辩证";
 
-        //首次诊疗计划
-        if (null != firstCourseRecordDoc) {
-            String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
-            Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
-            if (StringUtil.isNotBlank(treatPlan)
-                    && (!treatPlanDate.after(startDate)
-                    || !treatPlanDate.before(endDate))
-                    && RegexUtil.getRegexRes(treatPlan, regex, 2)) {
-                status.set("0");
-                return;
-            }
+        if (ListUtil.isEmpty(dateList)) {
+            status.set("0");
+            return;
         }
+        for (Date daDate : dateList) {
+            Date startDate = DateUtil.getFirstTimeOfDay(DateUtil.addDate(daDate, -1));
+            Date endDate = DateUtil.getLastTimeOfDay(DateUtil.addDate(daDate, 2));
+            Boolean exist = false;
+
+            //首次诊疗计划
+            if (null != firstCourseRecordDoc) {
+                String treatPlan = firstCourseRecordDoc.getStructureMap().get("诊疗计划");
+                Date treatPlanDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("病历日期")));
+                if (StringUtil.isNotBlank(treatPlan)
+                        && (treatPlanDate.getTime() >= startDate.getTime() && treatPlanDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(treatPlan, regex)) {
+                    exist = true;
+                    continue;
+                }
+            }
 
-        //查房记录
-        if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-            threeLevelWardDocs = threeLevelWardDocs.stream()
-                    .filter(Objects::nonNull)
-                    .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
-                    .filter(i -> !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).after(startDate)
-                            || !DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(i.getStructureMap().get("查房日期"))).before(endDate))
-                    .collect(Collectors.toList());
+            //查房记录
             if (ListUtil.isNotEmpty(threeLevelWardDocs)) {
-                for (ThreeLevelWardDoc item : threeLevelWardDocs) {
-                    if (RegexUtil.getRegexRes(item.getStructureMap().get("病情记录"), regex, 2)) {
-                        status.set("0");
-                        return;
-                    }
+                List<ThreeLevelWardDoc> threeLevelWardDocs_match = threeLevelWardDocs.stream()
+                        .filter(Objects::nonNull)
+                        .filter(i -> ListUtil.isNotEmpty(i.getAllDoctorWradDocs()))
+                        .flatMap(i -> i.getAllDoctorWradDocs().stream())
+                        .distinct()
+                        .filter(i -> i.getStructureMap().containsKey("查房日期") && i.getStructureMap().containsKey("病情记录"))
+                        .filter(i -> StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() >= startDate.getTime()
+                                && StringUtil.parseDateTime(i.getStructureMap().get("查房日期")).getTime() <= endDate.getTime())
+                        .filter(i -> RegexUtil.getRegexRes(i.getStructureMap().get("病情记录"), regex))
+                        .collect(Collectors.toList());
+                if (ListUtil.isNotEmpty(threeLevelWardDocs_match)) {
+                    exist = true;
+                    continue;
                 }
             }
-        }
 
-        //出院小结
-        if (null != leaveHospitalDoc) {
-            String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
-            Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(firstCourseRecordDoc.getStructureMap().get("出院日期")));
-            if (StringUtil.isNotBlank(leaveHosText)
-                    && (!leaveHospitalDate.after(startDate)
-                    || !leaveHospitalDate.before(endDate))
-                    && RegexUtil.getRegexRes(leaveHosText, regex, 2)) {
-                status.set("0");
+            //出院小结
+            if (null != leaveHospitalDoc) {
+                String leaveHosText = leaveHospitalDoc.getStructureMap().get("出院医嘱");
+                Date leaveHospitalDate = DateUtil.getFirstTimeOfDay(StringUtil.parseDateTime(leaveHospitalDoc.getStructureMap().get("日期")));
+                if (StringUtil.isNotBlank(leaveHosText)
+                        && (leaveHospitalDate.getTime() >= startDate.getTime() && leaveHospitalDate.getTime() <= endDate.getTime())
+                        && RegexUtil.getRegexRes(leaveHosText, regex)) {
+                    exist = true;
+                    continue;
+                }
+            }
+
+            if (!exist) {
+                status.set("-1");
                 return;
             }
         }
-
-        status.set("-1");
+        status.set("0");
         return;
     }
 }

+ 62 - 1
kernel/src/main/java/com/lantone/qc/kernel/util/RegexUtil.java

@@ -1,10 +1,16 @@
 package com.lantone.qc.kernel.util;
 
+import com.google.common.collect.Lists;
 import com.lantone.qc.pub.util.StringUtil;
 
+import java.util.Comparator;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 /**
  * @Description :
@@ -58,6 +64,61 @@ public class RegexUtil {
         return false;
     }
 
+    /**
+     * 返回匹配次数最多(最少)的字符串
+     *
+     * @param content
+     * @param regex
+     * @param reversed
+     * @return
+     */
+    public static List<String> getRegexRes(String content, String regex, Boolean reversed) {
+        List<String> retList = Lists.newArrayList();
+        Map<Integer, List<String>> sortedMap = new TreeMap<>(new Comparator<Integer>() {
+            @Override
+            public int compare(Integer o1, Integer o2) {
+                // 降序排序
+                return o2.compareTo(o1);
+            }
+        });
+
+        Map<String, Integer> matchMap = new LinkedHashMap<>();
+        try {
+            if (StringUtil.isBlank(content) || StringUtil.isBlank(regex)) {
+                return null;
+            }
+            Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+            Matcher matcher = pattern.matcher(content);
+            while (matcher.find()) {
+                String matchStr = matcher.group();
+                if (matchMap.containsKey(matchStr)) {
+                    matchMap.put(matchStr, matchMap.get(matchStr).intValue() + 1);
+                } else {
+                    matchMap.put(matchStr, 1);
+                }
+            }
+        } catch (Exception e) {
+            return null;
+        }
+        if (matchMap != null && matchMap.size() > 0) {
+            for (Map.Entry<String, Integer> entry : matchMap.entrySet()) {
+                if (sortedMap.containsKey(entry.getValue())) {
+                    List<String> list = sortedMap.get(entry.getValue());
+                    list.add(entry.getKey());
+                    sortedMap.put(entry.getValue(), list);
+                } else {
+                    sortedMap.put(entry.getValue(), Lists.newArrayList(entry.getKey()));
+                }
+            }
+            if (reversed) {
+                retList = sortedMap.values().stream().collect(Collectors.toList()).get(0);
+            } else {
+                retList = sortedMap.values().stream().collect(Collectors.toList()).get(sortedMap.size() - 1);
+            }
+        }
+        return retList;
+    }
+
     public static Boolean getRegexListRes(String content, List<String> regexList) {
         // 是否有符合的数据
         try {
@@ -76,4 +137,4 @@ public class RegexUtil {
         }
         return false;
     }
-}
+}

+ 1 - 1
kernel/src/main/resources/bootstrap.yml

@@ -18,7 +18,7 @@ spring:
   resources:
     static-locations: classpath:/
   profiles:
-    active: dev
+    active: test
 
 qc:
   hospital_id: 1,2,3,4,5,6,7,8,10,11,13,15,20,21,22,23,24,34,35,36

Dosya farkı çok büyük olduğundan ihmal edildi
+ 2 - 1
kernel/src/main/resources/medicine.properties


+ 13 - 0
public/src/main/java/com/lantone/qc/pub/util/DateUtil.java

@@ -485,6 +485,19 @@ public class DateUtil {
         return cal.getTime();
     }
 
+    /**
+     * 获取某一分钟的0秒的时间
+     *
+     * @param date 输入日期
+     * @return 返回加上0秒的时间
+     */
+    public static Date getFirstTimeOfMinute(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.SECOND, 0);
+        return cal.getTime();
+    }
+
     /**
      * 获取某一天的23时59分59秒的时间
      *

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 9
public/src/main/resources/chinesemedicine.json


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
public/src/main/resources/chinesemedicineyinpian.json


+ 2 - 1
trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/DeathRecordDocTrans.java

@@ -59,7 +59,8 @@ public class DeathRecordDocTrans extends ModelDocTrans {
             "签名时间=记录时间",
             "科室=科别",
             "死亡时间=死亡日期",
-            "医生签名=记录医生"
+            "医生签名=记录医生",
+            "诊治经过=诊疗经过"
     );
 
 }

+ 55 - 0
trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/util/CommonAnalysisUtil.java

@@ -0,0 +1,55 @@
+package com.lantone.qc.trans.ningbozhenhai.util;
+
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @Description :
+ * @Author : zhaops
+ * @Date 2022/7/25 15:56
+ */
+@Slf4j
+public class CommonAnalysisUtil {
+    /**
+     * 将title根据在文本中的位置排序
+     *
+     * @param titles
+     * @param content
+     * @return
+     */
+    public static List<String> sortTitles(List<String> titles, String content) {
+        titles = titles.stream().sorted(Comparator.comparing(i -> i.length()))
+                .collect(Collectors.toList());
+        Collections.reverse(titles);
+
+        Map<Integer, String> titleIndex = new TreeMap<>();
+        int index, index_1, index_2, firstIndex;
+        for (String title : titles) {
+            index = 0;
+            firstIndex = -1;
+            while (index >= 0 && index < content.length()) {
+                index_1 = content.indexOf(title + ":", index);
+                index_2 = content.indexOf(title + ":", index);
+                index = Math.max(index_1, index_2);
+                if (index < 0) {
+                    break;
+                }
+                if (firstIndex == -1 && index > firstIndex) {
+                    firstIndex = index;
+                    titleIndex.put(firstIndex, title);
+                }
+                StringBuffer sb = new StringBuffer(title.length());
+                for (int i = 0; i < title.length(); i++) {
+                    sb.append('*');
+                }
+                content = content.substring(0, index) + sb.toString() + content.substring(index + title.length());
+
+            }
+        }
+        titles = Lists.newArrayList(titleIndex.values());
+        return titles;
+    }
+}

+ 1 - 1
trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/util/DeathRecordHtmlAnalysis.java

@@ -26,7 +26,7 @@ public class DeathRecordHtmlAnalysis implements HtmlAnalysis {
         Map<String, String> structureMap = Maps.newLinkedHashMap();
         try {
             List<String> titles = Lists.newArrayList("性别", "年龄", "婚姻", "入院日期", "死亡时间", "入院情况", "入院诊断",
-                    "诊疗经过(重点记录病情演变、抢救经过)", "诊疗经过", "死亡原因", "死亡诊断", "医师签字", "医生签名", "记录时间");
+                    "诊疗经过(重点记录病情演变、抢救经过)", "诊疗经过","诊治经过", "死亡原因", "死亡诊断", "医师签字", "医生签名", "记录时间");
             String html = args[0];
             String recTitle = args[1];
             String recTypeId = args[2];

+ 3 - 3
trans/src/main/java/com/lantone/qc/trans/ningbozhenhai/util/FirstCourseRecordHtmlAnalysis.java

@@ -25,8 +25,8 @@ public class FirstCourseRecordHtmlAnalysis implements HtmlAnalysis {
     public Map<String, String> analysis(String... args) {
         Map<String, String> structureMap = Maps.newLinkedHashMap();
         try {
-            List<String> titles = Lists.newArrayList("病例特点", "拟诊讨论", "中医辨病辨证依据", "中医鉴别诊断", "西医鉴别诊断",
-                    "鉴别诊断", "西医诊断依据", "诊断依据", "初步诊断", "病情评估", "诊疗计划", "医生签名");
+            List<String> titles = Lists.newArrayList("病例特点", "拟诊讨论", "中医辨病辨证依据", "鉴别诊断", "中医鉴别诊断", "西医鉴别诊断",
+                    "西医诊断依据", "诊断依据", "初步诊断", "病情评估", "诊疗计划", "医生签名");
             String html = args[0];
             String recTitle = args[1];
             Document doc = Jsoup.parse(html);
@@ -34,7 +34,7 @@ public class FirstCourseRecordHtmlAnalysis implements HtmlAnalysis {
                     .replace("第1页", "");
             CommonAnalysisUtil.extractWardInfo(recTitle, htmlContent, structureMap);
             if (StringUtil.isNotBlank(htmlContent)) {
-                titles = CommonAnalysisUtil.sortTitles(titles, htmlContent);
+                titles = com.lantone.qc.trans.ningbozhenhai.util.CommonAnalysisUtil.sortTitles(titles, htmlContent);
                 CommonAnalysisUtil.cutByTitles(htmlContent, titles, 0, structureMap);
                 if (!structureMap.containsKey("诊断依据")) {
                     String zdyj = "";