Introduction

Skip logic in OpenSpecimen allows fields in custom forms to be dynamically shown or hidden based on the value of another field. This functionality ensures that forms adapt to user input, improving usability and reducing the likelihood of errors. Skip logic is defined using XML and retains its configuration even when the form is edited and saved via the UI.

  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. Fields can be shown or hidden based on the value of dropdowns or radio buttons.

  2. Skip logic can be applied based on specific text or numerical values.

  3. Conditions can include ranges for numbers, dates, or text values.

  4. Show/Hide Using Logical and Relational Operators:

What is not supported currently?

Best practices to create skip logic in a form

  1. Create the form with all required fields via the UI.

  2. Export the XML of the form using the Export button.

  3. Edit the XML to define skip logic using the showWhen tag.

  4. Re-import the edited XML. Ensure the form name in the XML is unchanged to avoid creating a duplicate form.

  5. Once imported, the skip logic is saved and remains functional even after subsequent updates via the UI.

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 the demo site: 'Genetic History'

On selecting 'Yes', the 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.

Example 3: Use Single checkbox in </showWhen>, since its boolean value, you need to mentioned 0/1 in the condition as below