Переглянути джерело

添加规则:异常化验未记录、异常检查未记录

huj 5 роки тому
батько
коміт
20d5065787

+ 156 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03070.java

@@ -0,0 +1,156 @@
+package com.lantone.qc.kernel.catalogue.threelevelward;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.LisDoc;
+import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+/**
+ * @author HUJING
+ * @create 2020-08-17 15:29
+ * @desc 异常化验未记录
+ **/
+@Component
+public class THR03070 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        List<LisDoc> lisDocs = inputInfo.getLisDocs();
+        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
+        if (lisDocs.size() == 0 || threeLevelWardDocs.size() == 0) {
+            return;
+        }
+        //异常数据列表
+        List<String> abnormal = Lists.newArrayList();
+        for (LisDoc lisDoc : lisDocs) {
+            double resultValue = -1, max = -1, min = -1;
+            Map<String, String> structureMap = lisDoc.getStructureMap();
+            String itemName = structureMap.get("报告名称");
+            String result = structureMap.get("检验结果");
+            String reference = structureMap.get("参考值");
+            if (StringUtil.isBlank(itemName) || StringUtil.isBlank(result) || StringUtil.isBlank(reference)) {
+                continue;
+            }
+            itemName = itemName.split("=")[1];
+            //1.化验结果是阳性时,直接把该化验名称放入异常数据列表中
+            if (result.contains("阳")) {
+                abnormal.add(itemName);
+                continue;
+            }
+            //2.化验结果为阴性,或化验结果中不包含数字,跳过该条化验结果
+            if (result.contains("阴") || !CatalogueUtil.numberExist(result)) {
+                continue;
+            }
+            try {
+                resultValue = Double.parseDouble(result);
+            } catch (Exception e) {
+                System.out.println("THR03070--解析result出错:" + itemName + "->" + result);
+            }
+            if (resultValue < 0) {
+                continue;
+            }
+            //3.化验正常值在一个范围内,以“-”分割,最小值最大值返回都扩大10%,再与化验结果比较,在这范围之外,把该化验名称放入异常数据列表中
+            if (reference.contains("-")) {
+                try {
+                    String[] minMax = reference.split("-");
+                    min = Double.parseDouble(getNumber(minMax[0])) * 0.85;        //最小值范围缩小10%
+                    String maxNumber = getNumber(minMax[1]);
+                    if (StringUtil.isNotBlank(maxNumber)) {
+                        max = Double.parseDouble(maxNumber) * 1.15;    //最大值范围扩大10%
+                    }
+                    //化验结果在正常范围之外(返回扩大10%),把该化验名称放入异常数据列表中
+                    if (min >= 0 && max >= 0 && (resultValue < min || resultValue > max)) {
+                        abnormal.add(itemName);
+                    }
+                } catch (Exception e) {
+                    System.out.println("THR03070--3.出异常");
+                }
+            }
+            //4.化验正常值比某个值小,但该化验结果比该值大,把该化验名称放入异常数据列表中
+            else if (reference.contains("<")) {
+                try {
+                    String maxNumber = getNumber(reference);
+                    if (StringUtil.isNotBlank(maxNumber)) {
+                        max = Double.parseDouble(maxNumber);
+                    }
+                    if (resultValue > max) {
+                        abnormal.add(itemName);
+                    }
+                } catch (Exception e) {
+                    System.out.println("THR03070--4.出异常");
+                }
+            }
+            //5.化验正常值比某个值大,但该化验结果比该值小,把该化验名称放入异常数据列表中
+            else if (reference.contains(">")) {
+                try {
+                    String maxNumber = getNumber(reference);
+                    if (StringUtil.isNotBlank(maxNumber)) {
+                        min = Double.parseDouble(maxNumber);
+                    }
+                    if (resultValue < min) {
+                        abnormal.add(itemName);
+                    }
+                } catch (Exception e) {
+                    System.out.println("THR03070--5.出异常");
+                }
+            }
+        }
+
+        Map<String, Integer> abnormalCount = Maps.newHashMap();
+        abnormal = abnormal.stream().map(x -> {
+            if (x.contains("[")) {
+                x = x.substring(0, x.indexOf("["));
+            }
+            if (x.contains("(")) {
+                x = x.substring(0, x.indexOf("("));
+            }
+            x = x.replaceAll("[^\\u4e00-\\u9fa5]", "");
+            return x;
+        }).distinct().collect(Collectors.toList());
+        abnormal.forEach(i -> abnormalCount.put(i, 0));
+
+        List<ThreeLevelWardDoc> allDoctorWradDocs = threeLevelWardDocs.get(0).getAllDoctorWradDocs();
+        for (ThreeLevelWardDoc doc : allDoctorWradDocs) {
+            Map<String, String> structureMap = doc.getStructureMap();
+            String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("体检", "病情记录"));
+            for (String lis : abnormal) {
+                if (content.contains(lis)) {
+                    abnormalCount.put(lis, abnormalCount.get(lis) + 1);
+                }
+            }
+        }
+
+        List<String> abnormalMiss = Lists.newArrayList();
+        for (Map.Entry<String, Integer> lis : abnormalCount.entrySet()) {
+            if (lis.getValue() == 0) {
+                abnormalMiss.add(lis.getKey());
+            }
+        }
+        if (abnormalMiss.size() > 0) {
+            status.set("-1");
+            info.set(abnormalMiss.toString().replaceAll("[\\[\\]]", ""));
+        }
+    }
+
+    public String getNumber(String content) {
+        String group = "";
+        String compile = "([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9]|0)";
+        Pattern p = Pattern.compile(compile);
+        Matcher matcher = p.matcher(content);
+        if (matcher.find()) {
+            group = matcher.group(0);
+        }
+        return group;
+    }
+}

+ 110 - 0
kernel/src/main/java/com/lantone/qc/kernel/catalogue/threelevelward/THR03071.java

@@ -0,0 +1,110 @@
+package com.lantone.qc.kernel.catalogue.threelevelward;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.lantone.qc.kernel.catalogue.QCCatalogue;
+import com.lantone.qc.kernel.util.CatalogueUtil;
+import com.lantone.qc.pub.model.InputInfo;
+import com.lantone.qc.pub.model.OutputInfo;
+import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
+import com.lantone.qc.pub.model.doc.LeaveHospitalDoc;
+import com.lantone.qc.pub.model.doc.PacsDoc;
+import com.lantone.qc.pub.model.doc.ThreeLevelWardDoc;
+import com.lantone.qc.pub.util.StringUtil;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author HUJING
+ * @create 2020-08-17 15:29
+ * @desc 异常检查未记录
+ **/
+@Component
+public class THR03071 extends QCCatalogue {
+    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
+        status.set("0");
+        List<PacsDoc> pacsDocs = inputInfo.getPacsDocs();
+        List<ThreeLevelWardDoc> threeLevelWardDocs = inputInfo.getThreeLevelWardDocs();
+        FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
+        LeaveHospitalDoc leaveHospitalDoc = inputInfo.getLeaveHospitalDoc();
+        if (pacsDocs.size() == 0) {
+            return;
+        }
+        //辅检数据
+        Map<String, List<String>> pacsMap = Maps.newHashMap();
+        Map<String, Integer> pacsCount = Maps.newHashMap();
+        String splitRegex = "[;;]";
+        for (PacsDoc pacsDoc : pacsDocs) {
+            Map<String, String> structureMap = pacsDoc.getStructureMap();
+            String itemName = structureMap.get("报告名称");
+            String itemDiag = structureMap.get("检查结果诊断");
+            if (StringUtil.isBlank(itemName) || StringUtil.isBlank(itemDiag)) {
+                continue;
+            }
+            if (itemName.contains("检查")) {
+                itemName = itemName.substring(0, itemName.indexOf("检查") + 2);
+            }
+            String[] itemDiags = itemDiag.split(splitRegex);
+            List<String> itemDiagList = Lists.newArrayList(itemDiags);
+            if (pacsMap.containsKey(itemName)) {
+                pacsMap.get(itemName).addAll(itemDiagList);
+            } else {
+                pacsMap.put(itemName, itemDiagList);
+            }
+        }
+        //检查项目对应数据初始化
+        pacsMap.keySet().stream().forEach(i -> pacsCount.put(i, 0));
+
+        if (threeLevelWardDocs.size() > 0) {
+            for (ThreeLevelWardDoc doc : threeLevelWardDocs.get(0).getAllDoctorWradDocs()) {
+                Map<String, String> structureMap = doc.getStructureMap();
+                String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("体检", "病情记录"));
+                findPacs(pacsMap, pacsCount, content);
+            }
+        }
+
+        if (firstCourseRecordDoc != null) {
+            Map<String, String> structureMap = firstCourseRecordDoc.getStructureMap();
+            String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("病例特点"));
+            findPacs(pacsMap, pacsCount, content);
+        }
+
+        if (leaveHospitalDoc != null) {
+            Map<String, String> structureMap = leaveHospitalDoc.getStructureMap();
+            String content = CatalogueUtil.structureMapJoin(structureMap, Lists.newArrayList("诊治经过"));
+            findPacs(pacsMap, pacsCount, content);
+        }
+
+        List<String> pacsMiss = Lists.newArrayList();
+        for (Map.Entry<String, Integer> pacs : pacsCount.entrySet()) {
+            if (pacs.getValue() == 0) {
+                pacsMiss.add(pacs.getKey());
+            }
+        }
+
+        if (pacsMiss.size() > 0) {
+            status.set("-1");
+            info.set(pacsMiss.toString().replaceAll("[\\[\\]]", ""));
+        }
+    }
+
+    /**
+     * 从文本中查找辅检对应的诊断信息,只要找到一个能对上,pacsCount对应辅检项目的数量就+1
+     *
+     * @param pacsMap   key:辅检项目  value:List[诊断信息]
+     * @param pacsCount key:辅检项目    value:匹配的数量
+     * @param content   文本
+     */
+    private void findPacs(Map<String, List<String>> pacsMap, Map<String, Integer> pacsCount, String content) {
+        for (Map.Entry<String, List<String>> map : pacsMap.entrySet()) {
+            for (String itemDiag : map.getValue()) {
+                if (content.contains(itemDiag)) {
+                    pacsCount.put(map.getKey(), pacsCount.get(map.getKey()) + 1);
+                    break;
+                }
+            }
+        }
+    }
+}