我的规则是这样的:
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 需要一个整数。但这并不能让问题消失。如果不是简单的绑定(bind),则需要一个 boolean 表达式。
我会这样写规则:
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)
关于java - MVEL 或 Drools 是否无法解析其类型为 Map<String,List<Object>> 的事实?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38461276/