Conditional Sections

It is possible to remove sections from a script execution by evaluating an expression at the start of the execution: if the section is not visible, it will not be listed in the sections panel and the expression will not be re-evaluated during the script execution.

Using a pre-populated DS as described in Pre-Populating Scripts with Captured Data, we can set a flag on an entity depending on circumstances external to the script. Let's say we have an entity called IntakeInformation that has a boolean attribute "collectIncomeInformation". We can specify an Income section in our script:

Figure 1. Visible Attribute of a Section
...
<section visible="IntakeInformation.collectIncomeInformation==true">
   ...
</section>
...

This will hide the Income section if the "collectIncomeInformation" attribute is false, as if the section was not present in the script definition.

If a section needs to be enabled or disabled depending on answers from previous sections, it is possible to wrap all the pages of a section in a single condition. Unlike the visible attribute, this condition will be evaluated whenever the section is encountered, which means it is possible to go back and change an answer that affects the navigability of a section. The section will still appear in the sections panel but will be grayed out so the user cannot click on it.

The preceding example can be modified so that the "collectIncomeInformation" question is asked at the start of the script. The Income section can then be modified as follows:

Figure 2. Conditional Section
...
<section>
   <condition
     expression="IntakeInformation.collectIncomeInformation">
     ...
   </condition>
</section>
...