When using entities in a rulebase, you can check whether entity instances match particular conditions.
Count the number of instances of an entity for which a particular attribute is true
Get the highest/most recent value of an entity-level variable for which a particular attribute is true
To count the number of instances there are of an entity for which a particular entity-level attribute has a particular value, you use the Instance Count If function. The syntax for this function is:
InstanceCountIf(<relationship text>,<entity-level condition>)
the number of <relationship text> for which it is the case that <entity-level attribute>
For example, the Instance Count If function could be used to determine the number of school students for the claimant:
the number of school students that the claimant has = InstanceCountIf(the claimant's children, the child is a school student)
(For this rule to compile the following entities and relationship must be included in a properties files in the project: an entity 'the claimant' , an entity 'the child' and a one-to-many relationship 'the claimant's children'.)
The function returns a value of 1 for the following data:
the child | the child is a school student |
---|---|
Rachel | false |
Michael | false |
Simon | true |
NOTES:
You can only put one attribute as the 'If' parameter in the function, but that attribute can be proven in a separate rule by any number of other conditions.
To obtain the highest or most recent value of an entity-level variable for all instances of the entity for which a particular entity-level attribute has a particular value, you use the Instance Maximum If function. The syntax for this function is:
InstanceMaximumIf(<relationship text>,<entity-level variable>,<entity-level condition>)
For example, the Instance Maximum If function could be used to determine the most recent date of employment of a permanent employee by a company:
the most recent date of employment of a permanent employee by the company = InstanceMaximumIf(the company's employees, the employee's date of employment, the employee is a permanent employee)
(For this rule to compile the following entities and relationship must be included in a properties files in the project: an entity 'the company' , an entity 'the employee' and a one-to-many relationship 'the company's employees'.)
The function returns a value of 15/05/2006 for the following data:
the employee | the employee's date of employment | the employee is a permanent employee |
---|---|---|
David | 01/01/2006 | true |
Shaun | 24/08/2006 | false |
Anita | 15/05/2006 | true |
NOTES:
You can only put one attribute as the 'If' parameter in the function, but that attribute can be proven in a separate rule by any number of other conditions.
To obtain the lowest or least recent value of an entity-level variable for all instances of the entity for which a particular entity-level attribute has a particular value, you use the Instance Minimum If function. The syntax for this function is:
InstanceMinimumIf(<relationship text>,<entity-level variable>,<entity-level condition>)
For example, the Instance Minimum If function could be used to determine the youngest of the claimant's female children:
the youngest of the claimant's female children = InstanceMinimumIf(the claimant's children, the child's age, the child is female)
(For this rule to compile the following entities and relationship must be included in a properties files in the project: an entity 'the claimant' , an entity 'the child' and a one-to-many relationship 'the claimant's children'.)
The function returns a value of 4 for the following data:
the child | the child's age | the child is female |
---|---|---|
Sam | 3 | false |
Alex | 4 | true |
Shannon | 6 | false |
Paris | 8 | true |
NOTES:
You can only put one attribute as the 'If' parameter in the function, but that attribute can be proven in a separate rule by any number of other conditions.
To obtain the sum of all instances of an entity-level variable for which it is true of the entity that a specific entity-level boolean attribute is true, you use the Instance Sum If function. The syntax for this function is:
InstanceSumIf(<relationship text>,<entity-level variable being summed>,<entity-level condition>)
total for all <relationship text>, <entity-level variable> only where <entity-level attribute>
<entity-level variable> totaled for all of <relationship text> for which it is the case that <entity-level attribute>
For example, the Instance Sum If function could be used to determine the total boarding school fees for the claimant:
the total cost of boarding school fees for the claimant = InstanceSumIf(the claimant's children, the annual school fees for the child, the child attends a boarding school)
(For this rule to compile the following entities and relationship must be included in a properties files in the project: an entity 'the claimant' , an entity 'the child' and a one-to-many relationship 'the claimant's children'.)
The function returns a value of $33000 for the following data:
the child | the annual school fees for the child | the child attends a boarding school |
---|---|---|
Sally | $18000 | true |
James | $15000 | true |
Bob | $10000 | false |
NOTES:
You can only put one attribute as the 'If' parameter in the function, but that attribute can be proven in a separate rule by any number of other conditions.
See also: