|
@@ -0,0 +1,264 @@
|
|
|
+package com.lantone.qc.kernel.catalogue.hospital.xszyy.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.Content;
|
|
|
+import com.lantone.qc.pub.model.InputInfo;
|
|
|
+import com.lantone.qc.pub.model.OutputInfo;
|
|
|
+import com.lantone.qc.pub.model.entity.Allergy;
|
|
|
+import com.lantone.qc.pub.model.entity.Diag;
|
|
|
+import com.lantone.qc.pub.model.entity.GeneralDesc;
|
|
|
+import com.lantone.qc.pub.model.entity.Negative;
|
|
|
+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.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : BEH02980
|
|
|
+ * @Description : 病历前后描述不一致
|
|
|
+ * @Author : Mark
|
|
|
+ * @Date: 2020-06-23 11:02
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class BEH02980 extends QCCatalogue {
|
|
|
+ @Autowired
|
|
|
+ ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
|
|
|
+
|
|
|
+ private List<String> containList = Arrays.asList("脑萎缩", "慢性", "纤颤", "高血压", "糖尿", "冠状", "冠心病", "支架", "起搏器", "房颤", "风湿");
|
|
|
+ private List<String> filterList = Arrays.asList("心脏病", "低血糖", "急性", ";");
|
|
|
+
|
|
|
+ public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
+ status.set("0");
|
|
|
+ if (inputInfo.getBeHospitalizedDoc() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ 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<>();
|
|
|
+ //现病史需要取一般情况之后疾病
|
|
|
+ if (presentLabel != null) {
|
|
|
+ List<GeneralDesc> generals = presentLabel.getGenerals();
|
|
|
+ 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 || presentDiag.getHospitalDiagName().contains("否认")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /* 现病史中一般情况之后的疾病名称 */
|
|
|
+ if (presentText.indexOf(presentDiag.getHospitalDiagName()) > lastGeneralIndex) {
|
|
|
+ if (isContains(presentDiag.getHospitalDiagName()) && !isFilter(presentDiag.getHospitalDiagName())) {
|
|
|
+ String dgname = presentDiag.getHospitalDiagName();
|
|
|
+ if (presentDiag.getNegative() == null) {
|
|
|
+ if (!pos_diags.contains(dgname)) {
|
|
|
+ pos_diags.add(dgname);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!neg_diags.contains(dgname)) {
|
|
|
+ neg_diags.add(dgname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pastLabel != null && StringUtils.isNotEmpty(pastLabel.getText())) {
|
|
|
+ extract_diags(pastLabel.getDiags(), pos_diags, neg_diags);
|
|
|
+ //否认其他的情况
|
|
|
+ String pasttext = pastLabel.getText();
|
|
|
+ //冠状动脉支架植入术特殊情况,只要出现,就从否认的史中去掉
|
|
|
+ if (neg_diags.contains("冠状动脉支架植入术")) {
|
|
|
+ neg_diags.remove("冠状动脉支架植入术");
|
|
|
+ }
|
|
|
+ String neg_diags_first[] = pasttext.split("否认");
|
|
|
+ for (String str1 : neg_diags_first) {
|
|
|
+ String neg_diags_second[] = str1.split("、");
|
|
|
+ for (String str2 : neg_diags_second) {
|
|
|
+ for (String neg_diag : neg_diags) {
|
|
|
+ if (str2.contains(neg_diag)) {
|
|
|
+ String str3 = str2.substring(0, str2.indexOf(neg_diag));
|
|
|
+ if (str3.contains("其它") || str3.contains("其他")) {
|
|
|
+ int index = neg_diags.indexOf(neg_diag);
|
|
|
+ neg_diags.set(index, "其它的");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+// //过敏史
|
|
|
+// if(!"7".equals(Content.hospital_Id))
|
|
|
+// {
|
|
|
+// extract_Allergy(pastLabel.getAllergies(), pos_diags, neg_diags, pastLabel.getText());
|
|
|
+// }
|
|
|
+ } else {
|
|
|
+ //例如邵逸夫 台州这种结构化数据,判断高血压 和 糖尿病是否有冲突
|
|
|
+ List<Diag> pastDiags = new ArrayList<>();
|
|
|
+ Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
|
|
|
+ String a1 = structureMap.get("高血压");
|
|
|
+ Diag diag = new Diag();
|
|
|
+ diag.setName("高血压");
|
|
|
+ diag.setHospitalDiagName("高血压");
|
|
|
+ if (StringUtils.isNotEmpty(a1) && "否认".equals(a1)) {
|
|
|
+ Negative negative = new Negative();
|
|
|
+ negative.setName("否认");
|
|
|
+ pastDiags.add(diag);
|
|
|
+ } else if (StringUtils.isNotEmpty(a1) && !"否认".equals(a1)) {
|
|
|
+ pastDiags.add(diag);
|
|
|
+ }
|
|
|
+
|
|
|
+ a1 = structureMap.get("糖尿病");
|
|
|
+ diag = new Diag();
|
|
|
+ diag.setName("糖尿病");
|
|
|
+ diag.setHospitalDiagName("糖尿病");
|
|
|
+ if (StringUtils.isNotEmpty(a1) && "否认".equals(a1)) {
|
|
|
+ Negative negative = new Negative();
|
|
|
+ negative.setName("否认");
|
|
|
+ pastDiags.add(diag);
|
|
|
+ } else if (StringUtils.isNotEmpty(a1) && !"否认".equals(a1)) {
|
|
|
+ pastDiags.add(diag);
|
|
|
+ }
|
|
|
+
|
|
|
+ extract_diags(pastDiags, 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);
|
|
|
+ if ("糖尿病".equals(negdiag) && "妊娠期糖尿病".equals(dgname)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ("高血压史".equals(negdiag) && "高血压病".equals(dgname)) {
|
|
|
+ matchSum++;
|
|
|
+ if (StringUtils.isEmpty(infoStr)) {
|
|
|
+ infoStr = negdiag;
|
|
|
+ } else {
|
|
|
+ infoStr = infoStr + "," + negdiag;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ /* 相似度分数 */
|
|
|
+ double likeRate = jsonArray.getDoubleValue(1);
|
|
|
+ if (likeRate > 0.99) {
|
|
|
+ matchSum++;
|
|
|
+ if (StringUtils.isEmpty(infoStr)) {
|
|
|
+ infoStr = negdiag;
|
|
|
+ } else {
|
|
|
+ infoStr = infoStr + "," + negdiag;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (matchSum > 0) {
|
|
|
+ status.set("-1");
|
|
|
+ info.set(infoStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //疾病史
|
|
|
+ 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.contains(dgname)) {
|
|
|
+ pos_diags.add(dgname);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!neg_diags.contains(dgname)) {
|
|
|
+ neg_diags.add(dgname);
|
|
|
+ dgs.add(dgname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dgs;
|
|
|
+ }
|
|
|
+
|
|
|
+// //过敏史
|
|
|
+// private List<String> extract_Allergy(List<Allergy> allergys, List<String> pos_diags, List<String> neg_diags, String text) {
|
|
|
+// List<String> dgs = new ArrayList<>();
|
|
|
+// String content = text;
|
|
|
+// int allergyNum = 0;
|
|
|
+// for (Allergy dg : allergys) {
|
|
|
+// String dgname = dg.getName();
|
|
|
+// if (dg.getNegative() == null) {
|
|
|
+// if (!pos_diags.contains(dgname)) {
|
|
|
+// pos_diags.add(dgname);
|
|
|
+// }
|
|
|
+// if (dg.getAllergyFood() != null) {
|
|
|
+// allergyNum = 1;
|
|
|
+// }
|
|
|
+// if (dg.getAllergyMedicine() != null) {
|
|
|
+// allergyNum = 2;
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// int index = content.lastIndexOf(dgname);
|
|
|
+// text = content.substring(Math.max(0, index - 10), index);
|
|
|
+// if (allergyNum == 0 && !neg_diags.contains(dgname) && !text.contains("其他") && !text.contains("其它") && !text.contains("其余")) {
|
|
|
+// neg_diags.add(dgname);
|
|
|
+// dgs.add(dgname);
|
|
|
+// }
|
|
|
+// if (allergyNum == 1 && text.contains("食物") && !neg_diags.contains(dgname) && !text.contains("其他") && !text.contains("其它") && !text.contains("其余")) {
|
|
|
+// neg_diags.add(dgname);
|
|
|
+// dgs.add(dgname);
|
|
|
+// }
|
|
|
+// if (allergyNum == 2 && text.contains("药物") && !neg_diags.contains(dgname) && !text.contains("其他") && !text.contains("其它") && !text.contains("其余")) {
|
|
|
+// neg_diags.add(dgname);
|
|
|
+// dgs.add(dgname);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return dgs;
|
|
|
+// }
|
|
|
+
|
|
|
+ private boolean isContains(String diagName) {
|
|
|
+ for (String c : containList) {
|
|
|
+ if (diagName.contains(c)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isFilter(String diagName) {
|
|
|
+ for (String c : filterList) {
|
|
|
+ if (diagName.contains(c)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|