|
@@ -0,0 +1,180 @@
|
|
|
+package com.lantone.qc.kernel.catalogue.operationdiscussion;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
|
|
|
+import com.lantone.qc.kernel.client.SimilarityServiceClient;
|
|
|
+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.doc.FirstPageRecordDoc;
|
|
|
+import com.lantone.qc.pub.model.doc.operation.OperationDiscussionDoc;
|
|
|
+import com.lantone.qc.pub.model.doc.operation.OperationDoc;
|
|
|
+import com.lantone.qc.pub.model.doc.operation.OperationRecordDoc;
|
|
|
+import com.lantone.qc.pub.model.entity.Annotation;
|
|
|
+import com.lantone.qc.pub.model.entity.Diag;
|
|
|
+import com.lantone.qc.pub.model.label.DiagLabel;
|
|
|
+import com.lantone.qc.pub.model.vo.SimilarityVo;
|
|
|
+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;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : OPE03322
|
|
|
+ * @Description : 入院记录或首页诊断为【胎膜早破】,手术记录中术后诊断无胎膜早破
|
|
|
+ * @Author : zhanghang
|
|
|
+ * @Date: 2022-04-13 13:54
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class OPE03322 extends QCCatalogue {
|
|
|
+ @Autowired
|
|
|
+ SimilarityServiceClient similarityServiceClient;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void start(InputInfo inputInfo, OutputInfo outputInfo) {
|
|
|
+ status.set("0");
|
|
|
+ List<String> diagListWords = Content.JBLB_TMZP;
|
|
|
+ //获取入院记录
|
|
|
+ BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
|
|
|
+ //获取病案首页
|
|
|
+ FirstPageRecordDoc firstPageRecordDoc = inputInfo.getFirstPageRecordDoc();
|
|
|
+ if (beHospitalizedDoc == null && firstPageRecordDoc == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //匹配疾病正则
|
|
|
+ String rex = Content.PDZZ_TMZP;
|
|
|
+ //创建存储能匹配疾病的集合
|
|
|
+ List<String> diagList = new ArrayList<>();
|
|
|
+ //入院记录不为空,获取其诊断信息
|
|
|
+ if (beHospitalizedDoc != null) {
|
|
|
+ //初步诊断
|
|
|
+ DiagLabel initialDiagLabel = beHospitalizedDoc.getInitialDiagLabel();
|
|
|
+ //修正诊断
|
|
|
+ DiagLabel revisedDiagLabel = beHospitalizedDoc.getRevisedDiagLabel();
|
|
|
+ //补充诊断
|
|
|
+ DiagLabel suppleDiagLabel = beHospitalizedDoc.getSuppleDiagLabel();
|
|
|
+ if (initialDiagLabel != null) {
|
|
|
+ List<Diag> diagLists = initialDiagLabel.getDiags();
|
|
|
+ if (ListUtil.isNotEmpty(diagLists)) {
|
|
|
+ diagLists.stream().filter(diag -> StringUtil.isNotEmpty(diag.getHospitalDiagName()) && (diagListWords.contains(diag.getHospitalDiagName()) ||
|
|
|
+ diag.getHospitalDiagName().matches(rex) || diag.getHospitalDiagName().contains("胎膜早破") )).forEach(diag ->
|
|
|
+ diagList.add(diag.getHospitalDiagName()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (revisedDiagLabel != null) {
|
|
|
+ List<Diag> diagLists = revisedDiagLabel.getDiags();
|
|
|
+ if (ListUtil.isNotEmpty(diagLists)) {
|
|
|
+ diagLists.stream().filter(diag -> StringUtil.isNotEmpty(diag.getHospitalDiagName()) && (diagListWords.contains(diag.getHospitalDiagName()) ||
|
|
|
+ diag.getHospitalDiagName().matches(rex) || diag.getHospitalDiagName().contains("胎膜早破"))).forEach(diag ->
|
|
|
+ diagList.add(diag.getHospitalDiagName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (suppleDiagLabel != null) {
|
|
|
+ List<Diag> diagLists = suppleDiagLabel.getDiags();
|
|
|
+ if (ListUtil.isNotEmpty(diagLists)) {
|
|
|
+ diagLists.stream().filter(diag -> StringUtil.isNotEmpty(diag.getHospitalDiagName()) && (diagListWords.contains(diag.getHospitalDiagName()) ||
|
|
|
+ diag.getHospitalDiagName().matches(rex) || diag.getHospitalDiagName().contains("胎膜早破"))).forEach(diag ->
|
|
|
+ diagList.add(diag.getHospitalDiagName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取病案首页疾病并判断
|
|
|
+ if (firstPageRecordDoc != null) {
|
|
|
+ //获取出院诊断
|
|
|
+ String leaveDiagStr = firstPageRecordDoc.getStructureMap().get("出院诊断");
|
|
|
+ if (StringUtil.isNotEmpty(leaveDiagStr)) {
|
|
|
+ List<Map<String, String>> leaveDiagList = (List<Map<String, String>>) JSONArray.parse(leaveDiagStr);
|
|
|
+ leaveDiagList.stream().filter(diagMap -> StringUtil.isNotEmpty(diagMap.get("诊断名称")) && (diagListWords.contains(diagMap.get("诊断名称")) ||
|
|
|
+ diagMap.get("诊断名称").matches(rex) || diagMap.get("诊断名称").contains("胎膜早破") )).forEach(diagMap ->
|
|
|
+ diagList.add(diagMap.get("诊断名称")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果疾病集合为空则直接返回
|
|
|
+ if (ListUtil.isEmpty(diagList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> diagCollectList = diagList.stream().distinct().collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(diagCollectList)) {
|
|
|
+ status.set("-1");
|
|
|
+ //获取手术记录
|
|
|
+ List<OperationDoc> operationDocs = inputInfo.getOperationDocs();
|
|
|
+ if (ListUtil.isEmpty(operationDocs)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (OperationDoc operationDoc : operationDocs) {
|
|
|
+ OperationRecordDoc operationRecordDoc = operationDoc.getOperationRecordDoc();
|
|
|
+ if (operationRecordDoc == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //获取术后诊断
|
|
|
+ Map<String, String> structureMap = operationRecordDoc.getStructureMap();
|
|
|
+ String operationDiagZ = structureMap.get("术中后诊断");
|
|
|
+ String operationDiagO = structureMap.get("术后诊断");
|
|
|
+ if (StringUtil.isEmpty(operationDiagZ) && StringUtil.isEmpty(operationDiagO)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (String diagCollectName : diagCollectList) {
|
|
|
+ if ((StringUtil.isNotEmpty(operationDiagZ) || StringUtil.isNotEmpty(operationDiagO)) && StringUtil.isNotEmpty(diagCollectName)) {
|
|
|
+ if (StringUtil.isNotEmpty(operationDiagZ)) {
|
|
|
+ if (getLikeRate(operationDiagZ, diagCollectName)) {
|
|
|
+ status.set("0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotEmpty(operationDiagO)) {
|
|
|
+ if (getLikeRate(operationDiagO, diagCollectName)) {
|
|
|
+ status.set("0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean getLikeRate(String text_1, String text_2) {
|
|
|
+ JSONArray similarContent = new JSONArray();
|
|
|
+ JSONObject detailContent = new JSONObject();
|
|
|
+ detailContent.put("text_1", text_1);
|
|
|
+ detailContent.put("text_2", text_2);
|
|
|
+ similarContent.add(detailContent);
|
|
|
+ //存储CRF完整所需结构数据
|
|
|
+ SimilarityVo similarityVo = new SimilarityVo();
|
|
|
+ similarityVo.setData(similarContent);
|
|
|
+ //获取CRF模型返回数据
|
|
|
+ JSONArray data = getAnnotation(similarityServiceClient, similarityVo).getData();
|
|
|
+ double likeRate = 0d;
|
|
|
+ if (data.size() > 0) {
|
|
|
+ JSONObject dataContent = data.getJSONObject(0);
|
|
|
+ likeRate = dataContent.getDoubleValue("like_rate");
|
|
|
+ }
|
|
|
+ if (likeRate > 0.9) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Annotation getAnnotation(SimilarityServiceClient similarityServiceClient, SimilarityVo similarityVo) {
|
|
|
+ Annotation annotation = new Annotation();
|
|
|
+ try {
|
|
|
+ String annotation_str = similarityServiceClient.getAnnotation(similarityVo);
|
|
|
+ annotation = JSON.parseObject(annotation_str, Annotation.class);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ return annotation;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|