浏览代码

医学规则测试

zhaops 4 年之前
父节点
当前提交
f2456779f1

+ 61 - 9
cdssman-service/src/main/java/com/diagbot/entity/ResultCritical.java

@@ -13,8 +13,8 @@ import java.util.Date;
  * 
  * </p>
  *
- * @author zhaops
- * @since 2021-01-11
+ * @author gaodm
+ * @since 2021-01-14
  */
 @TableName("test_result_critical")
 public class ResultCritical implements Serializable {
@@ -60,6 +60,11 @@ public class ResultCritical implements Serializable {
     /**
      * 危机值开单项类型(1:实验室检查、2:辅助检查)
      */
+    private Integer criticalType;
+
+    /**
+     * 开单项类型
+     */
     private String criticalItemType;
 
     /**
@@ -87,6 +92,11 @@ public class ResultCritical implements Serializable {
      */
     private String referenceValue;
 
+    /**
+     * 范围(0:范围内,1:范围外)
+     */
+    private Integer criticalItemRange;
+
     /**
      * 参考值(最小值)
      */
@@ -103,9 +113,14 @@ public class ResultCritical implements Serializable {
     private String unit;
 
     /**
-     * 范围(0:范围内,1:范围外)
+     * 年龄最小值
+     */
+    private Integer minAge;
+
+    /**
+     * 年龄最大值
      */
-    private Integer range;
+    private Integer maxAge;
 
     /**
      * 输出结果(提醒文本)
@@ -127,6 +142,11 @@ public class ResultCritical implements Serializable {
      */
     private String message;
 
+    /**
+     * 模拟入参
+     */
+    private String inputParams;
+
     public Long getId() {
         return id;
     }
@@ -176,6 +196,13 @@ public class ResultCritical implements Serializable {
     public void setResultId(Long resultId) {
         this.resultId = resultId;
     }
+    public Integer getCriticalType() {
+        return criticalType;
+    }
+
+    public void setCriticalType(Integer criticalType) {
+        this.criticalType = criticalType;
+    }
     public String getCriticalItemType() {
         return criticalItemType;
     }
@@ -218,6 +245,13 @@ public class ResultCritical implements Serializable {
     public void setReferenceValue(String referenceValue) {
         this.referenceValue = referenceValue;
     }
+    public Integer getCriticalItemRange() {
+        return criticalItemRange;
+    }
+
+    public void setCriticalItemRange(Integer criticalItemRange) {
+        this.criticalItemRange = criticalItemRange;
+    }
     public BigDecimal getMinValue() {
         return minValue;
     }
@@ -239,12 +273,19 @@ public class ResultCritical implements Serializable {
     public void setUnit(String unit) {
         this.unit = unit;
     }
-    public Integer getRange() {
-        return range;
+    public Integer getMinAge() {
+        return minAge;
     }
 
-    public void setRange(Integer range) {
-        this.range = range;
+    public void setMinAge(Integer minAge) {
+        this.minAge = minAge;
+    }
+    public Integer getMaxAge() {
+        return maxAge;
+    }
+
+    public void setMaxAge(Integer maxAge) {
+        this.maxAge = maxAge;
     }
     public String getOutput() {
         return output;
@@ -274,6 +315,13 @@ public class ResultCritical implements Serializable {
     public void setMessage(String message) {
         this.message = message;
     }
+    public String getInputParams() {
+        return inputParams;
+    }
+
+    public void setInputParams(String inputParams) {
+        this.inputParams = inputParams;
+    }
 
     @Override
     public String toString() {
@@ -285,20 +333,24 @@ public class ResultCritical implements Serializable {
             ", creator=" + creator +
             ", modifier=" + modifier +
             ", resultId=" + resultId +
+            ", criticalType=" + criticalType +
             ", criticalItemType=" + criticalItemType +
             ", criticalItemName=" + criticalItemName +
             ", criticalItemHisName=" + criticalItemHisName +
             ", criticalItemHisDetailName=" + criticalItemHisDetailName +
             ", inputValue=" + inputValue +
             ", referenceValue=" + referenceValue +
+            ", criticalItemRange=" + criticalItemRange +
             ", minValue=" + minValue +
             ", maxValue=" + maxValue +
             ", unit=" + unit +
-            ", range=" + range +
+            ", minAge=" + minAge +
+            ", maxAge=" + maxAge +
             ", output=" + output +
             ", expectedOutput=" + expectedOutput +
             ", success=" + success +
             ", message=" + message +
+            ", inputParams=" + inputParams +
         "}";
     }
 }

+ 156 - 1
cdssman-service/src/main/java/com/diagbot/facade/RuleConvertFacade.java

@@ -3,7 +3,9 @@ package com.diagbot.facade;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.entity.MappingShortEntity;
 import com.diagbot.entity.ResultBill;
+import com.diagbot.entity.ResultCritical;
 import com.diagbot.entity.node.BillItem;
+import com.diagbot.entity.node.LisCritical;
 import com.diagbot.entity.node.MedNameRegName;
 import com.diagbot.entity.node.TransfusionRemind;
 import com.diagbot.enums.GraphLabelEnum;
@@ -303,7 +305,7 @@ public class RuleConvertFacade {
             //基础属性复制
             ResultBill resultBill = new ResultBill();
             resultBill.setBillType(2);
-            resultBill.setBillItemType("输血提醒指标");
+            resultBill.setBillItemType(GraphLabelEnum.TransfusionRemind.getName());
             resultBill.setBillItemName(item.getTransfusion_type());
             resultBill.setConflictItemType(item.getNode_label());
             resultBill.setConflictItemName(item.getIndex_name());
@@ -390,6 +392,81 @@ public class RuleConvertFacade {
         return retList;
     }
 
+    public List<ResultCritical> criticalRuleConvert_lis(List<LisCritical> items,Long hospitalId) {
+        List<ResultCritical> retList = Lists.newLinkedList();
+        List<ResultCritical> resultList = Lists.newLinkedList();
+        List<ResultCritical> resultMappingList = Lists.newArrayList();
+
+        if (ListUtil.isEmpty(items)) {
+            return retList;
+        }
+
+        Map<String, Map<String, Map<String, List<Long>>>> lisConfigMap = lisConfigFacade.getUniqueConfigMap(hospitalId, null, null);
+
+        for (LisCritical item : items) {
+            //基础属性复制
+            ResultCritical result = new ResultCritical();
+            result.setCriticalType(1);
+            result.setCriticalItemType(GraphLabelEnum.LisCritical.getName());
+
+            String uniqueName = item.getName().substring(0, item.getName().length() - 3);
+            result.setCriticalItemName(uniqueName);
+            result.setReferenceValue(item.getName());
+            if (StringUtil.isNotBlank(item.getMaxval())) {
+                result.setMaxValue(BigDecimal.valueOf(Double.valueOf(item.getMaxval())));
+            }
+            if (StringUtil.isNotBlank(item.getMinval())) {
+                result.setMinValue(BigDecimal.valueOf(Double.valueOf(item.getMinval())));
+            }
+            if (StringUtil.isNotBlank(item.getAge())) {
+                String[] ages = item.getAge().split(":");
+                if (ages.length == 1) {
+                    if (item.getAge().startsWith(":")) {
+                        result.setMaxAge(Integer.valueOf(ages[0]));
+                    } else {
+                        result.setMinAge(Integer.valueOf(ages[0]));
+                    }
+                } else if (ages.length > 1) {
+                    result.setMinAge(Integer.valueOf(ages[0]));
+                    result.setMaxAge(Integer.valueOf(ages[1]));
+                }
+            }
+            result.setCriticalItemRange(StringUtil.isBlank(item.getRange()) ? 0 : Integer.valueOf(item.getRange()));
+            result.setUnit(item.getUnit());
+            resultList.add(result);
+        }
+
+        //医院端映射
+        for (ResultCritical result : resultList) {
+            Map<String, Map<String, List<Long>>> hisMap = lisConfigMap.get(result.getCriticalItemName());
+            if (hisMap != null && hisMap.size() > 0) {
+                hisMap.entrySet().forEach(entry -> {
+                    result.setCriticalItemHisName(entry.getKey());
+                    if (entry.getValue() != null && entry.getValue().size() > 0) {
+                        entry.getValue().entrySet().forEach(subEntry -> {
+                            ResultCritical resultExt = new ResultCritical();
+                            BeanUtil.copyProperties(result, resultExt);
+                            resultExt.setCriticalItemHisDetailName(subEntry.getKey());
+                            resultMappingList.add(resultExt);
+                        });
+                    } else {
+                        resultMappingList.add(result);
+                    }
+                });
+            } else {
+                result.setSuccess(0);
+                result.setMessage("开单项缺少医院端映射;");
+                resultMappingList.add(result);
+            }
+        }
+
+        //模拟数据输入
+        retList = createCriticalInputValue(resultMappingList);
+
+        return retList;
+    }
+
+
     public MappingShortEntity setMappingShortEntity(String name, String hisName, String hisDetailName) {
         MappingShortEntity item = new MappingShortEntity();
         item.setName(name);
@@ -449,6 +526,57 @@ public class RuleConvertFacade {
         return retList;
     }
 
+    /**
+     * 模拟输入数值-危急值
+     * @param resultList
+     * @return
+     */
+    public List<ResultCritical> createCriticalInputValue(List<ResultCritical> resultList) {
+        List<ResultCritical> retList = Lists.newLinkedList();
+        if (ListUtil.isEmpty(resultList)) {
+            return retList;
+        }
+        for (ResultCritical result : resultList) {
+            if (result.getSuccess() != null && result.getSuccess().equals(0)) {
+                retList.add(result);
+                continue;
+            }
+            if (result.getMaxValue() != null || result.getMinValue() != null) {
+                if (result.getCriticalItemRange() == null) {
+                    result.setCriticalItemRange(0);
+                }
+                if (result.getCriticalItemRange().equals(1)) {
+                    if (result.getMinValue() != null) {
+                        ResultCritical minResult = new ResultCritical();
+                        BeanUtil.copyProperties(result, minResult);
+                        minResult.setInputValue(random(null, result.getMinValue()).toString());
+                        BillMsg billMsg = getCriticalMsg(minResult);
+                        minResult.setExpectedOutput(billMsg.getMsg());
+                        retList.add(minResult);
+                    }
+                    if (result.getMaxValue() != null) {
+                        ResultCritical maxResult = new ResultCritical();
+                        BeanUtil.copyProperties(result, maxResult);
+                        maxResult.setInputValue(random(result.getMaxValue(), null).toString());
+                        BillMsg billMsg = getCriticalMsg(maxResult);
+                        maxResult.setExpectedOutput(billMsg.getMsg());
+                        retList.add(maxResult);
+                    }
+                } else {
+                    result.setInputValue(random(result.getMinValue(), result.getMaxValue()).toString());
+                    BillMsg billMsg = getCriticalMsg(result);
+                    result.setExpectedOutput(billMsg.getMsg());
+                    retList.add(result);
+                }
+            } else {
+                BillMsg billMsg = getCriticalMsg(result);
+                result.setExpectedOutput(billMsg.getMsg());
+                retList.add(result);
+            }
+        }
+        return retList;
+    }
+
     /**
      * 模拟提示信息
      *
@@ -581,6 +709,33 @@ public class RuleConvertFacade {
         return billMsg;
     }
 
+    /**
+     * 模拟提示信息-危急值
+     * @param resultCritical
+     * @return
+     */
+    public BillMsg getCriticalMsg(ResultCritical resultCritical) {
+        BillMsg billMsg = new BillMsg();
+        if (resultCritical.getCriticalItemType().equals(GraphLabelEnum.LisCritical.getName())) {
+            String content = "";
+            if (StringUtil.isNotBlank(resultCritical.getCriticalItemHisName())) {
+                content += resultCritical.getCriticalItemHisName();
+            }
+            if (StringUtil.isNotBlank(resultCritical.getCriticalItemHisDetailName())
+                    && !resultCritical.getCriticalItemHisName().equals(resultCritical.getCriticalItemHisDetailName())) {
+                content += resultCritical.getCriticalItemHisDetailName();
+            }
+            if (StringUtil.isNotBlank(resultCritical.getInputValue())) {
+                content += trimZero(resultCritical.getInputValue());
+            }
+            billMsg = MsgUtil.getCommonCriticalMsg(content, TypeEnum.lis.getName());
+        } else if (resultCritical.getCriticalItemType().equals(GraphLabelEnum.PacsCritical.getName())) {
+            billMsg = MsgUtil.getCommonCriticalMsg("", TypeEnum.pacs.getName());
+        }
+        return billMsg;
+    }
+
+
     /**
      * 生成随机数
      *

+ 8 - 0
cdssman-service/src/main/java/com/diagbot/vo/RuleTestVO.java

@@ -3,6 +3,8 @@ package com.diagbot.vo;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.constraints.NotNull;
+
 /**
  * @Description:
  * @Author:zhaops
@@ -14,5 +16,11 @@ public class RuleTestVO extends HospitalIdVO {
     /**
      * 测试类型
      */
+    @NotNull(message = "请输入测试案例id")
     private Long caseId;
+    /**
+     * 开单类型(1:通用,2:输血)
+     */
+    @NotNull(message = "请输入开单项测试规则类型(1:通用,2:输血)")
+    private Integer billType;
 }

+ 9 - 14
cdssman-service/src/main/java/com/diagbot/web/RuleTestController.java

@@ -75,7 +75,7 @@ public class RuleTestController {
 
     @ApiOperation(value = "全规则测试[zhaops]",
             notes = "hospitalId: 医院Id <br>" +
-                    "caseId: 测试类型<br>")
+                    "caseId: 测试用例id<br>")
     @PostMapping("/ruleTest")
     @SysLogger("ruleTest")
     public RespDTO<Boolean> ruleTest(@Valid @RequestBody RuleTestVO ruleTestVO) {
@@ -85,22 +85,17 @@ public class RuleTestController {
 
     @ApiOperation(value = "开单合理性规则测试[zhaops]",
             notes = "hospitalId: 医院Id <br>" +
-                    "caseId: 测试类型<br>")
+                    "caseId: 测试用例id<br>" +
+                    "billType: 开单项测试规则类型(1:通用,2:输血) <br>")
     @PostMapping("/billRuleTest")
     @SysLogger("billRuleTest")
     public RespDTO<Boolean> billRuleTest(@Valid @RequestBody RuleTestVO ruleTestVO) {
-        Boolean data = ruleTestFacade.billRuleTest(ruleTestVO);
-        return RespDTO.onSuc(data);
-    }
-
-    @ApiOperation(value = "开单合理性规则测试-输血[zhaops]",
-            notes = "hospitalId: 医院Id <br>" +
-                    "caseId: 测试类型<br>")
-    @PostMapping("/billTransfusionRuleTest")
-    @SysLogger("billTransfusionRuleTest")
-    //@Transactional
-    public RespDTO<Boolean> billTransfusionRuleTest(@Valid @RequestBody RuleTestVO ruleTestVO) {
-        Boolean data = ruleTestFacade.billTransfusionRuleTest(ruleTestVO);
+        Boolean data = false;
+        if (ruleTestVO.getBillType().equals(1)) {
+            data = ruleTestFacade.billRuleTest(ruleTestVO);
+        } else if (ruleTestVO.getBillType().equals(2)) {
+            data = ruleTestFacade.billTransfusionRuleTest(ruleTestVO);
+        }
         return RespDTO.onSuc(data);
     }
 }

+ 6 - 1
cdssman-service/src/main/resources/mapper/ResultCriticalMapper.xml

@@ -11,19 +11,24 @@
         <result column="creator" property="creator" />
         <result column="modifier" property="modifier" />
         <result column="result_id" property="resultId" />
+        <result column="critical_type" property="criticalType" />
         <result column="critical_item_type" property="criticalItemType" />
         <result column="critical_item_name" property="criticalItemName" />
         <result column="critical_item_his_name" property="criticalItemHisName" />
         <result column="critical_item_his_detail_name" property="criticalItemHisDetailName" />
         <result column="input_value" property="inputValue" />
         <result column="reference_value" property="referenceValue" />
+        <result column="critical_item_range" property="criticalItemRange" />
         <result column="min_value" property="minValue" />
         <result column="max_value" property="maxValue" />
-        <result column="range" property="range" />
+        <result column="unit" property="unit" />
+        <result column="min_age" property="minAge" />
+        <result column="max_age" property="maxAge" />
         <result column="output" property="output" />
         <result column="expected_output" property="expectedOutput" />
         <result column="success" property="success" />
         <result column="message" property="message" />
+        <result column="input_params" property="inputParams" />
     </resultMap>
 
 </mapper>

+ 2 - 2
cdssman-service/src/test/java/com/diagbot/CodeGeneration.java

@@ -54,9 +54,9 @@ public class CodeGeneration {
 
         // 策略配置
         StrategyConfig strategy = new StrategyConfig();
-//        strategy.setTablePrefix(new String[] { "ltkg_" });// 此处可以修改为您的表前缀
+        strategy.setTablePrefix(new String[] { "test" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "ltkg_preset_info" }); // 需要生成的表
+        strategy.setInclude(new String[] { "test_result_critical" }); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);