Versions Compared

Key

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

Description

FormConditions.js is located under bahmni_config/openmrs/apps/clinical. https://github.com/Bahmni/default-config/blob/master/openmrs/apps/clinical/formConditions.js 

This configuration

will allow

allows users to enable, disable or show errors based on specific conditions on

some

inputs on the form.

Some sections of the form that are only filled when a particular set of information is needed. Thus So, if we disable such fields, this can simplify data entry into the form and make it simplifies the form much less confusing.

If Consider for example the case where there are two dates being entered in a form template and one of the date should be always lesser than the other one. The This condition can be checked in this javascript JavaScript and an appropriate error message can be thrownshown upon validation.

The following function takes two inputs (formName and formFieldValues) and returns an object that contains array on of enable and disable field/s and an error message if any. This code snippet will make "Posture" option disable on initial rendering. Once data is entered for "Systolic Data" field, "Posture" option is enabled.

Example

Code Block
languagejs
linenumberstrue
'Systolic Data' : function (formName, formFieldValues) {
        var systolic = formFieldValues['Systolic'];
        if (systolic) {
            return {
                enable: ["Posture"]
            }
        } else {
            return {
                disable: ["Posture"],
				error: "Error message here if any"
            }
        }
	},

 

This code snippet will make "Posture" option disable on rendering. Once data is entered for "Systolic Data" field it will enable "Posture" option.

Note 

 

Functions signature 

<Concept Full Name> : function (formName, formFieldValues) { } .This signature is mandatory to implement this functionality.

 It will only work with Concept Full Name  ex. "Systolic Data", "Systolic" and "Posture".

It returns 

Returns the following

{

      enable: ["Posture"],

      disable: [],

      error: "Error message here if any"
}

 

 

 

Tip
titleOn this Page

Table of Contents