MVEL 或 Drools 是否无法解决其类型为 Map<String,List<Object>> 的事实?
Does MVEL or Drools cannot resolve fact that its type is Map<String,List<Object>>?
我的规则是这样的:
rule "calcitonin evaluation"
lock-on-active true
salience 0
when
$p : Patient($labtestItem : labtests.get("calcitonin").get("0"))
LabTestItem($result : result.substring(1,(result.length)-1), parseFloat($result) > 8.4) from $labtestItem
then
$labtestItem.setAbnormalIndicator("high");
$labtestItem.setAttentionLevel("important");
modify($p){}
end
但它总是出错:
Unable to Analyse Expression labtests.get("calcitonin").get(0):
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
如果我这样写我的规则,它会运行:
rule "calcitonin evaluation"
lock-on-active true
salience 0
when
$p : Patient($labtestItem : labtests)
then
System.out.println($labtestItem.get("calcitonin"));
modify($p){}
end
.get("0")
没有意义 - List.get 需要一个整数。但这不会使问题消失。如果它不是简单的绑定,则需要一个布尔表达式。
我会这样写规则:
rule "calcitonin evaluation"
when
$p : Patient($labtestItem : labtests)
$lti: LabTestItem($result : result, parseFloat($result.substring(1,(result.length)-1)) > 8.4) from $labtestItem.get("calcitonin").get(0)
then
$lti.setAbnormalIndicator("high");
$lti.setAttentionLevel("important");
modify($p){}
end
编辑: 为避免 $labtestItem.get("calcitonin")
的空结果,添加守卫作为约束:
$p : Patient($labtestItem : labtests,
labtests.get("calcitonin") != null)
我的规则是这样的:
rule "calcitonin evaluation"
lock-on-active true
salience 0
when
$p : Patient($labtestItem : labtests.get("calcitonin").get("0"))
LabTestItem($result : result.substring(1,(result.length)-1), parseFloat($result) > 8.4) from $labtestItem
then
$labtestItem.setAbnormalIndicator("high");
$labtestItem.setAttentionLevel("important");
modify($p){}
end
但它总是出错:
Unable to Analyse Expression labtests.get("calcitonin").get(0):
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
如果我这样写我的规则,它会运行:
rule "calcitonin evaluation"
lock-on-active true
salience 0
when
$p : Patient($labtestItem : labtests)
then
System.out.println($labtestItem.get("calcitonin"));
modify($p){}
end
.get("0")
没有意义 - List.get 需要一个整数。但这不会使问题消失。如果它不是简单的绑定,则需要一个布尔表达式。
我会这样写规则:
rule "calcitonin evaluation"
when
$p : Patient($labtestItem : labtests)
$lti: LabTestItem($result : result, parseFloat($result.substring(1,(result.length)-1)) > 8.4) from $labtestItem.get("calcitonin").get(0)
then
$lti.setAbnormalIndicator("high");
$lti.setAttentionLevel("important");
modify($p){}
end
编辑: 为避免 $labtestItem.get("calcitonin")
的空结果,添加守卫作为约束:
$p : Patient($labtestItem : labtests,
labtests.get("calcitonin") != null)