|
@@ -1,13 +1,17 @@
|
|
|
package com.lantone.qc.kernel.catalogue.firstpagerecord;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
|
+import com.lantone.qc.kernel.client.SimilarityServiceClient;
|
|
|
+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.doc.BeHospitalizedDoc;
|
|
|
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.StringUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -22,51 +26,78 @@ import java.util.Map;
|
|
|
*/
|
|
|
@Component
|
|
|
public class FIRP0178 extends QCCatalogue {
|
|
|
+ @Autowired
|
|
|
+ SimilarityServiceClient similarityServiceClient;
|
|
|
+
|
|
|
public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
status.set("0");
|
|
|
- if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getFirstPageRecordDoc().getStructureMap() != null
|
|
|
- && inputInfo.getBeHospitalizedDoc() != null) {
|
|
|
+ if (inputInfo.getFirstPageRecordDoc() != null && inputInfo.getLeaveHospitalDoc() != null) {
|
|
|
Map<String, Object> firstpageStructureMap = inputInfo.getFirstPageRecordDoc().getStructureExtMap();
|
|
|
List<Map<String, String>> dischargeDiag = (List) firstpageStructureMap.get(Content.dischargeDiag);
|
|
|
- if (ListUtil.isEmpty(dischargeDiag)){
|
|
|
+ if (ListUtil.isEmpty(dischargeDiag)) {
|
|
|
return;
|
|
|
}
|
|
|
+ /* 病案首页出院小结诊断 除去主诊断*/
|
|
|
+ List<String> firstpageLeaveDiags = getFirstPageDiag(dischargeDiag);
|
|
|
|
|
|
- BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
|
|
|
- List<String> beHospitalDiag = new ArrayList<>();//收集入院记录中初步诊断、修正诊断、其他诊断所有诊断
|
|
|
- if (beHospitalizedDoc.getInitialDiagLabel() != null) {
|
|
|
- putDiagToList(beHospitalizedDoc.getInitialDiagLabel().getDiags(),beHospitalDiag); //初步诊断
|
|
|
- }
|
|
|
- if (beHospitalizedDoc.getRevisedDiagLabel() != null){
|
|
|
- putDiagToList(beHospitalizedDoc.getRevisedDiagLabel().getDiags(),beHospitalDiag); //修正诊断
|
|
|
- }
|
|
|
- if (beHospitalizedDoc.getSuppleDiagLabel() != null){
|
|
|
- putDiagToList(beHospitalizedDoc.getSuppleDiagLabel().getDiags(), beHospitalDiag); //其他诊断
|
|
|
+ DiagLabel leaveDiagLabel = inputInfo.getLeaveHospitalDoc().getLeaveDiagLabel();
|
|
|
+ if (leaveDiagLabel == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ List<Diag> leaveDiags = leaveDiagLabel.getDiags();
|
|
|
+ List<String> leaveDiagsStr = putDiagToList(leaveDiags);
|
|
|
|
|
|
- if (beHospitalDiag.size() > 0 && dischargeDiag.size() < 2) {
|
|
|
+ /*
|
|
|
+ if (firstpageLeaveDiags.size() != leaveDiagsStr.size()) {
|
|
|
status.set("-1");
|
|
|
return;
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
- List<String> firstpageDiag = new ArrayList<>();
|
|
|
- for (int i = 1; i < dischargeDiag.size(); i++) {
|
|
|
- String diagnoseName = dischargeDiag.get(i).get(Content.diagnoseName);
|
|
|
- if (StringUtil.isBlank(diagnoseName)) {
|
|
|
- continue;
|
|
|
+ /* 目前相似度算法是针对文本的,在此处并不适用,如 截瘫 - 高位截瘫,相似度为0 */
|
|
|
+ ModelAI modelAI = new ModelAI();
|
|
|
+ int matchDiagSum = 0;
|
|
|
+ for (String firstpageLeaveDiag : firstpageLeaveDiags) {
|
|
|
+ for (String leaveDiag : leaveDiagsStr) {
|
|
|
+ if (firstpageLeaveDiag.equals(leaveDiag) || leaveDiag.contains(firstpageLeaveDiag)) {
|
|
|
+ matchDiagSum++;
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ JSONArray similarContent = new JSONArray();
|
|
|
+ modelAI.putContent(similarContent, firstpageLeaveDiag, leaveDiag);
|
|
|
+ double likeRate = modelAI.loadSimilarAI(similarContent, similarityServiceClient);
|
|
|
+ if (likeRate > 0.9) {
|
|
|
+ matchDiagSum++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- firstpageDiag.add(diagnoseName);
|
|
|
}
|
|
|
|
|
|
- if (!ListUtil.equals(firstpageDiag,beHospitalDiag)){
|
|
|
+ if (matchDiagSum != firstpageLeaveDiags.size()) {
|
|
|
status.set("-1");
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> getFirstPageDiag(List<Map<String, String>> dischargeDiag) {
|
|
|
+ List<String> firstpageDiag = new ArrayList<>();
|
|
|
+ for (int i = 1; i < dischargeDiag.size(); i++) {
|
|
|
+ String diagnoseName = dischargeDiag.get(i).get(Content.diagnoseName);
|
|
|
+ if (StringUtil.isBlank(diagnoseName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ firstpageDiag.add(diagnoseName);
|
|
|
}
|
|
|
+ return firstpageDiag;
|
|
|
}
|
|
|
|
|
|
- private void putDiagToList(List<Diag> diagList, List<String> beHospitalDiag){
|
|
|
- for (Diag diag:diagList) {
|
|
|
- beHospitalDiag.add(diag.getName());
|
|
|
+ private List<String> putDiagToList(List<Diag> diagList) {
|
|
|
+ List<String> diags = new ArrayList<>();
|
|
|
+ for (Diag diag : diagList) {
|
|
|
+ diags.add(diag.getHospitalDiagName());
|
|
|
}
|
|
|
+ return diags;
|
|
|
}
|
|
|
}
|