Sfoglia il codice sorgente

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

# Conflicts:
#	kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH0011.java
MarkHuang 5 anni fa
parent
commit
ce4766a5f2

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

@@ -1,6 +1,9 @@
 package com.lantone.qc.kernel.catalogue.behospitalized;
 
+import com.alibaba.fastjson.JSONArray;
 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.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Diag;
@@ -9,6 +12,7 @@ import com.lantone.qc.pub.model.label.DiagLabel;
 import com.lantone.qc.pub.model.label.PastLabel;
 import com.lantone.qc.pub.model.label.PresentLabel;
 import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -24,8 +28,10 @@ import java.util.List;
  */
 @Component
 public class BEH0011 extends QCCatalogue {
-//    @Autowired
-//    private SpecialStorageUtil specialStorageUtil;
+    //    @Autowired
+    //    private SpecialStorageUtil specialStorageUtil;
+    @Autowired
+    ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if (inputInfo.getBeHospitalizedDoc() == null) {
@@ -35,42 +41,65 @@ public class BEH0011 extends QCCatalogue {
         PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
         DiagLabel initialDiagLabel = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel();
         PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
-        if (initialDiagLabel == null || pastLabel == null || presentLabel == null) {
+        if (initialDiagLabel == null) {
             status.set("0");
             return;
         }
-        String presentText = presentLabel.getText();
-        List<Diag> presentDiags = presentLabel.getDiags();
-        List<String> presentPastDiag = new ArrayList<>();
-        /* 取现病史中一般情况之后的疾病名称 */
-        if (StringUtil.isNotBlank(presentText) && presentDiags.size() > 0) {
+        List<String> presentPastDiags = new ArrayList<>();
+        if (presentLabel != null) {
             List<GeneralDesc> generals = presentLabel.getGenerals();
-            /* 如果现病史中能找到一般情况,则查找之后的疾病名称 */
-            if (generals.size()>0) {
-                String lastGeneral = generals.get(generals.size() - 1).getName();
-                int lastGeneralIndex = presentText.indexOf(lastGeneral);
-                for (Diag presentDiag : presentDiags) {
-                    if (presentDiag.getNegative() != null) {
-                        continue;
-                    }
-                    /* 现病史中一般情况之后的疾病名称 */
-                    if (presentText.indexOf(presentDiag.getHospitalDiagName()) > lastGeneralIndex) {
-                        presentPastDiag.add(presentDiag.getHospitalDiagName());
+            if (generals.size() > 0) {
+                String presentText = presentLabel.getText();
+                List<Diag> presentDiags = presentLabel.getDiags();
+                /* 取现病史中一般情况之后的疾病名称 */
+                if (StringUtil.isNotBlank(presentText) && presentDiags.size() > 0) {
+                    String lastGeneral = generals.get(generals.size() - 1).getName();
+                    int lastGeneralIndex = presentText.indexOf(lastGeneral);
+                    for (Diag presentDiag : presentDiags) {
+                        if (presentDiag.getNegative() != null) {
+                            continue;
+                        }
+                        /* 现病史中一般情况之后的疾病名称 */
+                        if (presentText.indexOf(presentDiag.getHospitalDiagName()) > lastGeneralIndex) {
+                            presentPastDiags.add(presentDiag.getHospitalDiagName());
+                        }
                     }
                 }
             }
         }
         /* 取既往史中疾病名称 */
-        List<Diag> pastDiags = pastLabel.getDiags();
-        addDiagHospitalName(presentPastDiag, pastDiags);
+        if (pastLabel != null) {
+            List<Diag> pastDiags = pastLabel.getDiags();
+            addDiagHospitalName(presentPastDiags, pastDiags);
+        }
         /* 取初步诊断中疾病名称 */
-        List<String> initDiag = new ArrayList<>();
+        List<String> initDiags = new ArrayList<>();
         List<Diag> initialDiagDiags = initialDiagLabel.getDiags();
-        addDiagHospitalName(initDiag, initialDiagDiags);
+        addDiagHospitalName(initDiags, initialDiagDiags);
 
-        if (initDiag.containsAll(presentPastDiag)){
+        int matchSum = 0;
+        ModelAI modelAI = new ModelAI();
+        for (String presentPastDiag : presentPastDiags) {
+            JSONArray jsonArray = modelAI.loadChiefPresentSimilarAI(presentPastDiag, initDiags, false
+                    , "diagnose", chiefPresentSimilarityServiceClient);
+            if (jsonArray.size() == 2) {
+                /* 相似度最高症状 */
+                String symptom = jsonArray.getString(0);
+                /* 相似度分数 */
+                double likeRate = jsonArray.getDoubleValue(1);
+                if (likeRate > 0.9) {
+                    matchSum++;
+                }
+            }
+        }
+        if (matchSum == presentPastDiags.size()){
+            status.set("0");
+        }
+        /*
+        if (initDiags.containsAll(presentPastDiags)) {
             status.set("0");
         }
+         */
     }
 
     private void addDiagHospitalName(List<String> presentPastDiag, List<Diag> pastDiags) {

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

@@ -35,6 +35,10 @@ public class BEH0012 extends QCCatalogue {
         }
         List<String> diags_out = new ArrayList<>();
         Map<String, String> hostpital_standDiag = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
+        if (hostpital_standDiag == null){
+            status.set("0");
+            return;
+        }
         List<Diag> diags = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel().getDiags();
         if (diags != null && diags.size() > 0) {
             for (Diag diag : diags) {

+ 34 - 8
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH02909.java

@@ -3,9 +3,9 @@ package com.lantone.qc.kernel.catalogue.behospitalized;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
 import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.entity.GeneralDesc;
 import com.lantone.qc.pub.model.entity.Medicine;
 import com.lantone.qc.pub.model.label.PresentLabel;
-import com.lantone.qc.pub.util.ListUtil;
 import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
@@ -28,17 +28,43 @@ public class BEH02909 extends QCCatalogue {
             return;
         }
         String drugsCurrentlyInUse = inputInfo.getBeHospitalizedDoc().getStructureMap().get("目前使用的药物");
-        drugsCurrentlyInUse = StringUtil.isBlank(drugsCurrentlyInUse) ? "" : drugsCurrentlyInUse;
-        List<String> drug = getDrug(drugsCurrentlyInUse);
+        if (StringUtil.isBlank(drugsCurrentlyInUse)) {
+            status.set("0");
+            return;
+        }
+        /*List<String> drug = getDrug(drugsCurrentlyInUse);*/
         PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
         if (presentLabel == null) {
             status.set("0");
             return;
         }
-        List<Medicine> medicines = presentLabel.getMedicines();
-        if (medicines != null && medicines.size() > 0) {
-            List<String> drugFromPresent = getDrugFromPresent(medicines);
-            if (ListUtil.equals(drug, drugFromPresent)) {
+        List<String> drugFromPresent = new ArrayList<>();
+        List<GeneralDesc> generals = presentLabel.getGenerals();
+        if (generals.size() > 0) {
+            String presentText = presentLabel.getText();
+            List<Medicine> medicines = presentLabel.getMedicines();
+            /* 取现病史中一般情况之后的药品名称 */
+            if (StringUtil.isNotBlank(presentText) && medicines != null && medicines.size() > 0) {
+                String lastGeneral = generals.get(generals.size() - 1).getName();
+                int lastGeneralIndex = presentText.indexOf(lastGeneral);
+                for (Medicine medicine : medicines) {
+                    /* 现病史中一般情况之后的药品名称,并且不包含不详 */
+                    if (presentText.indexOf(medicine.getName()) > lastGeneralIndex && !medicine.getName().contains("不详")) {
+                        drugFromPresent.add(medicine.getName());
+                    }
+                }
+            }
+        }
+        if (drugFromPresent.size() == 0) {
+            status.set("0");
+        } else {
+            int matchSum = 0;
+            for (String drug : drugFromPresent) {
+                if (drugsCurrentlyInUse.contains(drug)) {
+                    matchSum++;
+                }
+            }
+            if (matchSum == drugFromPresent.size()) {
                 status.set("0");
             }
         }
@@ -71,7 +97,7 @@ public class BEH02909 extends QCCatalogue {
         for (Medicine medicine : medicines) {
             name = medicine.getName();
             if (StringUtil.isNotBlank(name)) {
-                drugs.add(name.replaceAll("[“”\"]",""));
+                drugs.add(name.replaceAll("[“”\"]", ""));
             }
         }
         return drugs;

+ 53 - 20
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstcourserecord/FIRC0095.java

@@ -1,6 +1,9 @@
 package com.lantone.qc.kernel.catalogue.firstcourserecord;
 
+import com.alibaba.fastjson.JSONArray;
 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.pub.model.InputInfo;
 import com.lantone.qc.pub.model.OutputInfo;
 import com.lantone.qc.pub.model.entity.Diag;
@@ -9,6 +12,7 @@ import com.lantone.qc.pub.model.label.DiagLabel;
 import com.lantone.qc.pub.model.label.PastLabel;
 import com.lantone.qc.pub.model.label.PresentLabel;
 import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -23,6 +27,9 @@ import java.util.List;
  */
 @Component
 public class FIRC0095 extends QCCatalogue {
+    @Autowired
+    ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
+
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
         if (inputInfo.getBeHospitalizedDoc() == null) {
             status.set("0");
@@ -31,39 +38,65 @@ public class FIRC0095 extends QCCatalogue {
         PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
         DiagLabel initialDiagLabel = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel();
         PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
-        if (initialDiagLabel == null || pastLabel == null || presentLabel == null) {
+        if (initialDiagLabel == null) {
             status.set("0");
             return;
         }
-        String presentText = presentLabel.getText();
-        List<Diag> presentDiags = presentLabel.getDiags();
-        List<String> presentPastDiag = new ArrayList<>();
-        /* 取现病史中一般情况之后的疾病名称 */
-        if (StringUtil.isNotBlank(presentText) && presentDiags.size() > 0) {
+        List<String> presentPastDiags = new ArrayList<>();
+        if (presentLabel != null) {
             List<GeneralDesc> generals = presentLabel.getGenerals();
-            String lastGeneral = generals.get(generals.size() - 1).getName();
-            int lastGeneralIndex = presentText.indexOf(lastGeneral);
-            for (Diag presentDiag : presentDiags) {
-                if (presentDiag.getNegative() != null) {
-                    continue;
-                }
-                /* 现病史中一般情况之后的疾病名称 */
-                if (presentText.indexOf(presentDiag.getHospitalDiagName()) > lastGeneralIndex) {
-                    presentPastDiag.add(presentDiag.getHospitalDiagName());
+            if (generals.size() > 0) {
+                String presentText = presentLabel.getText();
+                List<Diag> presentDiags = presentLabel.getDiags();
+                /* 取现病史中一般情况之后的疾病名称 */
+                if (StringUtil.isNotBlank(presentText) && presentDiags.size() > 0) {
+                    String lastGeneral = generals.get(generals.size() - 1).getName();
+                    int lastGeneralIndex = presentText.indexOf(lastGeneral);
+                    for (Diag presentDiag : presentDiags) {
+                        if (presentDiag.getNegative() != null) {
+                            continue;
+                        }
+                        /* 现病史中一般情况之后的疾病名称 */
+                        if (presentText.indexOf(presentDiag.getHospitalDiagName()) > lastGeneralIndex) {
+                            presentPastDiags.add(presentDiag.getHospitalDiagName());
+                        }
+                    }
                 }
             }
         }
         /* 取既往史中疾病名称 */
-        List<Diag> pastDiags = pastLabel.getDiags();
-        addDiagHospitalName(presentPastDiag, pastDiags);
+        if (pastLabel != null) {
+            List<Diag> pastDiags = pastLabel.getDiags();
+            addDiagHospitalName(presentPastDiags, pastDiags);
+        }
         /* 取初步诊断中疾病名称 */
-        List<String> initDiag = new ArrayList<>();
+        List<String> initDiags = new ArrayList<>();
         List<Diag> initialDiagDiags = initialDiagLabel.getDiags();
-        addDiagHospitalName(initDiag, initialDiagDiags);
+        addDiagHospitalName(initDiags, initialDiagDiags);
 
-        if (initDiag.containsAll(presentPastDiag)){
+        int matchSum = 0;
+        ModelAI modelAI = new ModelAI();
+        for (String presentPastDiag : presentPastDiags) {
+            JSONArray jsonArray = modelAI.loadChiefPresentSimilarAI(presentPastDiag, initDiags, false
+                    , "diagnose", chiefPresentSimilarityServiceClient);
+            if (jsonArray.size() == 2) {
+                /* 相似度最高症状 */
+                String symptom = jsonArray.getString(0);
+                /* 相似度分数 */
+                double likeRate = jsonArray.getDoubleValue(1);
+                if (likeRate > 0.9) {
+                    matchSum++;
+                }
+            }
+        }
+        if (matchSum == presentPastDiags.size()) {
+            status.set("0");
+        }
+        /*
+        if (initDiags.containsAll(presentPastDiags)) {
             status.set("0");
         }
+         */
     }
 
     private void addDiagHospitalName(List<String> presentPastDiag, List<Diag> pastDiags) {

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

@@ -32,6 +32,10 @@ public class FIRC0096 extends QCCatalogue {
         }
         List<String> diags_out = new ArrayList<>();
         Map<String, String> hostpital_standDiag = specialStorageUtil.getJsonStringValue(KernelConstants.HOSPITAL_DIAG_MAP);
+        if (hostpital_standDiag == null){
+            status.set("0");
+            return;
+        }
         FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
         if(firstCourseRecordDoc != null){
             DiagLabel initialDiagLabel = firstCourseRecordDoc.getInitialDiagLabel();

+ 31 - 5
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0175.java

@@ -1,15 +1,20 @@
 package com.lantone.qc.kernel.catalogue.firstpagerecord;
 
+import com.alibaba.fastjson.JSONArray;
 import com.google.common.collect.Lists;
 import com.lantone.qc.kernel.catalogue.QCCatalogue;
-import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.kernel.client.ChiefPresentSimilarityServiceClient;
+import com.lantone.qc.kernel.structure.ai.ModelAI;
 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.entity.Diag;
 import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -21,6 +26,9 @@ import java.util.Map;
  */
 @Component
 public class FIRP0175 extends QCCatalogue {
+    @Autowired
+    ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
+
     List<String> diags = Lists.newArrayList("2型糖尿病");
 
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
@@ -37,16 +45,34 @@ public class FIRP0175 extends QCCatalogue {
             if (ListUtil.isEmpty(dischargeDiag) || ListUtil.isEmpty(leaveDiags)) {
                 return;
             }
-            String firstpageleaveDiag = dischargeDiag.get(0).get(Content.diagnoseName);
+            String firstpageleaveDiag = "";
+            for (Map<String, String> diag : dischargeDiag) {
+                String diagCategory = diag.get("诊断类别");
+                if (StringUtil.isNotBlank(diagCategory) && "主要诊断".equals(diagCategory)) {
+                    firstpageleaveDiag = diag.get(Content.diagnoseName);
+                    break;
+                }
+            }
             String leaveDiag = leaveDiags.get(0).getHospitalDiagName();
             //判断是否有2型糖尿病这种病如果没有,把疾病前的数字去掉
             if (!diags.contains(leaveDiag)) {
                 leaveDiag = leaveDiag.replaceAll("^[0-9]", "");
             }
-            if (!CatalogueUtil.compareToken(firstpageleaveDiag, leaveDiag)) {
-                status.set("-1");
+            /* 存放出院小结主要诊断,为了调用疾病相似度接口,特意存成list格式 */
+            List<String> firstLeaveDiag = new ArrayList<>();
+            firstLeaveDiag.add(leaveDiag);
+            ModelAI modelAI = new ModelAI();
+            JSONArray jsonArray = modelAI.loadChiefPresentSimilarAI(firstpageleaveDiag, firstLeaveDiag, false
+                    , "diagnose", chiefPresentSimilarityServiceClient);
+            if (jsonArray.size() == 2) {
+                /* 相似度最高症状 */
+                String symptom = jsonArray.getString(0);
+                /* 相似度分数 */
+                double likeRate = jsonArray.getDoubleValue(1);
+                if (likeRate < 0.9) {
+                    status.set("-1");
+                }
             }
-
         }
     }
 }

+ 10 - 8
kernel/src/main/java/com/lantone/qc/kernel/catalogue/firstpagerecord/FIRP0192.java

@@ -5,9 +5,8 @@ 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.FirstPageRecordDoc;
-import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
 import com.lantone.qc.pub.model.doc.operation.OperationDoc;
-import org.apache.commons.lang3.StringUtils;
+import com.lantone.qc.pub.util.StringUtil;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -22,10 +21,10 @@ import java.util.Map;
 @Component
 public class FIRP0192 extends QCCatalogue {
     public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
         FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
         List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
         if (firstPageRecordDoc == null || operationDocs.size() == 0) {
-            status.set("0");
             return;
         }
         Map<String, Object> firstPageRecordDocStructureMap = firstPageRecordDoc.getStructureExtMap();
@@ -33,13 +32,16 @@ public class FIRP0192 extends QCCatalogue {
         if (mapList != null && mapList.size() > 0) {
             Map<String, String> op = mapList.get(0);
             String oName = op.get(Content.operative_name);
+            String operationName = "";
             for (OperationDoc operationDoc : operationDocs) {
-                if (operationDoc.getOperationRecordDoc() == null) {
-                    continue;
+                if (operationDoc.getOperationRecordDoc() != null) {
+                    operationName = operationDoc.getOperationRecordDoc().getStructureMap().get("手术名称");
                 }
-                String operationName = operationDoc.getOperationRecordDoc().getStructureMap().get("手术名称");
-                if (operationName.contains(oName)){
-                    status.set("0");
+                if (StringUtil.isBlank(operationName) && operationDoc.getOperationDiscussionDoc() != null){
+                    operationName = operationDoc.getOperationDiscussionDoc().getStructureMap().get("手术名称");
+                }
+                if (StringUtil.isNotBlank(operationName) && !operationName.contains(oName)){
+                    status.set("-1");
                     return;
                 }
             }

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

@@ -8,6 +8,8 @@ import com.lantone.qc.pub.model.OutputInfo;
 import org.springframework.stereotype.Component;
 
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * @ClassName : FIRP02972
@@ -24,8 +26,9 @@ public class FIRP02972 extends QCCatalogue {
             String address = firstpageStructureMap.get(Content.current_address);
             if (!CatalogueUtil.isEmpty(address)) {
                 String suffix = (address.length()<=5)?address:(address.substring(address.length()-5));
-                String regex = "[\\d]+(-[\\d]+)*";
-                if (!suffix.matches(regex)) {
+                Pattern p = Pattern.compile("[0-9一二三四五六七八九]");
+                Matcher m = p.matcher(suffix);
+                if (!m.find()) {
                     status.set("-1");
                 }
             }