|
@@ -1,15 +1,17 @@
|
|
package com.lantone.qc.kernel.catalogue.leavehospital;
|
|
package com.lantone.qc.kernel.catalogue.leavehospital;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
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.Content;
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
import com.lantone.qc.pub.model.InputInfo;
|
|
import com.lantone.qc.pub.model.OutputInfo;
|
|
import com.lantone.qc.pub.model.OutputInfo;
|
|
-import com.lantone.qc.pub.model.doc.DeathRecordDoc;
|
|
|
|
-import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
|
|
|
|
import com.lantone.qc.pub.model.entity.Diag;
|
|
import com.lantone.qc.pub.model.entity.Diag;
|
|
-import com.lantone.qc.pub.model.label.DiagLabel;
|
|
|
|
import com.lantone.qc.pub.util.ListUtil;
|
|
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 org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
@@ -23,50 +25,53 @@ import java.util.Map;
|
|
*/
|
|
*/
|
|
@Component
|
|
@Component
|
|
public class LEA0514 extends QCCatalogue {
|
|
public class LEA0514 extends QCCatalogue {
|
|
- @Override
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ ChiefPresentSimilarityServiceClient chiefPresentSimilarityServiceClient;
|
|
|
|
+
|
|
|
|
+ List<String> diags = Lists.newArrayList("2型糖尿病");
|
|
|
|
+
|
|
public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
status.set("0");
|
|
status.set("0");
|
|
- LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
|
|
|
|
- if (leaveHospitalDoc == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- DeathRecordDoc deathRecordDoc = inputInfo.getDeathRecordDoc();
|
|
|
|
- if (deathRecordDoc == null || deathRecordDoc.getText() == null) {
|
|
|
|
- if (inputInfo.getFirstPageRecordDoc() != null) {
|
|
|
|
- DiagLabel leaveDiagLabel = leaveHospitalDoc.getLeaveDiagLabel();
|
|
|
|
- Map<String, Object> firstPageRecordStructureExtMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
|
|
|
|
- List<Map<String, String>> dischargeDiagStructure = (List<Map<String, String>>) firstPageRecordStructureExtMap.get(Content.dischargeDiag);
|
|
|
|
- if (ListUtil.isEmpty(dischargeDiagStructure)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- //首页出院诊断
|
|
|
|
- List<String> dischargeDiags = new ArrayList<>();
|
|
|
|
- for (Map<String, String> dischargeDiagMap : dischargeDiagStructure) {
|
|
|
|
- String diagnoseName = dischargeDiagMap.get(Content.diagnoseName);
|
|
|
|
- if (CatalogueUtil.isEmpty(diagnoseName)) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- dischargeDiags.add(diagnoseName);
|
|
|
|
- }
|
|
|
|
- if (leaveDiagLabel != null) {
|
|
|
|
- //出院记录出院诊断
|
|
|
|
- List<Diag> leaveDiags = leaveDiagLabel.getDiags();
|
|
|
|
- List<String> leaveDiagStrList = getDiagList(leaveDiags);
|
|
|
|
- if (!ListUtil.equals(leaveDiagStrList, dischargeDiags)) {
|
|
|
|
- status.set("-1");
|
|
|
|
- }
|
|
|
|
|
|
+ if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getLeaveHospitalDoc() != null) {
|
|
|
|
+ Map<String, Object> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
|
|
|
|
+ //病案首页出院诊断
|
|
|
|
+ List<Map<String, String>> dischargeDiag = (List) firstpageStructureMap.get(Content.dischargeDiag);
|
|
|
|
+ //出院小结诊断
|
|
|
|
+ List<Diag> leaveDiags = null;
|
|
|
|
+ if (inputInfo.getLeaveHospitalDoc().getLeaveDiagLabel() != null) {
|
|
|
|
+ leaveDiags = inputInfo.getLeaveHospitalDoc().getLeaveDiagLabel().getDiags();
|
|
|
|
+ }
|
|
|
|
+ if (ListUtil.isEmpty(dischargeDiag) || ListUtil.isEmpty(leaveDiags)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String firstpageleaveDiag = "";
|
|
|
|
+ for (Map<String, String> diag : dischargeDiag) {
|
|
|
|
+ String diagCategory = diag.get("诊断类别");
|
|
|
|
+ if (StringUtil.isNotBlank(diagCategory) && "主要诊断".equals(diagCategory)) {
|
|
|
|
+ firstpageleaveDiag = diag.get(Content.diagnoseName);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private List<String> getDiagList(List<Diag> diags) {
|
|
|
|
- List<String> diagList = new ArrayList<>();
|
|
|
|
- for (Diag diag : diags) {
|
|
|
|
- if (diag.getHospitalDiagName() != null) {
|
|
|
|
- diagList.add(diag.getHospitalDiagName());
|
|
|
|
|
|
+ String leaveDiag = leaveDiags.get(0).getHospitalDiagName();
|
|
|
|
+ //判断是否有2型糖尿病这种病如果没有,把疾病前的数字去掉
|
|
|
|
+ if (!diags.contains(leaveDiag)) {
|
|
|
|
+ leaveDiag = leaveDiag.replaceAll("^[0-9]", "");
|
|
|
|
+ }
|
|
|
|
+ /* 存放出院小结主要诊断,为了调用疾病相似度接口,特意存成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");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return diagList;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|