|
@@ -0,0 +1,242 @@
|
|
|
+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.kernel.util.CatalogueUtil;
|
|
|
+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.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.HashSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : BEH0011
|
|
|
+ * @Description : 初步诊断不完整
|
|
|
+ * 原逻辑 --初步诊断没有既往史里的慢性疾病
|
|
|
+ * 现逻辑 --检查现病史中一般情况之后的疾病名称,既往史中的疾病名称是否都在初步诊断里
|
|
|
+ * @Author : 楼辉荣
|
|
|
+ * @Date: 2020-03-06 17:28
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class BEH0011 extends QCCatalogue {
|
|
|
+ // @Autowired
|
|
|
+ // private SpecialStorageUtil specialStorageUtil;
|
|
|
+ @Autowired
|
|
|
+ ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
|
|
|
+
|
|
|
+ private List<String> containList = Arrays.asList("脑萎缩", "慢性", "纤颤", "高血压", "糖尿", "冠状", "冠心病", "支架", "起搏器", "房颤", "风湿");
|
|
|
+ private List<String> filterList = Arrays.asList("心脏病", "低血糖", "急性", ";");
|
|
|
+
|
|
|
+ public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
+ if (inputInfo.getBeHospitalizedDoc() == null) {
|
|
|
+ status.set("0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
|
|
|
+ String age = structureMap.get("年龄");
|
|
|
+ if (StringUtil.isNotBlank(age)) {
|
|
|
+ if (age.contains("月") || age.contains("天")) {
|
|
|
+ status.set("0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ age = age.replaceAll("岁", "");
|
|
|
+ try {
|
|
|
+ if (Integer.parseInt(age) < 10) {
|
|
|
+ status.set("0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println("BEH0011--解析age出错:" + "->" + age);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
|
|
|
+ DiagLabel initialDiagLabel = inputInfo.getBeHospitalizedDoc().getInitialDiagLabel();
|
|
|
+ /*补充诊断*/
|
|
|
+ DiagLabel suppleDiagLabel = inputInfo.getBeHospitalizedDoc().getSuppleDiagLabel();
|
|
|
+ PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
|
|
|
+ if (initialDiagLabel == null) {
|
|
|
+ status.set("0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<String> presentPastDiags = new HashSet<>();
|
|
|
+ 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())) {
|
|
|
+ presentPastDiags.add(presentDiag.getHospitalDiagName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* 取既往史中疾病名称 */
|
|
|
+ if (pastLabel != null && StringUtils.isNotEmpty(pastLabel.getText())) {
|
|
|
+ List<Diag> pastDiags = pastLabel.getDiags();
|
|
|
+ addDiagHospitalName(presentPastDiags, pastDiags);
|
|
|
+ } else { //结构化数据
|
|
|
+ List<Diag> pastDiags = new ArrayList<>();
|
|
|
+
|
|
|
+// Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
|
|
|
+ String a1 = structureMap.get("高血压");
|
|
|
+ if (StringUtils.isNotEmpty(a1) && !"否认".equals(a1)) {
|
|
|
+ Diag diag = new Diag();
|
|
|
+ diag.setName("高血压");
|
|
|
+ diag.setHospitalDiagName("高血压");
|
|
|
+ if (!isHave(presentPastDiags, "高血压")) {
|
|
|
+ pastDiags.add(diag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ a1 = structureMap.get("糖尿病");
|
|
|
+ if (StringUtils.isNotEmpty(a1) && !"否认".equals(a1)) {
|
|
|
+ Diag diag = new Diag();
|
|
|
+ diag.setName("糖尿病");
|
|
|
+ diag.setHospitalDiagName("糖尿病");
|
|
|
+ if (!isHave(presentPastDiags, "糖尿病")) {
|
|
|
+ pastDiags.add(diag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ addDiagHospitalName(presentPastDiags, pastDiags);
|
|
|
+ }
|
|
|
+ /* 取初步诊断中疾病名称 */
|
|
|
+ List<String> initDiags = new ArrayList<>();
|
|
|
+ List<Diag> initialDiagDiags = initialDiagLabel.getDiags();
|
|
|
+ addInitDiagHospitalName(initDiags, initialDiagDiags);
|
|
|
+ if(suppleDiagLabel !=null){
|
|
|
+ List<Diag> suppleDiagDiags = suppleDiagLabel.getDiags();
|
|
|
+ addInitDiagHospitalName(initDiags, suppleDiagDiags);
|
|
|
+ }
|
|
|
+ initDiags = initDiags.stream().distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ String infoStr = "";
|
|
|
+ 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.80) {
|
|
|
+ matchSum++;
|
|
|
+ } else {
|
|
|
+ infoStr = CatalogueUtil.concatInfo(infoStr, presentPastDiag);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ infoStr = CatalogueUtil.concatInfo(infoStr, presentPastDiag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ info.set(infoStr);
|
|
|
+ if (matchSum == presentPastDiags.size()) {
|
|
|
+ status.set("0");
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ if (initDiags.containsAll(presentPastDiags)) {
|
|
|
+ status.set("0");
|
|
|
+ }
|
|
|
+ */
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addDiagHospitalName(Set<String> presentPastDiag, List<Diag> pastDiags) {
|
|
|
+ for (Diag pastDiag : pastDiags) {
|
|
|
+ if (pastDiag.getNegative() != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isContains(pastDiag.getHospitalDiagName()) && !isFilter(pastDiag.getHospitalDiagName())) {
|
|
|
+ presentPastDiag.add(pastDiag.getHospitalDiagName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addInitDiagHospitalName(List<String> presentPastDiag, List<Diag> pastDiags) {
|
|
|
+ for (Diag pastDiag : pastDiags) {
|
|
|
+ if (pastDiag.getNegative() != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ presentPastDiag.add(pastDiag.getHospitalDiagName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isHave(Set<String> presentDiag, String diagName) {
|
|
|
+ for (String haveDiag : presentDiag) {
|
|
|
+ if (haveDiag.contains(diagName) || diagName.contains(haveDiag)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ /* 原逻辑
|
|
|
+ Map<String, Map<String, Object>> diagMap = specialStorageUtil.getJsonStringValue(KernelConstants.CONCEPT_DIAG_PROPERTY_MAP);
|
|
|
+ String initDiagText = CatalogueUtil.removeSpecialChar(initialDiagLabel.getText());
|
|
|
+ if (pastLabel.getDiags() != null) {
|
|
|
+ List<Diag> diags = pastLabel.getDiags().stream().filter(diag -> diag.getNegative() == null).collect(Collectors.toList());
|
|
|
+ List<String> initDiags = Arrays.asList(initDiagText.split(","));
|
|
|
+ if (diags.size() > 0) {
|
|
|
+ for (Diag diag : diags) {
|
|
|
+ Map<String, Object> map = (Map<String, Object>) diagMap.get(diag.getName());
|
|
|
+ if (map != null && map.size() > 0) {
|
|
|
+ String chronic = (String) map.get("chronic");//1是慢病
|
|
|
+ if ("1".equals(chronic) && !initDiags.contains(diag.getName())) {
|
|
|
+ if (StringUtils.isEmpty(info.get())) {
|
|
|
+ info.set(diag.getName());
|
|
|
+ } else {
|
|
|
+ info.set(info.get() + "," + diag.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(info.get())) {
|
|
|
+ status.set("0");
|
|
|
+ }
|
|
|
+ */
|
|
|
+}
|