Browse Source

结构转换

zhoutg 4 years ago
parent
commit
a1d3837b0a

+ 2 - 0
src/main/java/com/diagbot/dto/BillMsg.java

@@ -20,4 +20,6 @@ public class BillMsg {
     private String compareName;
     // 匹配标准名称
     private String compareStandName;
+    // 禁忌类型
+    private String type;
 }

+ 63 - 0
src/main/java/com/diagbot/enums/NeoEnum.java

@@ -0,0 +1,63 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author zhoutg
+ * @Description: 图谱禁忌类型
+ * @date 2018年10月11日 下午3:33:22
+ */
+
+public enum NeoEnum implements KeyedNamed {
+
+    gender(1, "禁忌性别"),
+    ageNeoDTO(2, "禁忌年龄"),
+    clinicfindings(3, "禁忌临床表现"),
+    oralmeds(4, "禁忌服用药品"),
+    allergicmeds(5, "禁忌过敏药品"),
+    operations(6, "禁忌手术"),
+    procedures(7, "禁忌操作"),
+    lis(8, "禁忌实验室检查"),
+    pacs(9, "禁忌辅助检查"),
+    disease(10, "禁忌疾病"),
+    group(11, "禁用人群"),
+    conflictmeds(12, "配伍禁忌");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    NeoEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static NeoEnum getEnum(int key) {
+        for (NeoEnum item : NeoEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        NeoEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 1 - 2
src/main/java/com/diagbot/enums/StandConvertEnum.java

@@ -17,8 +17,7 @@ public enum StandConvertEnum implements KeyedNamed {
     drug(4, "药品"),
     clinical(5, "临床表现"),
     operation(6, "手术"),
-    vital(7, "体征")
-    ;
+    vital(7, "体征");
 
     @Setter
     private int key;

+ 9 - 0
src/main/java/com/diagbot/model/ai/process/EntityProcessClinic.java

@@ -104,6 +104,7 @@ public class EntityProcessClinic extends EntityProcess {
             for (Lemma lemma : cureLemmas) {
                 Treat treat = new Treat();
                 treat.setName(lemma.getText());
+                treat.setStandName(lemma.getText()); // 先赋值,之后有同义词转换再替换
                 treats.add(treat);
             }
             presentLabel.setTreats(treats);
@@ -113,6 +114,10 @@ public class EntityProcessClinic extends EntityProcess {
             for (Lemma lemma : cureLemmas_me) {
                 Medicine medicine = new Medicine();
                 medicine.setName(lemma.getText());
+                medicine.setStandName(lemma.getText()); // 先赋值,之后有同义词转换再替换
+                if (lemma.isHaveChildren()) {
+                    medicine.setNegative(findNegative(lemma));//阴性
+                }
                 medicines.add(medicine);
             }
             presentLabel.setMedicines(medicines);
@@ -122,6 +127,10 @@ public class EntityProcessClinic extends EntityProcess {
             for (Lemma lemma : operationLemmas) {
                 Operation operation = new Operation();
                 operation.setName(lemma.getText());
+                operation.setStandName(lemma.getText()); // 先赋值,之后有同义词转换再替换
+                if (lemma.isHaveChildren()) {
+                    operation.setNegative(findNegative(lemma));//阴性
+                }
                 presentLabel.add(presentLabel.getOperations(), operation);
             }
 

+ 4 - 0
src/main/java/com/diagbot/model/entity/Medicine.java

@@ -1,10 +1,14 @@
 package com.diagbot.model.entity;
 
+import lombok.Data;
+
 /**
  * @ClassName : Medicine
  * @Description : 药物
  * @Author : 楼辉荣
  * @Date: 2020-03-03 18:32
  */
+@Data
 public class Medicine extends General {
+    private Negative negative;
 }

+ 31 - 92
src/main/java/com/diagbot/process/BillProcess.java

@@ -8,6 +8,7 @@ import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.NeoEnum;
 import com.diagbot.model.entity.Clinical;
 import com.diagbot.model.entity.Diag;
 import com.diagbot.model.entity.Medicine;
@@ -21,7 +22,6 @@ import com.diagbot.rule.LisRule;
 import com.diagbot.rule.PacsRule;
 import com.diagbot.rule.SexRule;
 import com.diagbot.util.BeanUtil;
-import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import org.springframework.stereotype.Component;
 
@@ -60,6 +60,25 @@ public class BillProcess {
                 nodeNeoDTO.setName("红细胞压积");
                 nodeNeoDTO.setVal("阳性");
                 billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
+
+                NodeNeoDTO opereat = new NodeNeoDTO();
+                opereat.setName("胸腔镜下左下肺叶切除术");
+                billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat);
+                NodeNeoDTO opereat2 = new NodeNeoDTO();
+                opereat2.setName("区域淋巴结清扫术");
+                billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat2);
+
+                NodeNeoDTO drug = new NodeNeoDTO();
+                drug.setName("拜阿司匹林");
+                billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug);
+                NodeNeoDTO drug2 = new NodeNeoDTO();
+                drug2.setName("美多芭");
+                billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug2);
+
+                NodeNeoDTO drug3 = new NodeNeoDTO();
+                drug3.setName("泰舒达");
+                billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
+
             }
             // 测试数据结束
 
@@ -94,113 +113,33 @@ public class BillProcess {
         List<BillMsg> billMsgList = new ArrayList<>();
         for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
             // 性别
-            SexRule.compareSexWithBill(wordCrfDTO, bill, billMsgList);
+            SexRule.compareSexWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.gender.getName());
+
+            // 年龄
+            AgeRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
 
             // 诊断
-            DiagRule.compareDiseaseWithBill(bill.getDisease(), diags, bill, billMsgList);
+            DiagRule.compareDiseaseWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
 
             //化验
-            LisRule.compareLisWithBill(lis, bill, billMsgList);
+            LisRule.compareLisWithBill(lis, bill, billMsgList, NeoEnum.lis.getName());
 
              //辅检
-            PacsRule.comparePacsWithBill(bill.getPacs(), pacs, bill, billMsgList);
+            PacsRule.comparePacsWithBill(bill.getPacs(), pacs, bill, billMsgList, NeoEnum.pacs.getName());
 
             //临床表现
-            DiagRule.compareDiseaseWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList);
+            DiagRule.compareDiseaseWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
 
             //手术
-            DiagRule.compareDiseaseWithBill(bill.getOperations(), operations, bill, billMsgList);
+            DiagRule.compareDiseaseWithBill(bill.getOperations(), operations, bill, billMsgList, NeoEnum.operations.getName());
 
             //禁忌过敏药品
-            DiagRule.compareDiseaseWithBill(bill.getAllergicmeds(), medicines, bill, billMsgList);
+            DiagRule.compareDiseaseWithBill(bill.getAllergicmeds(), medicines, bill, billMsgList, NeoEnum.allergicmeds.getName());
 
             //服用药品
-            DiagRule.compareDiseaseWithBill(bill.getOralmeds(), medicines, bill, billMsgList);
-
-            // 年龄
-            AgeRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList);
+            DiagRule.compareDiseaseWithBill(bill.getOralmeds(), medicines, bill, billMsgList, NeoEnum.oralmeds.getName());
 
         }
         indicationDTO.setBillMsgList(billMsgList);
     }
-    //
-    // /**
-    //  * 化验规则处理
-    //  *
-    //  * @param billNeoDTOList
-    //  * @param wordCrfDTO
-    //  * @param indicationDTO
-    //  */
-    // public void processBillWithLis(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
-    //
-    // }
-    //
-    // /**
-    //  * 辅检规则处理
-    //  *
-    //  * @param billNeoDTOList
-    //  * @param wordCrfDTO
-    //  * @param indicationDTO
-    //  */
-    // public void processBillWithPacs(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
-    //
-    // }
-    //
-    // /**
-    //  * 药品规则处理
-    //  *
-    //  * @param billNeoDTOList
-    //  * @param wordCrfDTO
-    //  * @param indicationDTO
-    //  */
-    // public void processBillWithDrug(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
-    //     DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
-    //     ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
-    //     PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
-    //     List<Diag> diags = new ArrayList<>();
-    //     List<Clinical> clinicals = new ArrayList<>();
-    //     if(diagLabel != null){
-    //         diags = diagLabel.getDiags();
-    //     }
-    //     if(chiefLabel != null && ListUtil.isNotEmpty(chiefLabel.getClinicals())){
-    //         clinicals.addAll(chiefLabel.getClinicals());
-    //     }
-    //     // 现病史临床表现数据先不用
-    //     if(presentLabel != null && ListUtil.isNotEmpty(presentLabel.getClinicals())){
-    //         clinicals.addAll(presentLabel.getClinicals());
-    //     }
-    //     List<Lis> lis = wordCrfDTO.getLis();
-    //     List<Pacs> pacs = wordCrfDTO.getPacs();
-    //
-    //     List<BillMsg> drugBill = new ArrayList<>();
-    //     for (BillNeoDTO bill : billNeoDTOList) {
-    //         DrugBillNeoDTO drug =  bill.getDrugBillNeoDTO();
-    //         // 性别
-    //         BillMsg sexMsg = SexRule.compareSexWithBill(drug.getGender(), wordCrfDTO, bill.getName());
-    //         CoreUtil.addBeanToList(drugBill, sexMsg);
-    //
-    //         // 诊断
-    //         BillMsg billMsg_disease = DiagRule.compareDiseaseWithBill(drug.getDisease(), diags, bill.getName());
-    //         CoreUtil.addBeanToList(drugBill, billMsg_disease);
-    //
-    //         // //化验
-    //         // BillMsg lisMsg = LisPacsRule.compareLisPacsWithBill(drug.getLis(), lis, bill.getName());
-    //         // CoreUtil.addBeanToList(drugBill, lisMsg);
-    //         //
-    //         // //辅检
-    //         // BillMsg pacsMsg = LisPacsRule.compareLisPacsWithBill(drug.getPacs(), pacs, bill.getName());
-    //         // CoreUtil.addBeanToList(drugBill, pacsMsg);
-    //         //
-    //         // //临床表现
-    //         // BillMsg clinicalMsg = DiagRule.compareDiseaseWithBill(drug.getClinicfindings(), clinicals, bill.getName());
-    //         // CoreUtil.addBeanToList(drugBill, clinicalMsg);
-    //
-    //         // 年龄
-    //         BillMsg ageMsg = AgeRule.compareAgeWithBill(drug.getAgeNeoDTO(), wordCrfDTO, bill.getName());
-    //         CoreUtil.addBeanToList(drugBill, ageMsg);
-    //
-    //     }
-    //     indicationDTO.setDrugBill(drugBill);
-    // }
-
 }

+ 2 - 2
src/main/java/com/diagbot/rule/AgeRule.java

@@ -22,7 +22,7 @@ public class AgeRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareAgeWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList) {
+    public static void compareAgeWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         NodeNeoDTO ageNeoDTO = billNeoMaxDTO.getAgeNeoDTO();
         Boolean flag = false;
         if (ageNeoDTO != null && wordCrfDTO.getAge() != null) {
@@ -32,7 +32,7 @@ public class AgeRule {
         if (flag) {
             String message = CoreUtil.getStrMsgWithRange(ageNeoDTO, "年龄", String.valueOf(wordCrfDTO.getAge()));
             BillMsg billMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                    message, message);
+                    message, message, type);
             billMsgList.add(billMsg);
         }
     }

+ 2 - 5
src/main/java/com/diagbot/rule/DiagRule.java

@@ -6,11 +6,8 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.model.entity.Negative;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
-import com.diagbot.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
-import org.neo4j.ogm.annotation.NodeEntity;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,7 +26,7 @@ public class DiagRule {
      * @param inputLises
      * @return
      */
-    public static <T> void compareDiseaseWithBill(List<NodeNeoDTO> drugLises, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList) {
+    public static <T> void compareDiseaseWithBill(List<NodeNeoDTO> drugLises, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         Map<String,String> old_stand = new HashMap<>();
         if(ListUtil.isNotEmpty(drugLises) && ListUtil.isNotEmpty(inputLises)){
             List<String> dl = drugLises.stream().map(x -> x.getName()).collect(Collectors.toList());
@@ -45,7 +42,7 @@ public class DiagRule {
             }
             if(old_stand.size() > 0){
                 for (Map.Entry<String,String> d:old_stand.entrySet()) {
-                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),billNeoMaxDTO.getOrderStandName(),d.getKey(),d.getValue());
+                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),billNeoMaxDTO.getOrderStandName(),d.getKey(),d.getValue(), type);
                     billMsgList.add(commonBillMsg);
                 }
             }

+ 2 - 2
src/main/java/com/diagbot/rule/LisRule.java

@@ -24,7 +24,7 @@ public class LisRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareLisWithBill(List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList) {
+    public static void compareLisWithBill(List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         List<NodeNeoDTO> neoList = billNeoMaxDTO.getLis();
         if(ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLis)){
             for (NodeNeoDTO neo : neoList) {
@@ -48,7 +48,7 @@ public class LisRule {
                         }
                         if (flag) {
                             BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),
-                                    billNeoMaxDTO.getOrderStandName(), message, message);
+                                    billNeoMaxDTO.getOrderStandName(), message, message, type);
                             billMsgList.add(commonBillMsg);
                         }
                     }

+ 4 - 9
src/main/java/com/diagbot/rule/PacsRule.java

@@ -6,7 +6,7 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import org.apache.commons.lang3.StringUtils;
-import java.util.ArrayList;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -25,8 +25,7 @@ public class PacsRule {
      * @param inputLis
      * @return
      */
-    public static <T> void comparePacsWithBill(List<NodeNeoDTO> drugLis, List<T> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList) {
-
+    public static <T> void comparePacsWithBill(List<NodeNeoDTO> drugLis, List<T> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         Map<String,String> old_stand = new HashMap<>();
         if(ListUtil.isNotEmpty(drugLis) && ListUtil.isNotEmpty(inputLis)){
             List<String> dl = drugLis.stream().map(x -> x.getName()).collect(Collectors.toList());
@@ -39,14 +38,10 @@ public class PacsRule {
             }
         }
         if(old_stand.size() > 0){
-            for (Map.Entry<String,String> d: old_stand.entrySet()
-                 ) {
-                BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),billNeoMaxDTO.getOrderStandName(),d.getKey(),d.getValue());
+            for (Map.Entry<String,String> d: old_stand.entrySet()) {
+                BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),billNeoMaxDTO.getOrderStandName(),d.getKey(),d.getValue(), type);
                 billMsgList.add(commonBillMsg);
             }
-
-
-
         }
     }
 }

+ 7 - 5
src/main/java/com/diagbot/rule/SexRule.java

@@ -23,7 +23,7 @@ public class SexRule {
      * @param billNeoMaxDTO
      * @return
      */
-    public static void compareSexWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList) {
+    public static void compareSexWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
         NodeNeoDTO nodeNeoDTO = billNeoMaxDTO.getGender();
         if (nodeNeoDTO != null && StringUtil.isNotBlank(nodeNeoDTO.getName()) && wordCrfDTO.getSex() != null) {
             String sex = nodeNeoDTO.getName();
@@ -35,11 +35,13 @@ public class SexRule {
             }
             if (sex.equals(sexStr)) {
                 if ("男".equals(sexStr)) {
-                    billMsgList.add(CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            "男性", "男性"));
+                    BillMsg billMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
+                            "男性", "男性", type);
+                    billMsgList.add(billMsg);
                 } else if ("女".equals(sexStr)) {
-                    billMsgList.add(CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            "女性", "女性"));
+                    BillMsg billMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
+                            "女性", "女性", type);
+                    billMsgList.add(billMsg);
                 }
             }
         }

+ 23 - 0
src/main/java/com/diagbot/util/CoreUtil.java

@@ -250,6 +250,29 @@ public class CoreUtil {
         return billMsg;
     }
 
+    /**
+     * 开单合理性通用提示信息
+     *
+     * @param orderName 原开单项
+     * @param orderStandName 标准开单项
+     * @param compareName 匹配名称
+     * @param compareStandName 匹配标准名称
+     * @param type 类型
+     * @return
+     */
+    public static BillMsg getCommonBillMsg(String orderName, String orderStandName, String compareName,
+                                           String compareStandName, String type) {
+        BillMsg billMsg = new BillMsg();
+        String msg = String.format(compareName + ",不宜开%s", orderName);
+        billMsg.setMsg(msg);
+        billMsg.setCompareName(compareName);
+        billMsg.setCompareStandName(compareStandName);
+        billMsg.setOrderName(orderName);
+        billMsg.setOrderStandName(orderStandName);
+        billMsg.setType(type);
+        return billMsg;
+    }
+
     /**
      * 开单合理性固定提示信息
      *