Java MVEL或Drools是否无法解决其类型为Map的事实<;字符串,列表<;对象>>;?
我的规则是这样的:Java MVEL或Drools是否无法解决其类型为Map的事实<;字符串,列表<;对象>>;?,java,drools,mvel,Java,Drools,Mvel,我的规则是这样的: 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) >
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
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
但它总是有错误:
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"
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
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(“降钙素”)
的结果为空,请添加保护作为约束:
$p : Patient($labtestItem : labtests,
labtests.get("calcitonin") != null)
非常感谢!这又帮了我一个问题。如果$labtestItem.get(“降钙素”)返回空值,我如何解决这个问题?