Branching logic controls whether a field or section appears based on previous responses. It helps makeforms shorter, clearer, andmorerelevanttotheuser. Withoutbranchinglogic, users may see many fields that do not apply to the participant, which increases burden and may lead to erroneous entries. With branching logic, the form adapts to the data already entered.
Consider a field asking whether the participant has experienced an adverse event. If the answer is “No,” the fields asking for event description, onset date, severity, seriousness, and outcome are not relevant. Branching logic can hide those fields unless the user answers “Yes.”
Similarly, pregnancy-related questions may be shown only for participants for whom they are applicable according to protocol definitions. Questions about hospitalization date may appear only if hospitalization status is “Yes.”
In REDCap, branching logic uses expressions based on variable names and coded values. For example, a field may be shown only when [adverse_event] = ‘1’. This means the field appears when the variable adverse_event is coded as 1, usually representing “Yes.” Branching logic can include multiple conditions, such as showing a field when [sex] = ‘2’ and [age_years] >= 10. More complex logic should be used carefully because it can become difficult to test and maintain.
Branching logic improves usability, but it also creates responsibility. Hidden fields may remain blank, and those blanks must be interpreted correctly. A blank value because the field was not applicable is different from a blank value because the user forgot to enter data. The data dictionary should document branching conditions, so analysts understand why certain values are missing.
Branching logic must be tested thoroughly. The data manager should create test records representing different scenarios and confirm that fields appear and disappear as expected.
Testing should include edge cases, such as missing values in the variables that control branching. In longitudinal projects, branching logic may also need event references if the condition depends on data from a different event.