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.

This configuration allows users to enable, disable or show errors based on specific conditions on inputs on the form.

Some sections of the form are only filled when a particular set of information is needed. So, if we disable such fields, it simplifies the form.

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

The following function takes two inputs (formName and formFieldValues) and returns an object that contains array of enable and disable field/s and an error message if any.  This In the below case, the returned object will be-

Code Block
languagejs
{
      enable: ["Posture"],
      disable: [],
      error: "Error message here if any"
}

 

This code snippet will make "Posture" option disable disabled 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"
            }
        }
	},

 

 

Functions signature 

Function signature 

Code Block
languagejs
<Concept Full Name> : function (formName, formFieldValues) { }
.

Returns the following

{

      enable: ["Posture"],

      disable: [],

      error: "Error message here if any"
}

 

 

 

Tip
titleOn this Page

Table of Contents