Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

How to set control (skip) logic in custom forms?

OpenSpecimen supports the use of skip logic i.e. to shows/hide one or more fields based on the value of another field, in custom forms.

  1. You need to know how to edit XMLs to define skip logic.
  2. Skip logic can be configured only via XML import. We will enhance the UI to support this in future.
  3. Skip logic is retained even if the form is edited and saved via UI (enhanced in v6.2).

What are the different types of skip logic supported?

  1. Show/hide field based on value of a dropdown or radio button (i.e. single value field)
  2. Show/hide field based value of a text or number field
  3. Show/hide field based on a condition, e.g. range of a number, date, text.
  4. Show/hide based on conditions involving complex expressions involving logical operators and relational operators
    Logical operators: 'and', 'or'
    Relational operators: '<', '>', '=', '<=', '>=', '!=' 

What is not supported currently?

  1. Conditions based on regex
  2. Enable disable fields. Currently only show/hide is supported.
  3. Adding skip logic on fields within sub-form is not supported.

Best practices to create skip logic in a form

  1. Create the form with all its fields via UI.
  2. Download the XML using the Export button.
  3. Edit the XML to add the skip logic.
  4. Import the XML back and the form is saved automatically. Make sure not to change the form name in the XML, otherwise it will create a new form.
  5. User can update the form via UI and save it without hampering the skip logic of the form.

Example form definition XML with skip logic: GeneticHistory.xml, Smoking History

Check the syntax of the "showWhen" tag in the above XML.

Sample form:

Form field

Control

Values

Control logic

Proband

Radio Button

Yes, No

-

Relation with Proband

Drop down

Father, Mother, Son, Daughter, Others

The field should appear if option ‘No’ is selected for ‘Proband’ field

Other Relation

String Text Box

-

The field should appear if option ‘Others’ is selected for ‘Relation with Proband’ field

Try out the above sample form on demo site: 'Genetic History'

On selecting 'Yes', form field 'Relation with Proband' will not appear

On selecting 'No' option, form field 'Relation with Proband' will appear

Example of skip logic with condition involving logical operator:

Condition: Display 'FOBT Results' field when the value for 'FOBT Results' is either one of 'Positive' or 'Negative'

Syntax: 

<showWhen><![CDATA[fOBTResults = "Positive" or fOBTResults = "Negative"]]></showWhen>

 

Example of skip logic to hide/show a subform

Condition: Display the subform "Family History Details" when the value of the field "Family Cancer History" is "Yes"

Syntax (to be added just above the subform control name): <showWhen><![CDATA[familyCancerHistory = "Yes" ]]></showWhen>

When 'Family Cancer History' value is 'No', subform does not appear.



When 'Family Cancer History' value is 'Yes', a subform 'Family History Details' is visible.

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com