[rules-users] Performace Issues drools

sanal sanal.p at icthealth.com
Wed Apr 11 07:37:25 EDT 2012


Hi,
       Iam trying to use Drools for implementing some of the business logic
in hospital billing senario.My senario is as given.Iam implementing the
concept of  a packge. A package is a set of services or items  are put
together based on some contions. Only the packge is to be charged not the
individal services or items in the package.

Eg: A Health Package is defined with name  ExecutiveHealthCheckUp, which
have a condition say,quntity limit 2 for Laboratory tests.So if more than 2
test is ordered for a patient the 3rd ordered test should not be part of
package.  
    
     A ordered service is considered to be part of a package if the
packageChargeRecordId property of the service 

    Using Drools iam trying to find out each of the ordered services(
$orderedComponent)  for the patient to be part of package or not. Each of
the ordered service have quntity field.So i need to sum the quntity field of
same services ordered multiple times which is already part of the same
package and compare it with the quntity limit defined in the package
definition.

If a service is part of package iam setting packageChargeRecordId property
of ordered service to the packageId.


For implementing the same i have 2 set of collecton.

1st collection has got list of ordered services for the
patient.($objOrderedComponents.getOrderedComponentList() )


2nd collection list of condition for the services to be part of package.
($packageDefinition.getPackageComponentList())




rule "Package Rate_21"
        salience 65515
        when
                 /*package defanition object */
                $packageDefinition:PackageDefinition($packageId:packageId)
             
                /*Gets the list of services ordered */
               
$orderedComponent:OrderedComponent($id1:componentKey,$qty:componentQty) 
from        $objOrderedComponents.getOrderedComponentList() and

                /*trying to get the accumulated quantity for the services
which are already part of package */
                $accumulatedQty:Number()
    	from accumulate (
$accQtyComponent:OrderedComponent(packageChargeRecordId==$packageId,componentKey==$id1,
$AccQty : componentQty) from 
$objOrderedComponents.getOrderedComponentList(),sum($AccQty ) )  

and
               /*Comparing withe packakage definition rule */
                $pkgComps:PackageComponent(componentKey==$id1,(quantityLmt
>=($qty+$accumulatedQty.intValue()))) from
$packageDefinition.getPackageComponentList()	


        then
             /*setting the packagechargerecordId for the ordered services
which satisfies above conditions */
             $orderedComponent.setPackageChargeRecordId($packageId);  

             /*The changes have happened in facts so updating in the working
memory so the rule get executed once again*/
             modify ($objOrderedComponents){};    
end		

         The problem i am facing here is of performance. This way of
implementation is taking  much time compared to that of java code.If  iam
not using accumulate function and iam executing the rules for each item
seperatly instead of passing entire collection,it is working much better.
            
           Can anbody suggest a better way to implement it using drools.


Regards
Sanal.P







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



More information about the rules-users mailing list