my rules are just like this:
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
but it always built with error:
Unable to Analyse Expression labtests.get("calcitonin").get(0):
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
if i write my rules like this,it runs:
rule "calcitonin evaluation"
lock-on-active true
salience 0
when
$p : Patient($labtestItem : labtests)
then
System.out.println($labtestItem.get("calcitonin"));
modify($p){}
end
The .get("0")
doesn't make sense - List.get expects an integer. But this won't make the problem go away. You need a boolean expression if it isn't a simple binding.
I'd write the rule like this:
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
Edit: To avoid a null result of $labtestItem.get("calcitonin")
, add the guard as a constraint:
$p : Patient($labtestItem : labtests,
labtests.get("calcitonin") != null)