|
@@ -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) {
|