Procházet zdrojové kódy

诊断依据导出添加校验列

kongwz před 3 roky
rodič
revize
63298d54fe

+ 5 - 2
src/main/java/com/diagbot/dto/ExportDiagnoseDTO.java

@@ -24,8 +24,6 @@ public class ExportDiagnoseDTO implements Serializable {
     private String orderNo = "";
     @Excel(name="规则", width = 50, orderNum = "30")
     private String rule = "";
-    @Excel(name="关联词", width = 25, orderNum = "35")
-    private String relation;
     @Excel(name="等于", width = 10, orderNum = "40")
     private String eq;
     @Excel(name="最大值", width = 10, orderNum = "50")
@@ -38,4 +36,9 @@ public class ExportDiagnoseDTO implements Serializable {
     private String maxSymbol;
     @Excel(name="单位", width = 10, orderNum = "90")
     private String minSymbol;
+    @Excel(name="关联词", width = 30, orderNum = "35")
+    private String relation;
+    @Excel(name="校验", width = 50, orderNum = "33")
+    private String check;
+
 }

+ 12 - 3
src/main/java/com/diagbot/enums/DiagnoseLexiconTypeEnum.java

@@ -19,14 +19,14 @@ public enum DiagnoseLexiconTypeEnum implements KeyedNamed {
     Disease(100, "F"),
     zsxbszz(900, "G"),
     jwzz(901, "H"),
-    Age(410,"I"),
+    Age(410, "I"),
     Group(117, "J"),
     Ctzz(902, "K"),
     Fjjgzz(903, "L"),
     // 旧新诊断依据类型对应
     SymptomTpye(1, "A:症状"),
     VitalResultTpye(2, "B:体格检查结果"),
-//    VitalTpye(104, "C"),
+    //    VitalTpye(104, "C"),
     LisSubNameTpye(3, "D:实验室检查子项目"),
     PacsResultTpye(4, "L:辅检结果正则"),
     DiseaseTpye(5, "F:疾病"),
@@ -59,12 +59,21 @@ public enum DiagnoseLexiconTypeEnum implements KeyedNamed {
     }
 
 
-
     public static String getName(int key) {
         DiagnoseLexiconTypeEnum item = getEnum(key);
         return item != null ? item.name : null;
     }
 
+    public static int getKey(String value) {
+        DiagnoseLexiconTypeEnum[] values = values();
+        for (DiagnoseLexiconTypeEnum d : values) {
+            if (d.name.equals(value)) {
+                return d.key;
+            }
+        }
+        return 1000;
+    }
+
 
     @Override
     public int getKey() {

+ 93 - 94
src/main/java/com/diagbot/facade/KlDiagnoseDetailFacade.java

@@ -5,29 +5,20 @@ import com.diagbot.dto.ExportDescDTO;
 import com.diagbot.dto.ExportDiagnoseDTO;
 import com.diagbot.dto.ExportDiagnoseNameDTO;
 import com.diagbot.entity.KlDiagnoseDetail;
+import com.diagbot.entity.KlLibraryInfo;
 import com.diagbot.enums.CommonEnum;
 import com.diagbot.enums.DiagnoseLexiconTypeEnum;
 import com.diagbot.enums.IsDeleteEnum;
-import com.diagbot.service.impl.KlDiagnoseDetailServiceImpl;
-import com.diagbot.util.BeanUtil;
-import com.diagbot.util.EntityUtil;
-import com.diagbot.util.ExcelUtils;
-import com.diagbot.util.ListUtil;
-import com.diagbot.util.ReflectUtil;
-import com.diagbot.util.RegexUtil;
-import com.diagbot.util.StringUtil;
+import com.diagbot.service.KlDiagnoseDetailService;
+import com.diagbot.service.KlLibraryInfoService;
+import com.diagbot.util.*;
 import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -40,17 +31,27 @@ import java.util.stream.Stream;
  * @since 2021-06-10
  */
 @Service
-public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
+public class KlDiagnoseDetailFacade {
+
+//    @Autowired
+//    KlDiagnoseDetailFacade klDiagnoseDetailFacade;
+
+
+    @Autowired
+    @Qualifier("klLibraryInfoServiceImpl")
+    private KlLibraryInfoService klLibraryInfoService;
+
 
     @Autowired
-    KlDiagnoseDetailFacade klDiagnoseDetailFacade;
+    @Qualifier("klDiagnoseDetailServiceImpl")
+    private KlDiagnoseDetailService klDiagnoseDetailService;
 
     /**
      * 导出诊断依据【初版】
      */
     public void exportDiagnose(HttpServletResponse response) {
         // 获取全部数据、分组
-        List<KlDiagnoseDetail> klDiagnoseDetailList = klDiagnoseDetailFacade.list(new QueryWrapper<KlDiagnoseDetail>()
+        List<KlDiagnoseDetail> klDiagnoseDetailList = klDiagnoseDetailService.list(new QueryWrapper<KlDiagnoseDetail>()
 //                .eq("dis_name", "急性化脓性扁桃体炎")
                 .eq("is_deleted", IsDeleteEnum.N.getKey()));
         Map<String, List<KlDiagnoseDetail>> diagnoseDetailMap = EntityUtil.makeEntityListMap(klDiagnoseDetailList, "disName");
@@ -109,104 +110,121 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
             List<KlDiagnoseDetail> datats = kd.getValue();
             Map<Integer, List<String>> typeCodeNewListMap = new HashMap<>();// 1 --> [1.0,1.1]
             Map<Integer, List<String>> exportDiagnoseDTOS = removeKlDiagnoseDetail(datats, typeCodeNewListMap);
-            List<ExportDiagnoseDTO> exportDiagnoseDTO= packageData(exportDiagnoseDTOS, datats, typeCodeNewListMap);
-            data.put(sheetName,exportDiagnoseDTO);
+            List<ExportDiagnoseDTO> exportDiagnoseDTO = packageData(exportDiagnoseDTOS, datats, typeCodeNewListMap);
+            data.put(sheetName, exportDiagnoseDTO);
         }
         return data;
     }
 
     /**
-     *
      * @param exportDiagnoseDTOS 各种类型的关联词
-     * @param datats 诊断依据
+     * @param datats             诊断依据
      * @param typeCodeNewListMap 各种类型的codes
      */
-    public List<ExportDiagnoseDTO> packageData(Map<Integer, List<String>> exportDiagnoseDTOS,List<KlDiagnoseDetail> datats,Map<Integer, List<String>> typeCodeNewListMap){
+    public List<ExportDiagnoseDTO> packageData(Map<Integer, List<String>> exportDiagnoseDTOS, List<KlDiagnoseDetail> datats, Map<Integer, List<String>> typeCodeNewListMap) {
         List<ExportDiagnoseDTO> eds = Lists.newArrayList();
         List<Integer> types = Lists.newArrayList(91, 92, 93);
-
+        List<Integer> tps = Stream.of(1, 2, 3).collect(Collectors.toList());
         Map<Integer, List<KlDiagnoseDetail>> typeDiagnoseDetails = EntityUtil.makeEntityListMap(datats, "type");
-        /*for (Map.Entry<Integer, List<String>> edd : exportDiagnoseDTOS.entrySet()) {
-            Integer type = edd.getKey();
-            List<KlDiagnoseDetail> klDiagnoseDetails = typeDiagnoseDetails.get(type);
-            List<String> relations = edd.getValue();
-            List<String> codes = typeCodeNewListMap.get(type);
-            String maxCode = codes.get(codes.size() - 1);
-            String[] maxCodeArray = maxCode.split("\\.");
-            Integer max = Integer.parseInt(maxCodeArray[1]);
-            for (String relation:relations) {
-                max += 1;
-                KlDiagnoseDetail klDiagnoseDetail = new KlDiagnoseDetail();
-                klDiagnoseDetail.setType(type);
-                klDiagnoseDetail.setCode(maxCodeArray[0]+"."+max);
-                klDiagnoseDetail.setStandard(relation);
-                klDiagnoseDetails.add(klDiagnoseDetail);
-                codes.add(maxCodeArray[0]+"."+max);
-            }
-
-        }*/
-        Map<String,List<String>> typeCodeMap = new HashMap<>();//A --> [1.0,1.1,1.2,1.3]
-        Map<String,String> oldNewCodeMap = new HashMap<>();//1.0 -->A0
+        Map<String, List<String>> typeCodeMap = new HashMap<>();//A --> [1.0,1.1,1.2,1.3]
+        Map<String, String> oldNewCodeMap = new HashMap<>();//1.0 -->A0
         for (Map.Entry<Integer, List<KlDiagnoseDetail>> tdd : typeDiagnoseDetails.entrySet()) {
             List<KlDiagnoseDetail> klDiagnoseDetails = tdd.getValue();
-            for (KlDiagnoseDetail kdl:klDiagnoseDetails) {
+            for (KlDiagnoseDetail kdl : klDiagnoseDetails) {
                 Integer type = kdl.getType();
                 String code = kdl.getCode();
                 String formula = kdl.getFormula();
                 String typeName = DiagnoseLexiconTypeEnum.getName(type);//A:症状
                 String relation = kdl.getRelation();
-
+                String standard = kdl.getStandard();
+                List<String> relationNames = Lists.newArrayList(standard.split(CommonEnum.getName(1)));
+                if(type == 3){
+                    relationNames.clear();
+                    relationNames.add(relation);
+                }
+                List<String> checks = Lists.newArrayList();
                 ExportDiagnoseDTO exportDiagnoseDTO = new ExportDiagnoseDTO();
                 BeanUtil.copyProperties(kdl, exportDiagnoseDTO);
+                if (tps.contains(type)) {
+                    String s = DiagnoseLexiconTypeEnum.getName(type).split("\\:")[0];
+                    int key = DiagnoseLexiconTypeEnum.getKey(s);
+                    for (String name : relationNames) {
+                        List<KlLibraryInfo> klLibraryInfos = klLibraryInfoService.list(new QueryWrapper<KlLibraryInfo>()
+                                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                                .eq("name", name)
+                                .eq("type_id", key));
+                        if (ListUtil.isEmpty(klLibraryInfos)) {
+                            checks.add(name + "->");
+                        } else {
+                            KlLibraryInfo klLibraryInfo = klLibraryInfos.get(0);
+                            Long conceptId = klLibraryInfo.getConceptId();
+                            if (klLibraryInfo.getIsConcept() == 0) {
+                                List<KlLibraryInfo> infos = klLibraryInfoService.list(new QueryWrapper<KlLibraryInfo>()
+                                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                                        .eq("is_concept", 1)
+                                        .eq("type_id", key)
+                                        .eq("concept_id", conceptId));
+                                if (ListUtil.isNotEmpty(infos)) {
+                                    checks.add(name + "->" + infos.get(0).getName());
+                                } else {
+                                    checks.add(name + "->");
+                                }
 
+                            }
+                        }
+                    }
+                }
+                if (ListUtil.isNotEmpty(checks)) {
+                    exportDiagnoseDTO.setCheck(String.join(CommonEnum.getName(1), checks));
+                }
                 if (!types.contains(type)) {
                     String tName = typeName.split(":")[1];//症状
                     String tType = typeName.split(":")[0];//A
                     String tCode = code.split("\\.")[1];
-                    if(typeCodeMap.containsKey(tType)){
+                    if (typeCodeMap.containsKey(tType)) {
                         List<String> codes = typeCodeMap.get(tType);
                         List<String> collect = codes.stream().map(z -> z.split("\\.")[1]).sorted().collect(Collectors.toList());
-                        if(collect.contains(tCode)){
-                            String maxCode = collect.get(collect.size()-1);
-                            tCode = String.valueOf(Integer.parseInt(maxCode)+1);
-                            codes.add(String.valueOf(type)+"."+tCode);
+                        if (collect.contains(tCode)) {
+                            String maxCode = collect.get(collect.size() - 1);
+                            tCode = String.valueOf(Integer.parseInt(maxCode) + 1);
+                            codes.add(String.valueOf(type) + "." + tCode);
 
-                        }else {
-                            codes.add(String.valueOf(type)+"."+tCode);
+                        } else {
+                            codes.add(String.valueOf(type) + "." + tCode);
                         }
-                        typeCodeMap.put(tType,codes);
-                    }else {
+                        typeCodeMap.put(tType, codes);
+                    } else {
                         List<String> codes = Lists.newArrayList();
-                        codes.add(String.valueOf(type)+"."+tCode);
-                        typeCodeMap.put(tType,codes);
+                        codes.add(String.valueOf(type) + "." + tCode);
+                        typeCodeMap.put(tType, codes);
                     }
                     ReflectUtil.setProperty(exportDiagnoseDTO, "type", tName);
-                    ReflectUtil.setProperty(exportDiagnoseDTO, "orderNo", tType+String.valueOf(tCode));
-                    oldNewCodeMap.put(code,tType+String.valueOf(tCode));
-                    if (code.startsWith("3.") ) {
+                    ReflectUtil.setProperty(exportDiagnoseDTO, "orderNo", tType + String.valueOf(tCode));
+                    oldNewCodeMap.put(code, tType + String.valueOf(tCode));
+                    if (code.startsWith("3.")) {
                         exportDiagnoseDTO.setRule(kdl.getRelation());
                         exportDiagnoseDTO.setRelation("");
                     } else {
                         exportDiagnoseDTO.setRule(kdl.getStandard());
                     }
-                    if(code.startsWith("4.")){
-                        exportDiagnoseDTO.setRule(relation.replaceAll("\\、","|"));
+                    if (code.startsWith("4.")) {
+                        exportDiagnoseDTO.setRule(relation.replaceAll("\\、", "|"));
                         exportDiagnoseDTO.setRelation(kdl.getStandard());
                     }
                     exportDiagnoseDTO.setEq(kdl.getMidResult());
-                    if(("G".equals(tType) || "H".equals(tType)) && StringUtil.isNotBlank(relation)){
-                        exportDiagnoseDTO.setRule(kdl.getStandard()+"|"+kdl.getRelation().replaceAll("\\、","|"));
+                    if (("G".equals(tType) || "H".equals(tType)) && StringUtil.isNotBlank(relation)) {
+                        exportDiagnoseDTO.setRule(kdl.getStandard() + "|" + kdl.getRelation().replaceAll("\\、", "|"));
                         exportDiagnoseDTO.setRelation("");
                     }
-                }else {
+                } else {
                     ReflectUtil.setProperty(exportDiagnoseDTO, "type", typeName);
-                    for (Map.Entry<String,String> typeq:oldNewCodeMap.entrySet()){
+                    for (Map.Entry<String, String> typeq : oldNewCodeMap.entrySet()) {
                         String oldCode = typeq.getKey();
                         String newCode = typeq.getValue();
-                        formula = formula.replace(oldCode,newCode);
+                        formula = formula.replace(oldCode, newCode);
                     }
-                    exportDiagnoseDTO.setRule(formula.replaceAll("/","、")
-                            .replaceAll("\\(","[").replaceAll("\\)","]"));
+                    exportDiagnoseDTO.setRule(formula.replaceAll("/", "、")
+                            .replaceAll("\\(", "[").replaceAll("\\)", "]"));
                 }
 
                 eds.add(exportDiagnoseDTO);
@@ -221,7 +239,7 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
      * @param diagnoseDetails
      * @return
      */
-    public  List<ExportDiagnoseNameDTO> getCatalogue(Map<String, List<ExportDiagnoseDTO>> diagnoseDetails) {
+    public List<ExportDiagnoseNameDTO> getCatalogue(Map<String, List<ExportDiagnoseDTO>> diagnoseDetails) {
         List<ExportDiagnoseNameDTO> exportDiagnoseNameDTOList = Lists.newArrayList();
         for (String key : diagnoseDetails.keySet()) {
             ExportDiagnoseNameDTO exportDiagnoseNameDTO = new ExportDiagnoseNameDTO();
@@ -237,14 +255,11 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
      * @param klDiagnoseDetails
      */
     public Map<Integer, List<String>> removeKlDiagnoseDetail(List<KlDiagnoseDetail> klDiagnoseDetails, Map<Integer, List<String>> typeCodeNewListMap) {
-
         Map<Integer, List<String>> typeRelationNamesMap = new HashMap<>();// 1 --> [症状1,症状2]
-
         //获取所有公式
         List<String> allFormula = getAllFormula(klDiagnoseDetails);
         //获取公式中的所有编码
         List<String> regexData = getCodes(allFormula);
-
         //遍历病历
         List<Integer> types = Stream.of(1, 2, 6).collect(Collectors.toList());//症状、体征、病史有关联词的把关联词添加到规则里
         Iterator<KlDiagnoseDetail> iterator = klDiagnoseDetails.iterator();
@@ -258,29 +273,13 @@ public class KlDiagnoseDetailFacade extends KlDiagnoseDetailServiceImpl {
                 iterator.remove();
             } else {
                 if (StringUtil.isNotBlank(relation) && types.contains(type)) {
+                    List<String> checks = Lists.newArrayList();
                     List<String> relationNames = Lists.newArrayList(relation.split("\\、"));
-                    relationNames.add(0,standard);
-                    next.setStandard(String.join(CommonEnum.getName(1),relationNames));
+                    relationNames.add(0, standard);
+                    next.setStandard(String.join(CommonEnum.getName(1), relationNames));
                     next.setRelation("");
-                    /*if (typeRelationNamesMap.containsKey(type)) {
-                        List<String> contionNames = typeRelationNamesMap.get(type);
-                        contionNames.addAll(relationNames);
-                        typeRelationNamesMap.put(type, contionNames);
-                    } else {
-                        typeRelationNamesMap.put(type, relationNames);
-                    }*/
                 }
-                /*if (StringUtil.isNotBlank(code)) {
-                    if (typeCodeNewListMap.containsKey(type)) {
-                        List<String> codes = typeCodeNewListMap.get(type);
-                        codes.add(code);
-                        typeCodeNewListMap.put(type, codes);
-                    } else {
-                        List<String> codes = Lists.newArrayList();
-                        codes.add(code);
-                        typeCodeNewListMap.put(type, codes);
-                    }
-                }*/
+
             }
         }
         return typeRelationNamesMap;