浏览代码

定值转化为枚举

gaodm 4 年之前
父节点
当前提交
35678a87c3

+ 56 - 0
src/main/java/com/diagbot/enums/StaticTypeEnum.java

@@ -0,0 +1,56 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description: 静态信息类型
+ * @author: gaodm
+ * @time: 2020/9/3 20:16
+ */
+public enum StaticTypeEnum implements KeyedNamed {
+
+    DIS(1, "医保ICD_10疾病"),
+    DRUG(2, "药品通用名"),
+    LISMIX(3, "实验室检查套餐"),
+    LIS(4, "实验室检查"),
+    PACS(5, "辅助检查"),
+    OPT(6, "手术和操作");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    StaticTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static StaticTypeEnum getEnum(int key) {
+        for (StaticTypeEnum item : StaticTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        StaticTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 15 - 14
src/main/java/com/diagbot/facade/RetrievalFacade.java

@@ -11,6 +11,7 @@ import com.diagbot.entity.node.LISPack;
 import com.diagbot.entity.node.Medicine;
 import com.diagbot.entity.node.Operation;
 import com.diagbot.entity.node.PACS;
+import com.diagbot.enums.StaticTypeEnum;
 import com.diagbot.repository.DeptNode;
 import com.diagbot.repository.DeptRepository;
 import com.diagbot.repository.ICDDiseaseNode;
@@ -208,8 +209,8 @@ public class RetrievalFacade {
         for (ICDDisease icdDisease : icdDiseaseList) {
             StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
             staticDTO.setName(icdDisease.getName());
-            staticDTO.setType(1);
-            staticDTO.setTypeName("医保ICD_10疾病");
+            staticDTO.setType(StaticTypeEnum.DIS.getKey());
+            staticDTO.setTypeName(StaticTypeEnum.DIS.getName());
             disRetList.add(staticDTO);
         }
         //TODO 药品
@@ -217,8 +218,8 @@ public class RetrievalFacade {
         for (Medicine medicine : medicineList) {
             StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
             staticDTO.setName(medicine.getName());
-            staticDTO.setType(2);
-            staticDTO.setTypeName("药品通用名");
+            staticDTO.setType(StaticTypeEnum.DRUG.getKey());
+            staticDTO.setTypeName(StaticTypeEnum.DRUG.getName());
             drugRetList.add(staticDTO);
         }
         //TODO 检验套餐
@@ -226,8 +227,8 @@ public class RetrievalFacade {
         for (LISPack lisPack : lisPackList) {
             StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
             staticDTO.setName(lisPack.getName());
-            staticDTO.setType(3);
-            staticDTO.setTypeName("实验室检查套餐");
+            staticDTO.setType(StaticTypeEnum.LISMIX.getKey());
+            staticDTO.setTypeName(StaticTypeEnum.LISMIX.getName());
             lisPackRetList.add(staticDTO);
         }
         //TODO 检验明细关联出检验套餐
@@ -238,8 +239,8 @@ public class RetrievalFacade {
                     StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
                     staticDTO.setRetrievalName(lis.getName());
                     staticDTO.setName(lisPack.getName());
-                    staticDTO.setType(3);
-                    staticDTO.setTypeName("实验室检查套餐");
+                    staticDTO.setType(StaticTypeEnum.LISMIX.getKey());
+                    staticDTO.setTypeName(StaticTypeEnum.LISMIX.getName());
                     lisPackRelatecLisRetList.add(staticDTO);
                 }
             }
@@ -249,8 +250,8 @@ public class RetrievalFacade {
         for (LIS lis : lisList) {
             StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
             staticDTO.setName(lis.getName());
-            staticDTO.setType(4);
-            staticDTO.setTypeName("实验室检查");
+            staticDTO.setType(StaticTypeEnum.LIS.getKey());
+            staticDTO.setTypeName(StaticTypeEnum.LIS.getName());
             lisRetList.add(staticDTO);
         }
         //TODO 检查
@@ -258,8 +259,8 @@ public class RetrievalFacade {
         for (PACS pacs : pacsList) {
             StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
             staticDTO.setName(pacs.getName());
-            staticDTO.setType(5);
-            staticDTO.setTypeName("辅助检查");
+            staticDTO.setType(StaticTypeEnum.PACS.getKey());
+            staticDTO.setTypeName(StaticTypeEnum.PACS.getName());
             pacsRetList.add(staticDTO);
         }
         //TODO 手术和操作
@@ -267,8 +268,8 @@ public class RetrievalFacade {
         for (Operation operation : operationList) {
             StaticKnowledgeIndexDTO staticDTO = new StaticKnowledgeIndexDTO();
             staticDTO.setName(operation.getName());
-            staticDTO.setType(6);
-            staticDTO.setTypeName("手术和操作");
+            staticDTO.setType(StaticTypeEnum.OPT.getKey());
+            staticDTO.setTypeName(StaticTypeEnum.OPT.getName());
             operationRetList.add(staticDTO);
         }
         //0-全部、1-诊断、2-药品、3-检验套餐、4-检验明细、5-检查、6-手术和操作