[rules-users] Performace Issues drools

sanal sanal.p at icthealth.com
Mon Apr 16 05:08:07 EDT 2012


Hi ,

                             I am trying to use drools where the rules are
defined in a tree format.

 eg:Iam explaining it with a hospital senario. A healtcarepackage has got
set of criteria which is defined in a tree format.

 

                                                        QtyLimit      
AmtLimit                                  Excluded
       -- ServiceGroup                               -                        
-                                                  -

      ----------------DrugGroup                                  10000                                              

      ----------------ServiceGroup                              15000

      --------------------LabServices              2

     -------------------------GlucoseTest                                                                           
Y

    ---------------------RadiologyServices                   20000

    --------------------------XRayChest          5

 

 

Here each of the package criteria is a packagecomponent. and service which
are ordered for patient is a ServiceComponent.Using the above rules ideed to
check wether the service component can be part of the package or not?There
are few more critriea other than above
given(TariffClassType,Tariffclassvalue...etc)

 

 

I have included the Drl which iam using.I have added all the
PackageComponents and the serviceComponents to working memory as facts to
the working memory.Is there any better way for implementing the same?

 

 

 


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: 11*/
rule "Package Details_11"
 salience 8
when
 $orderedComponent:OrderedComponent($id1:componentKey,$qty:componentQty) and
   
$pkgComps:PackageComponent(componentKey==$id1,isPackageComponent==true,isActive==true)
then
 $orderedComponent.setIsPackageComponent(true);
end
 

/*#From row number: 12*/
rule "Package Details_12"
  salience 7
when

$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);
end
 

/*

#From row number: 21*/
 
rule "Package Rate_13"
 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);
end
 

/*

#From row number: 21*/
rule "Package Rate_14"
  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);
end
 

 
 
/*#From row number: 22*/
rule "Package Details_15"
salience 4
when
 $orderedComponent:OrderedComponent($id1:componentKey)

$pkgComps:PackageComponent(componentKey==$id1,isPackageComponent==true,exemption==true,isActive==true)
then
 $orderedComponent.setExemption(true);
end
 

/*#From row number: 21*/
 
rule "Package Rate_16"
salience 3
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
 $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); 
 modify ($objOrderedComponents){}; 
end
 

 
 
/*#From row number: 22*/
rule "Package Details_17"
 salience 2
when
 $objOrderedComponents:AccumulatedComponent()

$orderedComponent:OrderedComponent($id1:componentKey,isPackageComponent==false,componentType=="1052374",haveReachedRootNode==false)
then
    $orderedComponent.setGenericComponentKey();
 modify ($objOrderedComponents){}; 
end
 
/*#From row number: 22*/
rule "Package Details_18"
 salience 1
when
 $objOrderedComponents:AccumulatedComponent()

$orderedComponent:OrderedComponent($id1:componentKey,isPackageComponent==false,haveReachedRootNode==false)
then
 $orderedComponent.setGroupComponentKey();
 modify ($objOrderedComponents){}; 
end

--
View this message in context: http://drools.46999.n3.nabble.com/Performace-Issues-drools-tp3902270p3913888.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list