...
version | date | comment | changes |
---|---|---|---|
1 | 06-2021formal sector | ||
2 | 08-2021payment layer | remove acceptance criteria form FS cleaning FS specifics move calculation rules in a specific table add filter based on type and sub-type |
Concepts
The rules for the the calculation of the policy value or payment to HF can be complex and evolving. Therefore, the solution should bring flexibility, to avoid complete redesign and databases change when a parameter to define the contribution value is changed.
To bring that flexibility, the solution described here uses a Calculation Rule (the Calculation Rules are defined in additional openIMIS modules extending the Calculation Module). This module is defining a framework to design calculations and to manage their activation and versioning in openIMIS. This
...
relevance and condition are Nice to have.
Abstract Methods
...
getRuleName(classname)
NEED TO BE DEFINED ON ABSTRACT CLASS LEVEL
return an object “CalculationRules”
getRuleDetails(classname)
NEED TO BE DEFINED ON ABSTRACT CLASS LEVEL
defined in rules
active_for_object
ready
check_calculation
calculate
get_linked_class
Methods defined in abstract class
get_uuid
return UUID
get_version
return version
get_calculation_rule_name
return calculation rule name
get_rule_name(cls, sender, class_name, **kwargs):
return rule object is classname is part of impacted class
get_description
return description
get_impacted_class_parameter
return impacted_class_parameter
get_rule_details(classname)
For object in listObject
if object.class == classname
return object
...
get_paramteres(ClassName, instance)
...
#className is the class name of the object where the calculation param need to be added
...
return a list only with rule details that matches step 1 and 2
...
run_calculation_rules(instance, context)
NEED TO BE DEFINED ON ABSTRACT CLASS LEVEL
this function will be register to the module signal via the ready function if the rule is active
...
2 if activeForObject(instance)
calculate(instance)
Module function/Service
NEED TO BE DEFINED ON MODULE LEVEL
...
get_rule_details(classname)
this function will send a signal and the rules will reply if they have object matching the classname in their list of object
...
merge listruledetails and result_signal
return listruledetails
...
calculate(instance, context)
for all calculation rules (send signal):
runCalculationRules(instance, context)
no return
...
get_parameters(ClassName, instance)
#className is the class name of the object where the calculation param need to be added
...
return the ruleDetails that are valid to classname and related to instance
...
get_linked_class(List[ClassName] = None)
#List[ClassName] is send from FE, by checking the class used in page where the user ave access if None (in case too difficult to do on the FE) all liked class will be retrieve
...