فهرست منبع

体征开单合理性提示

zhoutg 4 سال پیش
والد
کامیت
c0ec4e4e9c

+ 24 - 7
src/main/java/com/diagbot/aggregate/IndicationAggregate.java

@@ -10,6 +10,7 @@ import com.diagbot.vo.IndicationPushVO;
 import io.github.lvyahui8.spring.annotation.DataConsumer;
 import io.github.lvyahui8.spring.annotation.DataProvider;
 import io.github.lvyahui8.spring.annotation.InvokeParameter;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -21,6 +22,7 @@ import java.util.Map;
  * @time: 2019/10/16 13:37
  */
 @Component
+@Slf4j
 public class IndicationAggregate {
 
     @Autowired
@@ -69,8 +71,13 @@ public class IndicationAggregate {
         IndicationDTO res = new IndicationDTO();
         // 开单合理性
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("2")) {
-            billFacade.billFac(indicationPushVO, wordCrfDTO, res);
-            CoreUtil.getDebugStr(start, "开单规则耗时", res.getDebug());
+            try {
+                billFacade.billFac(indicationPushVO, wordCrfDTO, res);
+                CoreUtil.getDebugStr(start, "开单规则耗时", res.getDebug());
+            } catch (Exception e) {
+                log.error("【开单规则出错】" + e.getMessage());
+                CoreUtil.getDebugStr("【开单规则出错】", e.getMessage(), res.getDebug());
+            }
             return res;
         }
         return null;
@@ -90,8 +97,13 @@ public class IndicationAggregate {
         IndicationDTO res = new IndicationDTO();
         // 高风险提示
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("3")) {
-            highRiskFacade.highRiskFac(indicationPushVO, wordCrfDTO, res);
-            CoreUtil.getDebugStr(start, "高风险提示耗时", res.getDebug());
+            try {
+                highRiskFacade.highRiskFac(indicationPushVO, wordCrfDTO, res);
+                CoreUtil.getDebugStr(start, "高风险提示耗时", res.getDebug());
+            } catch (Exception e) {
+                log.error("【高风险提示出错】" + e.getMessage());
+                CoreUtil.getDebugStr("【高风险提示出错】", e.getMessage(), res.getDebug());
+            }
             return res;
         }
         return null;
@@ -111,9 +123,14 @@ public class IndicationAggregate {
         IndicationDTO res = new IndicationDTO();
         // 危急值提示
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("1")) {
-            criticalFacade.criticalFac(indicationPushVO, wordCrfDTO, res);
-            CoreUtil.getDebugStr(start, "危急值提示耗时", res.getDebug());
-            return res;
+            try {
+                criticalFacade.criticalFac(indicationPushVO, wordCrfDTO, res);
+                CoreUtil.getDebugStr(start, "危急值提示耗时", res.getDebug());
+                return res;
+            } catch (Exception e) {
+                log.error("【危急值提示出错】" + e.getMessage());
+                CoreUtil.getDebugStr("【危急值提示出错】", e.getMessage(), res.getDebug());
+            }
         }
         return null;
     }

+ 1 - 1
src/main/java/com/diagbot/enums/TypeEnum.java

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

+ 27 - 1
src/main/java/com/diagbot/facade/BillFacade.java

@@ -3,16 +3,20 @@ package com.diagbot.facade;
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.biz.push.entity.Pacs;
+import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.process.BillProcess;
+import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.BillNeoVO;
 import com.diagbot.vo.IndicationPushVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -42,10 +46,32 @@ public class BillFacade {
 
         // 规则处理
         billProcess.process(billNeoDTOList, wordCrfDTO, res);
-        // System.out.println(res);
+
+        // 结果去重处理
+        dealMsg(res);
     }
 
 
+    /**
+     * 提示信息去重
+     * @param indicationDTO
+     */
+    public void dealMsg(IndicationDTO indicationDTO) {
+        List<BillMsg> billMsgList = indicationDTO.getBillMsgList();
+        if (ListUtil.isNotEmpty(billMsgList)) {
+            List<String> msgList = new ArrayList<>();
+            Iterator<BillMsg> it = billMsgList.iterator();
+            while (it.hasNext()) {
+                String msg = it.next().getMsg();
+                if (msgList.contains(msg)) {
+                    it.remove();
+                } else {
+                    msgList.add(msg);
+                }
+            }
+        }
+    }
+
     public BillNeoVO fillBillNeo(WordCrfDTO wordCrfDTO) {
         BillNeoVO billNeoVO = new BillNeoVO();
 

+ 32 - 12
src/main/java/com/diagbot/model/ai/BeHospitalizedAI.java

@@ -16,6 +16,7 @@ import com.diagbot.vo.SearchData;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -606,23 +607,42 @@ public class BeHospitalizedAI extends ModelAI {
             } else if ("R".equals(vi.getName().toUpperCase())) {
                 vi.setStandName("呼吸");
             } else if ("血压".equals(vi.getName()) || "BP".equals(vi.getName().toUpperCase())) {
+                String bpName = vi.getPd().getName();
                 Pattern pattern = Pattern.compile("\\d+/\\d+"); // 示例:血压80/44mmHg
-                Matcher matcher = pattern.matcher(vi.getPd().getName());
+                Matcher matcher = pattern.matcher(bpName);
+
                 if (matcher.find()) {
                     String val = matcher.group();
+                    vi.getPd().setValue(val);  // 重新赋值血压的数值
+                    vi.getPd().setUnit(bpName.substring(bpName.indexOf(val) + 1));   // 重新赋值血压的单位
+
                     String[] bp = val.split("/");
 
-                    PD dbp = new PD(); // 舒张压
-                    dbp.setValue(bp[0]);
-                    dbp.setName("舒张压");
-                    dbp.setStandName("舒张压");
-                    vitalLabel.setDbp(dbp);
-
-                    PD sbp = new PD(); // 收缩压
-                    sbp.setValue(bp[1]);
-                    sbp.setName("收缩压");
-                    sbp.setStandName("收缩压");
-                    vitalLabel.setSbp(sbp);
+                    List<Usual> usualList = new ArrayList<>();
+                    // PD dbp = new PD(); // 舒张压
+                    // dbp.setValue(bp[0]);
+                    // dbp.setName("舒张压");
+                    // dbp.setStandName("舒张压");
+                    // vitalLabel.setDbp(dbp);
+
+                    Usual usualDbp = new Usual();
+                    usualDbp.setName(vi.getName());
+                    usualDbp.setStandName("舒张压");
+                    usualDbp.setValue(bp[0]);
+                    usualList.add(usualDbp);
+
+                    // PD sbp = new PD(); // 收缩压
+                    // sbp.setValue(bp[1]);
+                    // sbp.setName("收缩压");
+                    // sbp.setStandName("收缩压");
+                    // vitalLabel.setSbp(sbp);
+
+                    Usual usualSbp = new Usual();
+                    usualSbp.setName(vi.getName());
+                    usualSbp.setStandName("收缩压");
+                    usualSbp.setValue(bp[1]);
+                    usualList.add(usualSbp);
+                    vi.setUsualList(usualList);
                 }
             }
         }

+ 12 - 0
src/main/java/com/diagbot/model/entity/Usual.java

@@ -0,0 +1,12 @@
+package com.diagbot.model.entity;
+
+import lombok.Data;
+
+@Data
+/**
+ * 常规实体类
+ */
+public class Usual extends General {
+    private String value;
+    private String unit;
+}

+ 4 - 1
src/main/java/com/diagbot/model/entity/Vital.java

@@ -3,6 +3,9 @@ package com.diagbot.model.entity;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @ClassName com.lantone.util.module.Vital
  * @Description TODO
@@ -13,10 +16,10 @@ import lombok.Setter;
 @Getter
 @Setter
 public class Vital extends General{
-//    private String vitalName;
     private BodyPart bodyPart;
     private Degree degree;
     private Negative negative;
     private String value;
     private PD pd;
+    private List<Usual> usualList = new ArrayList<>(); // 二层定义的实体,例如:血压(收缩压|舒张压)
 }

+ 54 - 39
src/main/java/com/diagbot/process/BillProcess.java

@@ -4,6 +4,7 @@ import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoDTO;
 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.facade.NeoFacade;
@@ -30,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -59,44 +61,58 @@ public class BillProcess {
             }
             billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
             billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
-            // // TODO 测试数据开始
-            // if (billNeoDTO.getName().equals("普通胃镜检查")) {
-            //     NodeNeoDTO sexNeo = new NodeNeoDTO();
-            //     sexNeo.setName("男性");
-            //     billNeoMaxDTO.setGender(sexNeo);
-            //
-            //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
-            //     nodeNeoDTO.setName("红细胞压积");
-            //     nodeNeoDTO.setVal("阳性");
-            //     billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
-            //
-            //     NodeNeoDTO nodepacsDTO = new NodeNeoDTO();
-            //     nodepacsDTO.setName("上腹部平扫");
-            //     billNeoDTO.getPacsBillNeoDTO().getPacs().add(nodepacsDTO);
-            //
-            //     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 drug3 = new NodeNeoDTO();
-            //     drug3.setName("泰舒达类");
-            //     billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
-            //
-            //     // NodeNeoDTO vital = new NodeNeoDTO();
-            //     // vital.setName("体温");
-            //     // vital.setMax(new BigDecimal("39.1"));
-            //     // vital.setMin(new BigDecimal("35.1"));
-            //     // vital.setValType(1);
-            //     // billNeoDTO.getPacsBillNeoDTO().getVitals().add(vital);
-            //
-            // }
+            // TODO 测试数据开始
+            if (billNeoDTO.getName().equals("普通胃镜检查")) {
+                NodeNeoDTO sexNeo = new NodeNeoDTO();
+                sexNeo.setName("男性");
+                billNeoMaxDTO.setGender(sexNeo);
+
+                NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+                nodeNeoDTO.setName("红细胞压积");
+                nodeNeoDTO.setVal("阳性");
+                billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
+
+                NodeNeoDTO nodepacsDTO = new NodeNeoDTO();
+                nodepacsDTO.setName("上腹部平扫");
+                billNeoDTO.getPacsBillNeoDTO().getPacs().add(nodepacsDTO);
+
+                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 drug3 = new NodeNeoDTO();
+                drug3.setName("泰舒达类");
+                billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
+
+                // NodeNeoDTO vital = new NodeNeoDTO();
+                // vital.setName("体温");
+                // vital.setMax(new BigDecimal("39.1"));
+                // vital.setMin(new BigDecimal("35.1"));
+                // vital.setValType(1);
+                // billNeoDTO.getPacsBillNeoDTO().getVitals().add(vital);
+
+                NodeNeoDTO vitalBp = new NodeNeoDTO();
+                vitalBp.setName("舒张压");
+                vitalBp.setMax(new BigDecimal("120"));
+                vitalBp.setMin(new BigDecimal("100"));
+                vitalBp.setValType(1);
+                billNeoDTO.getPacsBillNeoDTO().getVitals().add(vitalBp);
+
+                NodeNeoDTO vitalBp2 = new NodeNeoDTO();
+                vitalBp2.setName("收缩压");
+                vitalBp2.setMax(new BigDecimal("120"));
+                vitalBp2.setMin(new BigDecimal("100"));
+                vitalBp2.setValType(1);
+                billNeoDTO.getPacsBillNeoDTO().getVitals().add(vitalBp2);
+
+            }
             // 测试数据结束
 
             // System.out.println(billNeoMaxDTO);
@@ -166,7 +182,6 @@ public class BillProcess {
 
             // 服用药品(现病史一般情况后的药品)
             DrugRule.compareDrugWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
-
         }
         indicationDTO.setBillMsgList(billMsgList);
     }

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

@@ -29,13 +29,11 @@ public class VitalRule {
         if(ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLis)){
             for (NodeNeoDTO neo : neoList) {
                 for (Vital vit : inputLis) {
-                    if (neo.getName().equals(vit.getStandName())) {
-                        Map<String, Object> map = CoreUtil.compareNumWtihMap(neo, vit.getName(), vit.getStandName(), vit.getPd().getValue());
-                        if ((Boolean) map.get("flag") == true) {
-                            BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),
-                                    billNeoMaxDTO.getOrderStandName(), (String) map.get("msg"), type);
-                            billMsgList.add(commonBillMsg);
-                        }
+                    Map<String, Object> map = CoreUtil.compareVital(neo, vit);
+                    if ((Boolean) map.get("flag") == true) {
+                        BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),
+                                billNeoMaxDTO.getOrderStandName(), (String) map.get("msg"), type);
+                        billMsgList.add(commonBillMsg);
                     }
                 }
             }

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

@@ -3,6 +3,9 @@ package com.diagbot.util;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.model.entity.Usual;
+import com.diagbot.model.entity.Vital;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 
 import java.lang.reflect.Field;
@@ -17,6 +20,7 @@ import java.util.Map;
  * @author: zhoutg
  * @time: 2020/7/30 15:18
  */
+@Slf4j
 public class CoreUtil {
 
     /**
@@ -295,6 +299,49 @@ public class CoreUtil {
         return map;
     }
 
+
+    /**
+     * 比较查体是否匹配
+     *
+     * @param nodeNeoDTO
+     * @param vital
+     * @return
+     */
+    public static Map<String, Object> compareVital(NodeNeoDTO nodeNeoDTO, Vital vital) {
+        Map<String, Object> map = new LinkedHashMap<>();
+        boolean flag = false;
+        if (nodeNeoDTO == null || vital == null) {
+            map.put("flag", flag);
+            return map;
+        }
+        try {
+            // 比较数值
+            List<Usual> usualList = vital.getUsualList();
+            if (nodeNeoDTO.getName().equals(vital.getStandName()) && vital.getPd() != null
+                    && StringUtil.isNotBlank(vital.getPd().getValue())) {
+                flag = compareNum(nodeNeoDTO, Double.parseDouble(vital.getPd().getValue()));
+                if (flag) {
+                    map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
+                }
+            } else if (ListUtil.isNotEmpty(usualList)) {
+                for (Usual usual : usualList) {
+                    if (nodeNeoDTO.getName().equals(usual.getStandName())) {
+                        flag = compareNum(nodeNeoDTO, Double.parseDouble(usual.getValue()));
+                        if (flag) {
+                            map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
+                            break;
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.error("【开单合理性比较体征出错】" + e.getMessage());
+        }
+
+        map.put("flag", flag);
+        return map;
+    }
+
     /**
      * 比较数值是否匹配
      *
@@ -524,6 +571,17 @@ public class CoreUtil {
         debugMap.put(msg,  + (end - start) / 1000.0 + "秒");
     }
 
+    /**
+     * 输出调试信息
+     *
+     * @param msg
+     * @param error
+     * @param debugMap
+     */
+    public static void getDebugStr(String msg, String error, Map<String, Object> debugMap) {
+        debugMap.put(msg,  error);
+    }
+
     public static void main(String[] args) {
         String msg = String.format("该患者%s%s%s,请留意", "套餐","明细项","值");
         System.out.println(msg);