# Add Conditionality to Assessments

## Overview

Welkin Health allows you to add conditional logic to assessments, enabling fields to be shown or hidden based on responses to other questions. Conditional fields improve user experience by displaying only relevant questions and reducing assessment length for users who don't meet certain criteria.

For example, you might show a "Please specify" text field only if a user selects "Other" from a list, or display allergy questions only if the patient answers "Yes" to having allergies.

## Key Concepts

* **Conditional Statement** – A rule that shows/hides a field based on another field's value
* **Trigger Field** – The question whose response determines visibility
* **Conditional Field** – The question that appears/disappears based on the trigger
* **Condition Logic** – The rule that evaluates the trigger field (e.g., "equals Yes", "contains 'Other'")
* **Single CDT Conditions** – Most common; conditions within one CDT
* **Multi-CDT Conditions** – Advanced; conditions across multiple CDTs

## Building Blocks for Conditionality

### Step 1: Create CDTs and CDTFs for Your Questions

Before adding conditions, you need:

1. **Trigger Field CDTF** – The field whose response triggers the condition
   * Type: Usually "List" (single-select) or "Multi-Select List"
   * Options: Must include a value that will trigger the condition
   * Example: A "Yes/No" list field or "Other" option in a dropdown
2. **Conditional Field CDTF** – The field that appears when condition is met
   * Type: Can be any field type (text, numeric, date, etc.)
   * Example: "Please specify" text area field

**Simple Example Structure:**

```
CDT: medical-history
  - has_allergies (List: Yes/No)  ← Trigger field
  - allergy_details (Long Text)    ← Conditional field (shown only if has_allergies="Yes")
```

**Complex Example Structure:**

```
CDT: patient-education
  - education_level (List: High School/Some College/Bachelor's/Other)  ← Trigger
  - other_education (Text)         ← Conditional 1 (shown if = "Other")
  - college_major (Text)           ← Conditional 2 (shown if = "Bachelor's")
  - years_of_college (Integer)     ← Conditional 3 (shown if = "Some College" OR "Bachelor's")
```

### Step 2: Create the Assessment/Form Template

1. In Designer, navigate to **Visual Components** > **Forms**
2. Create a new assessment or edit an existing one
3. Add the CDTs and fields you created above to the form
4. Arrange them in logical order
5. Save the form (don't publish yet)

### Step 3: Add Conditional Logic to the Assessment

1. In the form editor, locate the **Conditional Logic** section or **Form Rules**
2. Look for a button like **+ Add Condition**, **Add Rule**, or **Conditional Logic**

## Creating a Condition

### Basic Condition Structure

Most conditions follow this pattern:

```
IF [Trigger Field] [Condition Operator] [Value]
THEN Show [Conditional Field]
```

### Condition Configuration

1. **Select the Trigger Field** – Choose which field's response will trigger the condition
   * Typically a field that's already visible on the form
   * Usually a List or Multi-Select field
2. **Select Condition Operator** – Choose how to evaluate the trigger field:
   * **Equals** – Value exactly matches
   * **Not Equals** – Value does not match
   * **Contains** – Value includes specified text
   * **Does Not Contain** – Value does not include text
   * **Greater Than** – Value is numerically greater
   * **Less Than** – Value is numerically less
   * **Is Empty** – Field has no value
   * **Is Not Empty** – Field has a value
3. **Enter the Condition Value** – Specify what value triggers the condition:
   * Example: If operator is "Equals", enter the specific option (e.g., "Yes", "Other")
   * Example: If operator is "Contains", enter the substring to look for
4. **Select Field to Show** – Choose which field appears when condition is true:
   * This field will be hidden by default
   * It shows only when the condition is met
5. **Save the Condition** – Click **Save** or **Add Condition**

## Practical Examples

### Example 1: Show "Other, Please Specify" Field

**Scenario:** Employment status question with "Other" option that requires explanation

**Trigger Field:** `employment_status` (List: Employed/Unemployed/Self-Employed/Student/Other) **Conditional Field:** `employment_status_other` (Text: "Please describe your employment")

**Condition Configuration:**

```
IF employment_status EQUALS "Other"
THEN Show employment_status_other
```

**Result:**

* Patient sees employment status dropdown
* Selects "Other"
* "Please describe your employment" field appears
* Patient can now enter details

### Example 2: Progressive Disclosure Based on Response

**Scenario:** Medication adherence assessment that asks follow-up questions only for non-adherent patients

**Trigger Field:** `medication_adherence` (List: Always/Most of the Time/Sometimes/Never) **Conditional Fields:**

* `adherence_barriers` (Multi-Select: Cost/Forgetting/Side Effects/Other)
* `adherence_interventions_needed` (Text: "What would help you take your medications as prescribed?")

**Condition Configuration:**

```
Condition 1:
IF medication_adherence EQUALS "Sometimes"
THEN Show adherence_barriers

Condition 2:
IF medication_adherence EQUALS "Never"
THEN Show adherence_barriers

Condition 3:
IF medication_adherence IS NOT EQUAL "Always"
THEN Show adherence_interventions_needed
```

**Result:**

* Patients who always take medications see only one question
* Patients with adherence issues see additional follow-up fields
* Assessment is shorter and more relevant per patient response

### Example 3: Condition with Empty Field Check

**Scenario:** Insurance information only relevant if patient has insurance

**Trigger Field:** `has_insurance` (List: Yes/No) **Conditional Fields:**

* `insurance_provider` (Text)
* `insurance_group_number` (Text)
* `insurance_member_id` (Text)

**Condition Configuration:**

```
IF has_insurance EQUALS "Yes"
THEN Show insurance_provider
AND Show insurance_group_number
AND Show insurance_member_id
```

**Result:**

* If "No": Insurance fields remain hidden
* If "Yes": All three insurance fields appear

### Example 4: Numeric Range Condition

**Scenario:** Show depression severity interventions only for elevated scores

**Trigger Field:** `phq9_score` (Integer: 0-27) **Conditional Field:** `depression_interventions_recommended` (Text)

**Condition Configuration:**

```
IF phq9_score GREATER THAN 10
THEN Show depression_interventions_recommended
```

**Result:**

* Score ≤ 10: No intervention field shown
* Score > 10: Intervention recommendations field appears

## Advanced Conditional Patterns

### Multiple Conditions on One Field

Show a field when ANY of multiple conditions are true (OR logic):

```
IF department EQUALS "Cardiology" OR department EQUALS "Internal Medicine"
THEN Show cardiac_risk_factors
```

### Multiple Conditions (AND Logic)

Show a field only when ALL conditions are true:

```
IF age GREATER THAN 65 AND has_diabetes EQUALS "Yes"
THEN Show diabetic_management_plan
```

### Nested Conditions

Hide/show fields based on multiple levels:

```
IF has_allergies EQUALS "Yes"
  THEN Show allergy_type

  IF allergy_type EQUALS "Drug Allergy"
    THEN Show specific_drug_allergy
```

## Testing Conditional Logic

### Before Publishing

1. **Create a Test Assessment Instance** – As if completing the form
2. **Test Each Condition Path:**
   * Select trigger value that shows conditional field → verify it appears
   * Select trigger value that hides conditional field → verify it disappears
   * Test every option in the trigger field
3. **Test Edge Cases:**
   * Empty fields (if condition references empty field)
   * Multiple selections (if using Multi-Select)
   * Numeric boundaries (if using numeric operators)

### After Publishing

1. Have care team members test in Care app
2. Have patients complete via PFA link
3. Verify conditional fields appear/disappear as expected
4. Check that data is captured correctly when fields are hidden

## Troubleshooting

### Conditional Field Not Showing

**Problem:** Field should appear based on trigger value but doesn't

**Solutions:**

* Verify trigger field value matches condition exactly (case-sensitive)
* Check that conditional field is configured to show on the form
* Ensure condition operator is correct (e.g., "Equals" vs "Contains")
* Test with a different trigger value to isolate issue
* Check browser developer console for JavaScript errors

### Conditional Field Always Showing

**Problem:** Field is always visible regardless of trigger value

**Solutions:**

* Check if field is set as "always visible" in form properties
* Verify conditional logic was saved/published
* Confirm trigger field hasn't been renamed or removed
* Clear browser cache and reload

### Multiple Conditions Not Working Together

**Problem:** Complex conditions with AND/OR logic not behaving correctly

**Solutions:**

* Simplify conditions temporarily to test each separately
* Verify AND/OR logic is configured correctly
* Check parentheses or grouping of conditions
* Test with different trigger values

## Best Practices

1. **Group Related Questions** – Keep trigger and conditional fields close together on form
2. **Clear Labeling** – Use clear question text that explains why conditionals appear
3. **Avoid Complex Nesting** – Keep conditional logic simple when possible
4. **Test Thoroughly** – Test every conditional path before deployment
5. **Document Logic** – Include notes explaining why conditions exist
6. **Consider User Experience** – Don't overuse conditionals; can confuse users if overdone
7. **Mobile Testing** – Test conditionals on mobile devices for responsive behavior
8. **Performance** – Very complex conditional logic may slow form performance

## Limitations

* Conditions typically only reference fields within the same assessment form
* Cross-assessment conditions (based on fields from different assessments) may not be supported
* Conditional logic is evaluated client-side; complex calculations may not be possible
* Some field types may not support conditions

## Related Topics

* [How to Create an Assessment or Form Template](/designer/documents-and-assessments/how-to-create-an-assessment-or-form-template.md) – Form creation basics
* [Custom Data Types (CDT): Designer](/designer/custom-data-types/custom-data-types-cdt-designer.md) – Creating fields for conditions
* [Designer: How to Configure Scored Assessments](/designer/documents-and-assessments/designer-how-to-configure-scored-assessments.md) – Assessment scoring with conditionals
* [Forms: Conditional Logic](/designer/documents-and-assessments/forms-conditional-logic.md) – Detailed conditional logic reference
* [How to Associate Assessments with Programs](/designer/documents-and-assessments/how-to-associate-assessments-with-programs.md) – Program-based assessment visibility


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.welkinhealth.com/designer/documents-and-assessments/how-to-add-conditionality-to-assessments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
