Przeglądaj źródła

病历前后描述不一致

MarkHuang 5 lat temu
rodzic
commit
d2a0bd6b7d

+ 106 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/behospitalized/BEH02980.java

@@ -0,0 +1,106 @@
+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;
+import com.lantone.qc.pub.model.entity.GeneralDesc;
+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;
+import java.util.List;
+
+
+/**
+ * @ClassName : BEH02980
+ * @Description : 病历前后描述不一致
+ * @Author : Mark
+ * @Date: 2020-06-23 11:02
+ */
+@Component
+public class BEH02980 extends QCCatalogue {
+    @Autowired
+    ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
+
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
+        DiagLabel initialDiagLabel = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel();
+        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
+
+        List<String> pos_diags = new ArrayList<>();
+        List<String> neg_diags = new ArrayList<>();
+        List<String> present_neg_diags = new ArrayList<>();
+        List<String> past_neg_diags = new ArrayList<>();
+
+        if (presentLabel != null) {
+            present_neg_diags = extract_diags(presentLabel.getDiags(), pos_diags, neg_diags);
+        }
+        if (pastLabel != null) {
+            past_neg_diags = extract_diags(pastLabel.getDiags(), pos_diags, neg_diags);
+        }
+        if (initialDiagLabel != null) {
+            extract_diags(initialDiagLabel.getDiags(), pos_diags, neg_diags);
+        }
+
+        String infoStr = "";
+        int matchSum = 0;
+        ModelAI modelAI = new ModelAI();
+
+        for (String negdiag : neg_diags) {
+            JSONArray jsonArray = modelAI.loadChiefPresentSimilarAI(negdiag, pos_diags, false
+                    , "diagnose", chiefPresentSimilarityServiceClient);
+            if (jsonArray.size() == 2) {
+                /* 相似度最高症状 */
+                String dgname = jsonArray.getString(0);
+                /* 相似度分数 */
+                double likeRate = jsonArray.getDoubleValue(1);
+                if (likeRate > 0.85) {
+                    matchSum++;
+                    if (present_neg_diags.indexOf(negdiag)>=0) {
+                        infoStr = "现病史:\t" + negdiag;
+                    }
+                    else if (past_neg_diags.indexOf(negdiag)>=0) {
+                        infoStr = "既往史:\t" + negdiag;
+                    }
+                    break;
+                }
+            }
+        }
+        info.set(infoStr);
+        if (matchSum > 0) {
+            status.set("-1");
+        }
+
+    }
+
+
+    private List<String> extract_diags(List<Diag> diags, List<String> pos_diags, List<String> neg_diags ) {
+        List<String> dgs = new ArrayList<>();
+        for (Diag dg:diags) {
+            String dgname = dg.getHospitalDiagName();
+            if (dg.getNegative()==null) {
+                if (pos_diags.indexOf(dgname)==-1) {
+                    pos_diags.add(dgname);
+                }
+            }
+            else {
+                if (neg_diags.indexOf(dgname)==-1) {
+                    neg_diags.add(dgname);
+                    dgs.add(dgname);
+                }
+            }
+        }
+
+        return dgs;
+    }
+
+}