Determinacy constraints - Demonstration

The demonstration below shows an imaginary doctor's visit element.

The visit may be the first one, or it may be a consecutive visit:

  • If it is the first visit, the previous visit date field should be hidden.
  • If it is not the first visit, the previous visit date field should be visible.
  • If it is the first visit, it is also impossible that the prescription is the same as the previous one, so the value of this field should be set to false and disabled.
  • If it is not the first visit, we have to ensure that the field should be enabled.

. However, if it is a consecutive visit and the prescription is the same as the previous one, the prescription field should be hidden.

 
Doctor Visit
Is For The First Time
Previous Visit Date
Same Prescription As Previously
Prescription
300
XML output

        
Determinacy constraints - Description

The basic idea that lies behind the determinacy constraint is that a certain value or existence of one node can somehow affect a different node.

The node that affects the other one is the determinant, whereas the one that is affected is called the dependant.

The change that is executed on the dependant is called the Action. There are several different actions available. There is also a possibility to run a custom action.

It depends on the determinacy existence or value, whether the action will be fired. A condition that is used can be created by properly setting a property Operator and a property ValueToCompare.

  • If the Operator's property value is Exists - the action is performed whenever the item exists.
  • If the Operator's property value is NotExists - the action is performed whenever the item does not exists.
  • If the Operator's property value is Equals, NotEquals, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual - the action is performed whenever the comparison between the item's value and the ValueToCompare property using the given operator is true.

The ValueToCompare property can also be provided as a list of alternative values (a | b | c). In such a situation only Equals and NotEquals operator values make sense. When the operator is set to Equals, then the action is fired if the item's value equals one of the values in the array. When the operator is set to NotEquals, then the action is fired if the item's value does not equal any of the values in the array.

One determinacy may have one or more dependants. Each dependant can have one or more actions fired on itself if the determinant's condition matches. There are several predefined actions available. There is also a possibility to write a custom action

The available actions are:

  • Add - adds a dependant item.
  • Disable - makes the dependant item disabled.
  • Enable - makes the dependant item enabled.
  • Hide - makes the dependant item invisible (notice that while invisible, the item may still be required, which may make it impossible to input a valid form data, whenever hiding a field make it optional or set its value).
  • Remove - removes a dependant item.
  • SetOptional - makes the dependant item optional.
  • SetRequired - makes the dependant item required.
  • SetValue - sets teh value of the dependant item to the Value property of the action.
  • Show - makes the dependant item visible.

Keep in mind that circular dependencies between different items may be dangerous. Consider the following determinacy set:

when item a equals 'a', it sets the value of item b to 'b'; if item b equals 'b', it sets the value of item a to 'c'; if item a equals 'c', it sets the value of item b to 'd'; if item b equals 'd', it sets the value of item a to 'a';

When the first determinacy is fired, it changes the value of item b. The change on item b fires the second determinacy. The second determinacy changes the value of item a, which in turn fires the third determinacy. The change after the third determinacy fires the fourth one, and finally the change in the fourth one fires the first one. Such a code will loop forever.