Hi,
Still Iam facing some issues with the accumulte.Please see the below
senario.I am trying to explain with the below example.
Suppose Glucose is a OrderedComponent which is under Labgroup.
PackageComponent(Rule)
------------------------------
LABGroup (ComponentKey=100) qtyLimit(2)
OrderedComponent
-------------------------------
Order1 Glucose (ComponentKey=101) Ordered qty (1)
ParentKey(100), ParentKey(4)
Order2 Glucose (ComponentKey=101) Ordered qty (1)
ParentKey(100) ,ParentKey(4)
Order3 Glucose (ComponentKey=101) Ordered qty (1)
ParentKey(100), ParentKey(4)
Rule execution flow which i require.
1) I need to check any rule exist for Orderedcomponent.If exist Execute the
Rule.
In this case no rule exist for glucose.
2) If no rule is found for the Orderedcomponent.I need to Check if any rule
exist for its parent(group).
I am trying to achive this by changing the component key. The component
key is changed to that of
the parent and the rules are executed once again.This process is
contiuned until any rules exist for the group
or root parent is reached(tree format).
1st Issue
Here parent of glucose is Lab. And Lab has got rule.So the Parent rule
of lab should get executed.
In this senario only 2 glucose orders should go under package. 3rd one
should not go under package.
With my existing Drl all the 3 are going inside the package.How can i
correct this?
2nd Issue
While accumulating with lab group,all ordered items whose parent group is
lab should be summed up.
The salience is used in such a manner because i need to execute the rules
for the services first
and later the rules for its parents group.
Please find the modified drl as per your suggestion.
package com.his.billing.domain;
import com.his.clinical.domain.PackageDefinition;
import com.his.clinical.domain.PackageComponent;
import com.his.billing.domain.OrderedComponent;
import com.his.billing.domain.AccumulatedComponent;
/*#From row number: 12*/
rule "Check whether is orderedComponent is excluded"
salience 7
when
$objOrderedComponents:AccumulatedComponent()
$orderedComponent:OrderedComponent($id1:componentKey,$orderTariffClassType:tariffClassType,$orderTariffClassId:tariffClassValue)
and
$pkgComps:PackageComponent(componentKey==$id1,isExcluded==true,(tariffClassTypeValue==null
|| tariffClassTypeValue=="" || (tariffClassTypeValue!=null &&
tariffClassTypeValue == $orderTariffClassType)),(tariffClassValue==null ||
(tariffClassValue!=null &&
tariffClassValue==$orderTariffClassId)),isPackageComponent==true,isActive==true)
then
$orderedComponent.setIsExluded(true);
$orderedComponent.setIsPackageComponent(true);
end
/*#From row number: 21*/
rule "Check whether is orderedComponent quantity limit exceeded"
salience 6
when
$objOrderedComponents:AccumulatedComponent()
$packageDefinition:PackageDefinition($packageId:packageId)
$orderedComponent:OrderedComponent($id1:componentKey,$amount:componentAmt,$qty:componentQty,$orderTariffClassType:tariffClassType,$orderTariffClassId:tariffClassValue)
and
$accumulatedQty:Number()
from accumulate (
$accQtyComponent:OrderedComponent(packageChargeRecordId==$packageId, $AccQty
: componentQty) from
$objOrderedComponents.getOrderedComponentList(),sum($AccQty ) ) and
$pkgComps:PackageComponent(componentKey==$id1,(quantityLmt == 0 ||
quantityLmt != null || quantityLmt
<($qty+$accumulatedQty.intValue())),isPackageComponent==true,isActive==true,(tariffClassTypeValue==null
|| tariffClassTypeValue=="" || (tariffClassTypeValue!=null &&
tariffClassTypeValue == $orderTariffClassType)),(tariffClassValue==null ||
(tariffClassValue!=null && tariffClassValue==$orderTariffClassId)))
then
$orderedComponent.setIsQtyExceeded(true);
$orderedComponent.setIsPackageComponent(true);
end
/*#From row number: 21*/
rule "Check whether is orderedComponent Amount limit exceeded"
salience 5
when
$objOrderedComponents:AccumulatedComponent()
$packageDefinition:PackageDefinition($packageId:packageId)
$orderedComponent:OrderedComponent($id1:componentKey,$amount:componentAmt,$qty:componentQty,$orderTariffClassType:tariffClassType,$orderTariffClassId:tariffClassValue)
and
$accumulatedAmount:Number()
from accumulate (
$accAmtComponent:OrderedComponent(packageChargeRecordId==$packageId,$accAmount:componentAmt)
from $objOrderedComponents.getOrderedComponentList(),sum($accAmount ) ) and
$pkgComps:PackageComponent(componentKey==$id1,( amountLmt == 0 ||
amountLmt == null || amountLmt
<($amount+$accumulatedAmount.intValue())),isPackageComponent==true,isActive==true,(tariffClassTypeValue==null
|| tariffClassTypeValue=="" || (tariffClassTypeValue!=null &&
tariffClassTypeValue == $orderTariffClassType)),(tariffClassValue==null ||
(tariffClassValue!=null && tariffClassValue==$orderTariffClassId)))
then
$orderedComponent.setIsAmtExceeded(true);
$orderedComponent.setIsPackageComponent(true);
end
/*#From row number: 22*/
rule "Check whether is orderedComponent is exempted"
salience 4
when
$objOrderedComponents:AccumulatedComponent()
$orderedComponent:OrderedComponent($id1:componentKey)
$pkgComps:PackageComponent(componentKey==$id1,isPackageComponent==true,exemption==true,isActive==true)
then
$orderedComponent.setExemption(true);
$orderedComponent.setIsPackageComponent(true);
end
/*#From row number: 21*/
rule "Check whether orderedComponent satisfy all rules.Then assign package
id"
salience 3
when
$objOrderedComponents:AccumulatedComponent()
$packageDefinition:PackageDefinition($packageId:packageId)
$orderedComponent:OrderedComponent($id1:componentKey,packageChargeRecordId!=$packageId,$amount:componentAmt,$qty:componentQty,$orderTariffClassType:tariffClassType,$orderTariffClassId:tariffClassValue)
and
$accumulatedAmount:Number()
from accumulate (
$accAmtComponent:OrderedComponent(packageChargeRecordId==$packageId,$accAmount:componentAmt)
from $objOrderedComponents.getOrderedComponentList(),sum($accAmount ) ) and
$accumulatedQty:Number()
from accumulate (
$accQtyComponent:OrderedComponent(packageChargeRecordId==$packageId, $AccQty
: componentQty) from
$objOrderedComponents.getOrderedComponentList(),sum($AccQty ) ) and
$pkgComps:PackageComponent(componentKey==$id1,isExcluded==false,(amountLmt
== 0 || amountLmt == null || amountLmt
=($amount+$accumulatedAmount.intValue())),( quantityLmt ==0 ||
quantityLmt
==null || quantityLmt
=($qty+$accumulatedQty.intValue())),isPackageComponent==true,isActive==true,(tariffClassTypeValue==null
|| tariffClassTypeValue=="" || (tariffClassTypeValue!=null &&
tariffClassTypeValue == $orderTariffClassType)),(tariffClassValue==null ||
(tariffClassValue!=null && tariffClassValue==$orderTariffClassId))) from
$packageDefinition.getPackageComponentList()
then
$orderedComponent.setIsComponentApplicable(true);
$orderedComponent.setPackageChargeRecordId($packageId);
$orderedComponent.setIsPackageComponent(true);
modify($orderedComponent){};
modify($objOrderedComponents){};
end
/*#From row number: 22*/
rule "If no rule exist for orderedComponent Check whether orderedComponent
is a pharmacy item then assign its generic naame and then apply the rules"
salience 2
when
$objOrderedComponents:AccumulatedComponent()
$orderedComponent:OrderedComponent($id1:componentKey,isPackageComponent==false,componentType=="1052374",haveReachedRootNode==false)
then
$orderedComponent.setGenericComponentKey();
modify($orderedComponent){};
modify($objOrderedComponents){};
end
/*#From row number: 22*/
rule "If no rule exist for orderedComponent Check whether rule exist for
its parent group"
salience 1
when
$objOrderedComponents:AccumulatedComponent()
$orderedComponent:OrderedComponent($id1:componentKey,isPackageComponent==false,haveReachedRootNode==false)
then
$orderedComponent.setGroupComponentKey();
modify($orderedComponent){};
modify($objOrderedComponents){};
end
Regards
Sanal.P
--
View this message in context:
http://drools.46999.n3.nabble.com/Performace-Issues-drools-tp3902270p3916...
Sent from the Drools: User forum mailing list archive at
Nabble.com.