Kaynağa Gözat

恩泽解析修改

rengb 4 yıl önce
ebeveyn
işleme
58bb8a8310

+ 199 - 1
kernel/src/main/java/com/lantone/qc/kernel/analysis/EZAnalysis.java

@@ -5,9 +5,25 @@ import com.google.common.collect.Maps;
 import com.lantone.qc.dbanaly.util.SpecialStorageUtil;
 import com.lantone.qc.kernel.client.CRFServiceClient;
 import com.lantone.qc.kernel.client.SimilarityServiceClient;
+import com.lantone.qc.kernel.structure.ai.BeHospitalizedAI;
+import com.lantone.qc.pub.model.InputInfo;
 import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
+import com.lantone.qc.pub.model.doc.MedicalRecordInfoDoc;
+import com.lantone.qc.pub.model.entity.BloodTransfusion;
+import com.lantone.qc.pub.model.entity.Diag;
+import com.lantone.qc.pub.model.entity.DiagInfectious;
+import com.lantone.qc.pub.model.entity.General;
+import com.lantone.qc.pub.model.entity.GeneralDesc;
+import com.lantone.qc.pub.model.entity.Operation;
+import com.lantone.qc.pub.model.entity.Vaccinate;
+import com.lantone.qc.pub.model.entity.Wound;
+import com.lantone.qc.pub.model.label.PastLabel;
+import com.lantone.qc.pub.model.label.PresentLabel;
 import com.lantone.qc.pub.model.vo.EzAnalysisVO;
 import com.lantone.qc.pub.res.EzAnalysisDTO;
+import com.lantone.qc.pub.util.FileUtil;
+import com.lantone.qc.pub.util.ListUtil;
+import com.lantone.qc.pub.util.StringUtil;
 import com.lantone.qc.trans.beilun.util.ez.EzXmlAnalysis;
 import com.lantone.qc.trans.comsis.OrdinaryAssistant;
 import lombok.extern.slf4j.Slf4j;
@@ -33,11 +49,22 @@ public class EZAnalysis {
     @Autowired
     SimilarityServiceClient similarityServiceClient;
 
+    public static String bom(String result) {
+        if (null != result && !"".equals(result)) {
+            if (result.indexOf("<") != -1 && result.lastIndexOf(">") != -1 && result.lastIndexOf(">") > result.indexOf("<")) {
+                result = result.substring(result.indexOf("<"), result.lastIndexOf(">") + 1);
+            }
+        }
+        return result;
+    }
+
     public List<EzAnalysisDTO> anlysis(EzAnalysisVO ezAnalysisVO) throws Exception {
         List<EzAnalysisDTO> details = Lists.newArrayList();
+//        ezAnalysisVO.setXml(bom(FileUtil.fileRead("C:\\Users\\Administrator\\Desktop\\恩泽\\入院记录\\小儿外科入院记录(男)\\1677273_小儿外科入院记录(男).txt")));
         Map<String, String> sourceMap = EzXmlAnalysis.analysisEk(ezAnalysisVO.getDeptName(), ezAnalysisVO.getXml());
+        InputInfo inputInfo = ai(sourceMap);
+        structHandle(inputInfo, sourceMap);
         Map<String, String> structMap = OrdinaryAssistant.mapKeyContrast(sourceMap, keyContrasts);
-        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
         Map<String, String> keyMaps = getKmaps();
         kys.forEach(ky -> {
             EzAnalysisDTO ezAnalysisDTO = new EzAnalysisDTO();
@@ -49,6 +76,177 @@ public class EZAnalysis {
         return details;
     }
 
+    private void structHandle(InputInfo inputInfo, Map<String, String> structMap) {
+        diagsHandle(inputInfo, structMap);
+        diagInfectiouseHandle(inputInfo, structMap);
+        vaccinateHandle(inputInfo, structMap);
+        operationHandle(inputInfo, structMap);
+        bloodTransfusionHandle(inputInfo, structMap);
+        generalDescHandle(inputInfo, structMap);
+    }
+
+    private void diagsHandle(InputInfo inputInfo, Map<String, String> map) {
+        StringBuffer sbf = new StringBuffer();
+        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
+        List<Diag> diags = pastLabel.getDiags();
+        List<Wound> wounds = pastLabel.getWounds();
+        if (ListUtil.isNotEmpty(diags)) {
+            diags.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getHospitalDiagName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
+                    .forEach(i -> {
+                        sbf.append(i.getHospitalDiagName()).append(",");
+                    });
+            diags.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getHospitalDiagName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
+                    .forEach(i -> {
+                        sbf.append(i.getNegative().getName()).append(i.getHospitalDiagName()).append(",");
+                    });
+        }
+        if (ListUtil.isNotEmpty(wounds)) {
+            wounds.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
+                    .forEach(i -> {
+                        sbf.append(i.getName()).append(",");
+                    });
+            wounds.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
+                    .forEach(i -> {
+                        sbf.append(i.getNegative().getName()).append(i.getName()).append(",");
+                    });
+        }
+        map.put("疾病史(含外伤)", sbf.toString());
+    }
+
+    private void diagInfectiouseHandle(InputInfo inputInfo, Map<String, String> map) {
+        StringBuffer sbf = new StringBuffer();
+        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
+        List<DiagInfectious> diagInfectiouses = pastLabel.getDiagInfectiouses();
+        if (ListUtil.isNotEmpty(diagInfectiouses)) {
+            diagInfectiouses.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
+                    .forEach(i -> {
+                        sbf.append(i.getName()).append(",");
+                    });
+            diagInfectiouses.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
+                    .forEach(i -> {
+                        sbf.append(i.getNegative().getName()).append(i.getName()).append(",");
+                    });
+        }
+        map.put("患者传染性标志", sbf.toString());
+        map.put("传染病史", sbf.toString());
+    }
+
+    private void vaccinateHandle(InputInfo inputInfo, Map<String, String> map) {
+        StringBuffer sbf = new StringBuffer();
+        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
+        List<Vaccinate> vaccinates = pastLabel.getVaccinates();
+        if (ListUtil.isNotEmpty(vaccinates)) {
+            vaccinates.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
+                    .forEach(i -> {
+                        sbf.append(i.getName()).append(",");
+                    });
+            vaccinates.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
+                    .forEach(i -> {
+                        sbf.append(i.getNegative().getName()).append(i.getName()).append(",");
+                    });
+        }
+        map.put("预防接种史", sbf.toString());
+    }
+
+    private void operationHandle(InputInfo inputInfo, Map<String, String> map) {
+        StringBuffer sbf = new StringBuffer();
+        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
+        List<Operation> operations = pastLabel.getOperations();
+        if (ListUtil.isNotEmpty(operations)) {
+            operations.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
+                    .forEach(i -> {
+                        sbf.append(i.getName()).append(",");
+                    });
+            operations.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
+                    .forEach(i -> {
+                        sbf.append(i.getNegative().getName()).append(i.getName()).append(",");
+                    });
+        }
+        map.put("手术史", sbf.toString());
+    }
+
+    private void bloodTransfusionHandle(InputInfo inputInfo, Map<String, String> map) {
+        StringBuffer sbf = new StringBuffer();
+        PastLabel pastLabel = inputInfo.getBeHospitalizedDoc().getPastLabel();
+        List<BloodTransfusion> bloodTransfusions = pastLabel.getBloodTransfusions();
+        if (ListUtil.isNotEmpty(bloodTransfusions)) {
+            bloodTransfusions.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && (i.getNegative() == null || StringUtil.isBlank(i.getNegative().getName())))
+                    .forEach(i -> {
+                        sbf.append(i.getName()).append(",");
+                    });
+            bloodTransfusions.stream()
+                    .filter(i -> i != null && StringUtil.isNotBlank(i.getName()) && i.getNegative() != null && StringUtil.isNotBlank(i.getNegative().getName()))
+                    .forEach(i -> {
+                        sbf.append(i.getNegative().getName()).append(i.getName()).append(",");
+                    });
+        }
+        map.put("输血史", sbf.toString());
+    }
+
+    private void generalDescHandle(InputInfo inputInfo, Map<String, String> map) {
+        StringBuffer sbf = new StringBuffer();
+        PresentLabel presentLabel = inputInfo.getBeHospitalizedDoc().getPresentLabel();
+        List<String> list = Lists.newArrayList();
+        List<String> neList = Lists.newArrayList();
+        List<General> gens = presentLabel.getGens();
+        List<GeneralDesc> generals = presentLabel.getGenerals();
+        if (ListUtil.isNotEmpty(generals)) {
+            int index = -1;
+            for (GeneralDesc general : generals) {
+                index++;
+                if (general == null || StringUtil.isBlank(general.getName())) {
+                    continue;
+                }
+                String genstr = "";
+                if (index < gens.size()) {
+                    genstr = gens.get(index).getName();
+                }
+                if (general.getNegative() != null && StringUtil.isNotBlank(general.getNegative().getName())) {
+                    neList.add(general.getNegative().getName() + general.getName() + genstr);
+                } else {
+                    list.add(general.getName() + genstr);
+                }
+            }
+        }
+        list.forEach(i -> {
+            sbf.append(i).append(",");
+        });
+        neList.forEach(i -> {
+            sbf.append(i).append(",");
+        });
+        map.put("一般健康状况标志", sbf.toString());
+    }
+
+    private InputInfo ai(Map<String, String> sourceMap) {
+        InputInfo inputInfo = new InputInfo();
+        inputInfo.setUseCrfCache(false);
+        MedicalRecordInfoDoc medicalRecordInfoDoc = new MedicalRecordInfoDoc();
+        medicalRecordInfoDoc.getStructureMap().put("behospitalCode", System.currentTimeMillis() + "");
+        inputInfo.setMedicalRecordInfoDoc(medicalRecordInfoDoc);
+        BeHospitalizedDoc beHospitalizedDoc = new BeHospitalizedDoc();
+        PresentLabel presentLabel = new PresentLabel();
+        presentLabel.setText(sourceMap.get("现病史"));
+        beHospitalizedDoc.setPresentLabel(presentLabel);
+        PastLabel pastLabel = new PastLabel();
+        pastLabel.setText(sourceMap.get("既往史"));
+        beHospitalizedDoc.setPastLabel(pastLabel);
+        inputInfo.setBeHospitalizedDoc(beHospitalizedDoc);
+        BeHospitalizedAI beHospitalizedAI = new BeHospitalizedAI();
+        beHospitalizedAI.medrec(inputInfo, crfServiceClient);
+        return inputInfo;
+    }
+
     private List<String> keyContrasts = Lists.newArrayList(
             "体温=体格检查--体温(℃)",
             "脉搏=体格检查--脉率(次/min)",