Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose

Orderset rules to be applied to calculate the dosage that can vary from implementation to implementation. To facilitate that, Rules engine is designed with extensibility in mind. By default Bahmni provides two rules "mg/kg" and "mg/m2" out of the box and these rules can also be configured with the help of csv file. Please check Using rules link for further information.

Extending rules engine with new rules:

Rules engine can be extended by writing appropriate groovy scripts and deploying at rules engine folder. Rules engine does nothing but transferring calls to its appropriate dosage calculator rule. Dosage calculator rule should adhere to the following interface in order to pickup automatically by the rules engine and apply the calculation.

Code Block
languagejava
titleDosageRule interface
public interface DosageRule {
     Dose calculateDose(DosageRequest request) throws Exception ;
    }

A sample groovy rule:

The following groovy rule is only for illustration purpose. Write a groovy class implementing DosageRule interface and attribute the class with "RuleName" attribute to assign a name for this particular rule. Rule assigned here will automatically populated at the drug order set creation Rules dropdown. If No rule name is assigned using "RuleName" attribute, then class name will be chosen as the rule name by default.

Expand
languagegroovy
titleExpand to see NewRule.groovy
Code Block
package org.openmrs.module.rulesengine.rule 
import org.openmrs.module.rulesengine.domain.DosageRequest 
import org.openmrs.module.rulesengine.domain.Dose 
import org.openmrs.module.rulesengine.domain.RuleName 
@RuleName(name = "testrule") 
class NewDosageRule implements DosageRule 
{ 
@Override 
Dose calculateDose(DosageRequest request) throws Exception
 { // write the new logic for calculating dosage and return Dose object. 
return null; 
} 
}

After writing the rule, the same has to be deployed in the appropriate place for the rule engine to pickup automatically.

Info
titleRules location

All the new rules written in groovy language should be deployed at:

/opt/openmrs/bahmni_config/openmrs/rulesengine/rulesengineextension
Note

After deploying the rules at the above location, restart openmrs for the rules engine to pickup new rules.Existing default rules that are already part of rules engine should already be populated. System must be restarted only for new groovy file based rules.

 

Tip
iconfalse
titleOn this Page

Table of Contents
stylenone

Panel
titleColorwhite
titleBGColor#668D3C
titleFeature Details

Using rules

Panel
titleColorwhite
titleBGColor#1FA5A0
titleRelated Links

Authoring Order Sets