浏览代码

1.移动RedisUtil、KernelConstants到dbanaly包下
2.添加查房记录主刀医师识别(在手术记录中查找,将主刀医师替换成相应医师职称)

hujing 5 年之前
父节点
当前提交
807f70ea7c
共有 28 个文件被更改,包括 246 次插入105 次删除
  1. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/util/KernelConstants.java
  2. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/util/RedisUtil.java
  3. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java
  4. 2 3
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0002.java
  5. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0011.java
  6. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0012.java
  7. 2 6
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0015.java
  8. 0 4
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0016.java
  9. 1 5
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0019.java
  10. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0065.java
  11. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0068.java
  12. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0494.java
  13. 2 4
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/deathrecord/DEAR0338.java
  14. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC0096.java
  15. 0 6
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC0497.java
  16. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0147.java
  17. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0508.java
  18. 2 2
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0094.java
  19. 19 14
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0127.java
  20. 20 8
      kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0128.java
  21. 1 5
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcess.java
  22. 0 8
      kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessPast.java
  23. 2 0
      kernel/src/main/java/com/lantone/qc/kernel/util/CacheUtil.java
  24. 60 18
      kernel/src/main/java/com/lantone/qc/kernel/util/CatalogueUtil.java
  25. 2 0
      kernel/src/main/java/com/lantone/qc/kernel/util/DiagEnhancer.java
  26. 1 1
      kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCTestController.java
  27. 8 0
      trans/src/main/java/com/lantone/qc/trans/changx/ChangxDocTrans.java
  28. 107 4
      trans/src/main/java/com/lantone/qc/trans/changx/ChangxThreeLevelWardDocTrans.java

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

@@ -1,4 +1,4 @@
-package com.lantone.qc.kernel.util;
+package com.lantone.qc.dbanaly.util;
 
 import java.util.ArrayList;
 import java.util.HashMap;

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

@@ -1,4 +1,4 @@
-package com.lantone.qc.kernel.util;
+package com.lantone.qc.dbanaly.util;
 
 import com.google.common.collect.Maps;
 import com.lantone.qc.pub.util.StringUtil;

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/analysis/QCAnalysis.java

@@ -5,7 +5,7 @@ import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.client.SimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.AIAnalyze;
 import com.lantone.qc.kernel.util.CatalogueUtil;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.exception.AIException;
 import com.lantone.qc.pub.exception.CatalogueException;
 import com.lantone.qc.pub.model.InputInfo;

+ 2 - 3
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0002.java

@@ -1,12 +1,11 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.alibaba.fastjson.JSONArray;
-import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.client.ChiefPresentSimilarityServiceClient;
 import com.lantone.qc.kernel.structure.ai.ModelAI;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0011.java

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Diag;

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0012.java

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Diag;

+ 2 - 6
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0015.java

@@ -1,19 +1,15 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.BodyPart;
-import com.lantone.qc.pub.model.entity.Cause;
 import com.lantone.qc.pub.model.entity.Clinical;
-import com.lantone.qc.pub.model.entity.Lis;
-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.List;
 
 

+ 0 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0016.java

@@ -1,15 +1,11 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.*;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.List;
 
 

+ 1 - 5
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0019.java

@@ -1,18 +1,14 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Clinical;
 import com.lantone.qc.pub.model.entity.Degree;
-import com.lantone.qc.pub.model.entity.Modification;
-import com.lantone.qc.pub.model.entity.PD;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.List;
 
 

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0065.java

@@ -35,7 +35,7 @@ public class BEH0065 extends QCCatalogue {
         } else {
             MenstrualLabel menstrualLabel = inputInfo.getBeHospitalizedDoc().getMenstrualLabel();
             String text = menstrualLabel.getText();
-            if (StringUtil.isNotBlank(text) && (text.contains("未行经") || text.contains("颜色")|| text.contains("绝经")|| text.contains("未来潮"))) {
+            if (StringUtil.isNotBlank(text) && (text.contains("未行经") || text.contains("颜色")|| text.contains("绝经")|| text.contains("未来潮"))) {
                 status.set("0");
                 return;
             }

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0068.java

@@ -38,7 +38,7 @@ public class BEH0068 extends QCCatalogue {
             if (inputInfo.getBeHospitalizedDoc().getMenstrualLabel() != null) {
                 MenstrualLabel menstrualLabel = inputInfo.getBeHospitalizedDoc().getMenstrualLabel();
                 String text = menstrualLabel.getText();
-                if (StringUtil.isNotBlank(text) && (text.contains("未行经") || text.contains("未来潮"))) {
+                if (StringUtil.isNotBlank(text) && (text.contains("未行经") || text.contains("未来潮") || text.contains("绝经"))) {
                     status.set("0");
                     return;
                 }

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0494.java

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.util.SpringContextUtil;

+ 2 - 4
kernel/src/main/java/com/lantone/qc/kernel/catalogue/deathrecord/DEAR0338.java

@@ -1,12 +1,10 @@
 package com.lantone.qc.kernel.catalogue.deathrecord;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.CatalogueUtil;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 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.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;

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

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.firstcourserecord;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;

+ 0 - 6
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC0497.java

@@ -2,17 +2,11 @@ package com.lantone.qc.kernel.catalogue.firstcourserecord;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
 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.entity.Diag;
-import com.lantone.qc.pub.model.label.DiagLabel;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
 import java.util.Map;
 
 /**

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0147.java

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.leavehospital;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.DeathRecordDoc;

+ 2 - 2
kernel/src/main/java/com/lantone/qc/kernel/catalogue/leavehospital/LEA0508.java

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.leavehospital;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;

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

@@ -1,8 +1,8 @@
 package com.lantone.qc.kernel.catalogue.threelevelward;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;

+ 19 - 14
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0127.java

@@ -6,6 +6,7 @@ import com.lantone.qc.pub.Content;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
 import com.lantone.qc.pub.util.DateUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
@@ -63,7 +64,7 @@ public class THR0127 extends QCCatalogue {
             List<String> lastWardDateRangeList = new ArrayList<>();
             //每周的病历记录
             while (i >= 1) {
-                roundRecordThisWeek = extractWardRecord(allDoctorWradDocs, beginDate, hoursPerWeek, lastRecordDate);
+                roundRecordThisWeek = extractWardRecord(inputInfo, allDoctorWradDocs, beginDate, hoursPerWeek, lastRecordDate);
                 if (CatalogueUtil.isEmpty(roundRecordThisWeek)) {
                     break;
                 }
@@ -77,16 +78,9 @@ public class THR0127 extends QCCatalogue {
                 status.set("0");
                 return;
             }
-            String title = "";
-            /* 如果有手术记录,则取出第一次手术记录的主刀医师职称 */
-            String doctorTitle = CatalogueUtil.getDoctorTitle(inputInfo);
             for (int j = 0; j < roundRecordEveryWeek.size(); j++) {
-                title = roundRecordEveryWeek.get(j);
-                if (title.contains("主刀")){
-                    title = title.replace("主刀",doctorTitle);
-                }
-                int directorNum = CatalogueUtil.appearNumber(title.split(","), Content.director);
-                int dept_doctorNum = CatalogueUtil.appearNumber(title.split(","), Content.dept_doctor);
+                int directorNum = CatalogueUtil.appearNumber(roundRecordEveryWeek.get(j).split(","), Content.director);
+                int dept_doctorNum = CatalogueUtil.appearNumber(roundRecordEveryWeek.get(j).split(","), Content.dept_doctor);
                 if (directorNum + dept_doctorNum < 2) {
                     //每周无2次主任医师查房记录/科主任查房记录
                     status.set("-1");
@@ -116,19 +110,30 @@ public class THR0127 extends QCCatalogue {
      * @param duration
      * @return
      */
-    private static String extractWardRecord(List<ThreeLevelWardDoc> threeLevelWardDocs, Date admisDate, int duration, Date maxRecordDate) {
-        String recordTime = "", recordTitle = "";
+    private static String extractWardRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs, Date admisDate, int duration, Date maxRecordDate) {
+        String recordTime = "", recordTitle = "", title = "";
         List<Date> dateList = new ArrayList();
         for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
             Map<String, String> threeLevelWardStructureMap = threeLevelWardDoc.getStructureMap();
             recordTime = threeLevelWardStructureMap.get("查房日期");
+            title = threeLevelWardStructureMap.get("查房标题");
+            if (StringUtil.isBlank(recordTime) || StringUtil.isBlank(title)) {
+                continue;
+            }
             Date recordDate = StringUtil.parseDateTime(recordTime);
             if (recordDate == null) {
                 continue;
             }
+            /* 替换查房标题中主刀/一助的职称 */
+            List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
+            if (title.contains("主刀")) {
+                String doctorTitle = CatalogueUtil.getDoctorTitle(operationDocs, recordDate,"主刀医师");
+                title = title.replace("主刀", doctorTitle);
+            } else if (title.contains("一助")){
+                String doctorTitle = CatalogueUtil.getDoctorTitle(operationDocs, recordDate,"一助");
+                title = title.replace("一助", doctorTitle);
+            }
             if (admisDate.before(recordDate) && !CatalogueUtil.compareTime(admisDate, recordDate, Long.valueOf(duration))) {
-                String title = threeLevelWardStructureMap.get("查房标题");
-                title = StringUtil.isNotBlank(title) ? title : "";
                 recordTitle += title + ",";
                 dateList.add(recordDate);
             }

+ 20 - 8
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR0128.java

@@ -2,13 +2,14 @@ package com.lantone.qc.kernel.catalogue.threelevelward;
 
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.kernel.util.CatalogueUtil;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 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.FirstCourseRecordDoc;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
 import com.lantone.qc.pub.util.DateUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -70,7 +71,7 @@ public class THR0128 extends QCCatalogue {
             List<String> lastWardDateRangeList = new ArrayList<>();
             //每周的病历记录
             while (i >= 1) {
-                roundRecordThisWeek = extractWardRecord(allDoctorWradDocs, beginDate, hoursPerWeek, lastRecordDate);
+                roundRecordThisWeek = extractWardRecord(inputInfo, allDoctorWradDocs, beginDate, hoursPerWeek, lastRecordDate);
                 if (CatalogueUtil.isEmpty(roundRecordThisWeek)) {
                     break;
                 }
@@ -120,19 +121,30 @@ public class THR0128 extends QCCatalogue {
      * @param duration
      * @return
      */
-    private static String extractWardRecord(List<ThreeLevelWardDoc> threeLevelWardDocs, Date admisDate, int duration, Date maxRecordDate) {
-        String recordTime = "", recordTitle = "";
+    private static String extractWardRecord(InputInfo inputInfo, List<ThreeLevelWardDoc> threeLevelWardDocs, Date admisDate, int duration, Date maxRecordDate) {
+        String recordTime = "", recordTitle = "", title = "";
         List<Date> dateList = new ArrayList();
         for (ThreeLevelWardDoc threeLevelWardDoc : threeLevelWardDocs) {
             Map<String, String> threeLevelWardStructureMap = threeLevelWardDoc.getStructureMap();
             recordTime = threeLevelWardStructureMap.get("查房日期");
+            title = threeLevelWardStructureMap.get("查房标题");
+            if (StringUtil.isBlank(recordTime) || StringUtil.isBlank(title)) {
+                continue;
+            }
             Date recordDate = StringUtil.parseDateTime(recordTime);
             if (recordDate == null) {
                 continue;
             }
-            if (admisDate.before(recordDate) && !CatalogueUtil.compareTime(admisDate, recordDate, Long.valueOf(duration))) {
-                String title = threeLevelWardStructureMap.get("查房标题");
-                title = StringUtil.isNotBlank(title) ? title : "";
+            /* 替换查房标题中主刀/一助的职称 */
+            List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
+            if (title.contains("主刀")) {
+                String doctorTitle = CatalogueUtil.getDoctorTitle(operationDocs, recordDate,"主刀医师");
+                title = title.replace("主刀", doctorTitle);
+            } else if (title.contains("一助")){
+                String doctorTitle = CatalogueUtil.getDoctorTitle(operationDocs, recordDate,"一助");
+                title = title.replace("一助", doctorTitle);
+            }
+            if (admisDate.before(recordDate) && !CatalogueUtil.compareTime(admisDate, recordDate, (long) duration)) {
                 recordTitle += title + ",";
                 dateList.add(recordDate);
             }

+ 1 - 5
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcess.java

@@ -2,15 +2,11 @@ package com.lantone.qc.kernel.structure.ai.process;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.lantone.qc.kernel.structure.ai.model.CrfOut;
 import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
 import com.lantone.qc.kernel.structure.ai.model.Lemma;
 import com.lantone.qc.kernel.util.CatalogueUtil;
 import com.lantone.qc.kernel.structure.ai.model.Relation;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
-import com.lantone.qc.pub.model.entity.Diag;
-import com.lantone.qc.pub.model.entity.DiagInfectious;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.entity.Negative;
 import com.lantone.qc.pub.model.entity.PD;
 import org.apache.commons.beanutils.BeanUtils;

+ 0 - 8
kernel/src/main/java/com/lantone/qc/kernel/structure/ai/process/EntityProcessPast.java

@@ -1,24 +1,16 @@
 package com.lantone.qc.kernel.structure.ai.process;
 
 import com.alibaba.fastjson.JSONObject;
-import com.lantone.qc.kernel.structure.ai.model.CrfOut;
 import com.lantone.qc.kernel.structure.ai.model.EntityEnum;
 import com.lantone.qc.kernel.structure.ai.model.Lemma;
 import com.lantone.qc.kernel.util.DiagEnhancer;
-import com.lantone.qc.kernel.util.KernelConstants;
-import com.lantone.qc.kernel.util.RedisUtil;
 import com.lantone.qc.pub.model.entity.*;
 import com.lantone.qc.pub.model.label.PastLabel;
-import org.apache.commons.beanutils.BeanUtils;
-import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @ClassName : EntityProcessPast

+ 2 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/CacheUtil.java

@@ -1,6 +1,8 @@
 package com.lantone.qc.kernel.util;
 
 import com.google.common.collect.Maps;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.nlp.participle.cfg.Configuration;
 import com.lantone.qc.nlp.participle.cfg.DefaultConfig;
 import com.lantone.qc.pub.util.StringUtil;

+ 60 - 18
kernel/src/main/java/com/lantone/qc/kernel/util/CatalogueUtil.java

@@ -2,8 +2,9 @@ package com.lantone.qc.kernel.util;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.DoctorAdviceDoc;
 import com.lantone.qc.pub.model.doc.operation.OperationDoc;
 import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
@@ -256,13 +257,9 @@ public class CatalogueUtil {
      */
     public static int appearNumber(String[] srcText, String findText) {
         int count = 0;
-        Pattern p = null;
-        Matcher m = null;
         for (String title : srcText) {
             title = subTitle(title);
-            p = Pattern.compile(findText);
-            m = p.matcher(title);
-            while (m.find()) {
+            if (title.contains(findText)) {
                 count++;
             }
         }
@@ -383,38 +380,83 @@ public class CatalogueUtil {
     }
 
     /**
-     * 获取主刀医师职称(取第一次取到的主刀医师职称)
+     * 获取两个时间的时间差
      *
-     * @param inputInfo
+     * @param firstDate
+     * @param secondDate
      * @return
      */
-    public static String getDoctorTitle(InputInfo inputInfo) {
+    public static long timeDifference(Date firstDate, Date secondDate) {
+        long timeDifference = 0L;
+        if (firstDate == null || secondDate == null) {
+            return timeDifference;
+        }
+        boolean flag = false;
+        if (firstDate.before(secondDate)) {
+            flag = true;
+        }
+        Calendar calendarS = Calendar.getInstance();
+        Calendar calendarE = Calendar.getInstance();
+        long timeS, timeE;
+        try {
+            calendarS.setTime(firstDate);
+            calendarE.setTime(secondDate);
+
+            timeS = calendarS.getTimeInMillis();
+            timeE = calendarE.getTimeInMillis();
+
+            if (flag) {
+                timeDifference = (timeE - timeS) / (1000 * 60);
+            } else {
+                timeDifference = (timeS - timeE) / (1000 * 60);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return timeDifference;
+    }
+
+    /**
+     * 获取主刀医师/一助职称(取距离查房记录时间最近的一次手术记录)
+     *
+     * @param operationDocs
+     * @return
+     */
+    public static String getDoctorTitle(List<OperationDoc> operationDocs, Date recordDate, String findTitle) {
         String title = "";
         RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
         Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
         if (surgeon == null) {
             return title;
         }
-
-        List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
+        /* 用于存放手术结束时间距离查房时间最近的一次时间差 */
+        long timeDiff = 0L;
         for (OperationDoc operationDoc : operationDocs) {
             OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
             if (operationRecordDoc == null) {
                 continue;
             }
             Map<String, String> structureMap = operationRecordDoc.getStructureMap();
-            String chiefSurgeon = structureMap.get("主刀医师");
-            if (StringUtil.isBlank(chiefSurgeon)){
+            String chiefSurgeon = structureMap.get(findTitle);
+            String operatorEndDateStr = structureMap.get("手术结束时间");
+
+            if (StringUtil.isBlank(chiefSurgeon) || StringUtil.isBlank(operatorEndDateStr)) {
                 continue;
             }
             Map<String, String> doctor = (Map) surgeon.get(chiefSurgeon);
-            if (doctor == null){
-                continue;
+            if (doctor != null) {
+                String professor = doctor.get("professor");
+                Date operatorEndDate = StringUtil.parseDateTime(operatorEndDateStr);
+                if (operatorEndDate != null) {
+                    long timeDifference = timeDifference(operatorEndDate, recordDate);
+                    if (timeDiff == 0 || timeDiff > timeDifference) {
+                        /* 取距离此次主刀医师查房最近的一次手术时间 */
+                        timeDiff = timeDifference;
+                        title = professor;
+                    }
+                }
             }
-            title = doctor.get("professor");
-            break;
         }
-
         return title;
     }
 }

+ 2 - 0
kernel/src/main/java/com/lantone/qc/kernel/util/DiagEnhancer.java

@@ -1,5 +1,7 @@
 package com.lantone.qc.kernel.util;
 
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.entity.Diag;
 import com.lantone.qc.pub.util.SpringContextUtil;
 import com.lantone.qc.pub.util.StringUtil;

+ 1 - 1
kernel/src/main/java/com/lantone/qc/kernel/web/controller/QCTestController.java

@@ -3,7 +3,7 @@ package com.lantone.qc.kernel.web.controller;
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.analysis.QCAnalysis;
 import com.lantone.qc.kernel.util.CacheFileManager;
-import com.lantone.qc.kernel.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.KernelConstants;
 import com.lantone.qc.pub.jdbc.MysqlJdbc;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.vo.MedrecVo;

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

@@ -1,13 +1,20 @@
 package com.lantone.qc.trans.changx;
 
 import com.google.common.collect.Lists;
+import com.lantone.qc.dbanaly.util.RedisUtil;
 import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
 import com.lantone.qc.pub.model.vo.MedrecVo;
 import com.lantone.qc.pub.model.vo.QueryVo;
 import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.SpringContextUtil;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.DocTrans;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -110,6 +117,7 @@ public class ChangxDocTrans extends DocTrans {
             }
             if (i.getTitle().equals("查房记录")) {
                 ChangxThreeLevelWardDocTrans threeLevelWardDocTrans = new ChangxThreeLevelWardDocTrans();
+                threeLevelWardDocTrans.setOperationDocs(inputInfo.getOperationDocs());
                 inputInfo.setThreeLevelWardDocs(threeLevelWardDocTrans.extract(i));
             }
             if (i.getTitle().equals("病理检验送检单")) {

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

@@ -4,7 +4,12 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.lantone.qc.dbanaly.facade.changx.CxXmlUtil;
 import com.lantone.qc.dbanaly.lt.facade.ModelHospitalFacade;
+import com.lantone.qc.dbanaly.util.KernelConstants;
+import com.lantone.qc.dbanaly.util.RedisUtil;
+import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
+import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
 import com.lantone.qc.pub.model.doc.ward.AttendingDoctorWardDoc;
 import com.lantone.qc.pub.model.doc.ward.DirectorDoctorWardDoc;
 import com.lantone.qc.pub.model.doc.ward.GeneralDoctorWardDoc;
@@ -14,8 +19,11 @@ import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.ModelDocTrans;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import com.lantone.qc.trans.comsis.Preproc;
+import lombok.Setter;
 import org.apache.commons.lang3.StringUtils;
 
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -26,9 +34,11 @@ import java.util.regex.Pattern;
  * @author: rengb
  * @time: 2020/3/17 13:27
  */
+@Setter
 public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
 
     private List<String> recTitles;
+    private List<OperationDoc> operationDocs;
 
     @Override
     public List<ThreeLevelWardDoc> extract(MedrecVo medrecVo) {
@@ -50,9 +60,9 @@ public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
         Map<String, String> xmlNodeValueMap = CxXmlUtil.firstLevelNodeValue(content);
         xmlNodeValueMap.put("mode_id=" + contentMap.get("modeId").toString(), "");
         String recTitle = contentMap.get("recTitle").toString();
-//        if (recTitles.contains(recTitle)) {
-//            xmlNodeValueMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
-//        }
+        //        if (recTitles.contains(recTitle)) {
+        //            xmlNodeValueMap.put("rec_title=" + contentMap.get("recTitle").toString(), "");
+        //        }
         Map<String, String> structureMap = OrdinaryAssistant.mapKeyContrast(xmlNodeValueMap, keyContrasts);
         structureMap.put("查房日期", structureMap.get("记录时间"));
 
@@ -113,9 +123,18 @@ public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
     private DirectorDoctorWardDoc findDirectorDoctorWardDoc(Map<String, String> structureMap) {
         String title = structureMap.get("查房标题");
         String content = structureMap.get("病情记录");
+        String recordDateStr = structureMap.get("查房日期");
+        Date recordDate = StringUtil.parseDateTime(recordDateStr);
         //标题有代字
         DirectorDoctorWardDoc directorDoctorWardDoc = null;
         if (StringUtil.isNotBlank(title)) {
+            if (title.contains("主刀")) {
+                String doctorTitle = getDoctorTitle(operationDocs, recordDate, "主刀医师");
+                title = title.replace("主刀", doctorTitle);
+            } else if (title.contains("一助")) {
+                String doctorTitle = getDoctorTitle(operationDocs, recordDate, "一助");
+                title = title.replace("一助", doctorTitle);
+            }
             if ((StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主任")) || findDirector(title, content)) {
                 directorDoctorWardDoc = new DirectorDoctorWardDoc();
                 directorDoctorWardDoc.setStructureMap(structureMap);
@@ -133,10 +152,20 @@ public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
     private AttendingDoctorWardDoc findAttendingDoctorWardDoc(Map<String, String> structureMap) {
         String title = structureMap.get("查房标题");
         String content = structureMap.get("病情记录");
+        String recordDateStr = structureMap.get("查房日期");
+        Date recordDate = StringUtil.parseDateTime(recordDateStr);
         AttendingDoctorWardDoc attendingDoctorWardDoc = null;
         //标题有代字
         if (StringUtil.isNotBlank(title)) {
-            if ((StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主治")) || findAttend(title, content)) {
+            if (title.contains("主刀")) {
+                String doctorTitle = getDoctorTitle(operationDocs, recordDate, "主刀医师");
+                title = title.replace("主刀", doctorTitle);
+            } else if (title.contains("一助")) {
+                String doctorTitle = getDoctorTitle(operationDocs, recordDate, "一助");
+                title = title.replace("一助", doctorTitle);
+            }
+            if ((StringUtils.isNotEmpty(subTitle(title)) && subTitle(title).contains("主治"))
+                    || findAttend(title, content)) {
                 attendingDoctorWardDoc = new AttendingDoctorWardDoc();
                 attendingDoctorWardDoc.setStructureMap(structureMap);
                 attendingDoctorWardDoc.setPageData((Map) structureMap);
@@ -193,4 +222,78 @@ public class ChangxThreeLevelWardDocTrans extends ModelDocTrans {
             "记录日期=记录时间"
     );
 
+    /**
+     * 获取主刀医师/一助职称(取距离查房记录时间最近的一次手术记录)
+     *
+     * @param operationDocs
+     * @return
+     */
+    public static String getDoctorTitle(List<OperationDoc> operationDocs, Date recordDate, String findTitle) {
+        String title = "";
+        RedisUtil redisUtil = SpringContextUtil.getBean("redisUtil");
+        Map<String, Object> surgeon = redisUtil.getJsonStringValue(KernelConstants.HOSPITAL_DOCTOR_MAP);
+        if (surgeon == null) {
+            return title;
+        }
+        /* 用于存放手术结束时间距离查房时间最近的一次时间差 */
+        long timeDiff = 0L;
+        for (OperationDoc operationDoc : operationDocs) {
+            OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
+            if (operationRecordDoc == null) {
+                continue;
+            }
+            Map<String, String> structureMap = operationRecordDoc.getStructureMap();
+            String chiefSurgeon = structureMap.get(findTitle);
+            String operatorEndDateStr = structureMap.get("手术结束时间");
+
+            if (StringUtil.isBlank(chiefSurgeon) || StringUtil.isBlank(operatorEndDateStr)) {
+                continue;
+            }
+            Map<String, String> doctor = (Map) surgeon.get(chiefSurgeon);
+            if (doctor != null) {
+                String professor = doctor.get("professor");
+                Date operatorEndDate = StringUtil.parseDateTime(operatorEndDateStr);
+                if (operatorEndDate != null) {
+                    long timeDifference = timeDifference(operatorEndDate, recordDate);
+                    if (timeDiff == 0 || timeDiff > timeDifference) {
+                        /* 取距离此次主刀医师查房最近的一次手术时间 */
+                        timeDiff = timeDifference;
+                        title = professor;
+                    }
+                }
+            }
+        }
+        return title;
+    }
+
+    public static long timeDifference(Date firstDate, Date secondDate) {
+        long timeDifference = 0L;
+        if (firstDate == null || secondDate == null) {
+            return timeDifference;
+        }
+        boolean flag = false;
+        if (firstDate.before(secondDate)) {
+            flag = true;
+        }
+        Calendar calendarS = Calendar.getInstance();
+        Calendar calendarE = Calendar.getInstance();
+        long timeS, timeE;
+        try {
+            calendarS.setTime(firstDate);
+            calendarE.setTime(secondDate);
+
+            timeS = calendarS.getTimeInMillis();
+            timeE = calendarE.getTimeInMillis();
+
+            if (flag) {
+                timeDifference = (timeE - timeS) / (1000 * 60);
+            } else {
+                timeDifference = (timeS - timeE) / (1000 * 60);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return timeDifference;
+    }
+
 }