Groovy Scripts are used as extension scripts that can be executed when a particular event is triggered.
Some of the events can be
For any groovy script the following are configurable
Different types of groovy scripts that can be configured are
File Name | Location and Example File | Note |
---|---|---|
BahmniObsValueCalculator.groovy |
|
|
TreatmentRegimenExtension.groovy |
|
|
bahmni.executeGroovyObsValueCalculator - Groovy scripts to calculate obs during Encounter save can be disabled using this property. Under heavy load, Groovy scripts loading/compilation and execution can make the responses slower. This property if set to False, will not execute groovy scripts (BahmniObsValueCalculator.groovy). If you do not use advanced calculations, it's better to turn this property to false. Note, for simple calculations while capturing observations, you may use JavaScript in Forms2 (e.g. BMI calculation). |
Custom Extensions
If One Configures, DstExtension.groovy under ObsToObsFlowSheet Control (Refer Sample Config), then the groovy is executed while the control (ObsToObsFlowSheet Control) is displayed. |
Configuration | Location and Example | Note |
---|---|---|
Add the groovy extension name as value of key "type" under the configuration section of ObsToObsFlowSheet Control |
|
|
One way to debug groovy scripts during development is to write statements to a temporary file, e.g., in BahmniObsValueCalculator.groovy, use the snippet below. groovy_debug.txt should be writable. Make sure to remove debugging statements and temporary file before deployment.
def file1 = new File(OpenmrsUtil.getApplicationDataDirectory() + "obscalculator/groovy_debug.txt")
file1.append 'debugging statement\n'