> ## Documentation Index
> Fetch the complete documentation index at: https://docs.carelane.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Questionnaire Templates

> Create reusable data collection form templates

Questionnaire templates define the structure of data collection forms (CRFs) that can be reused across multiple studies.

## What are Questionnaire Templates?

Questionnaire templates are FHIR Questionnaire resources that define:

* Form structure (groups and fields)
* Field types and validation
* Conditional logic
* Calculated fields
* Instructions and help text

## Creating a Questionnaire Template

<Steps>
  <Step title="Navigate to Templates">
    Go to Organization > Templates > Questionnaires.
  </Step>

  <Step title="Create New">
    Click "Create Questionnaire Template".
  </Step>

  <Step title="Enter Details">
    Provide template name and description.
  </Step>

  <Step title="Open Editor">
    Access the questionnaire editor.
  </Step>

  <Step title="Build Structure">
    Add groups and items to define the form.
  </Step>

  <Step title="Save">
    Save the template.
  </Step>
</Steps>

## Questionnaire Editor

### Adding Groups

Groups organize related fields:

<Steps>
  <Step title="Add Group">
    Click "Add Group" in the editor.
  </Step>

  <Step title="Name Group">
    Provide a title (e.g., "Demographics", "Vital Signs").
  </Step>

  <Step title="Configure">
    Set group options (repeating, conditional).
  </Step>
</Steps>

### Adding Items

Items are individual fields within groups:

<Steps>
  <Step title="Add Item">
    Click "Add Item" within a group.
  </Step>

  <Step title="Select Type">
    Choose the item type (text, number, choice, etc.).
  </Step>

  <Step title="Configure">
    Set label, validation, and options.
  </Step>
</Steps>

## Item Types

### Text Fields

| Type       | Description          |
| ---------- | -------------------- |
| **String** | Single-line text     |
| **Text**   | Multi-line text area |

Configure:

* Max length
* Required/optional
* Placeholder text

### Numeric Fields

| Type         | Description           |
| ------------ | --------------------- |
| **Integer**  | Whole numbers         |
| **Decimal**  | Numbers with decimals |
| **Quantity** | Value with unit       |

Configure:

* Min/max values
* Decimal places
* Units

### Date/Time Fields

| Type         | Description   |
| ------------ | ------------- |
| **Date**     | Calendar date |
| **DateTime** | Date and time |
| **Time**     | Time only     |

Configure:

* Date format options
* Year/month only option

### Choice Fields

| Type            | Description                |
| --------------- | -------------------------- |
| **Choice**      | Single selection           |
| **Open Choice** | Choice with "other" option |
| **Boolean**     | Yes/No                     |

Configure:

* Answer options
* Display style (list or dropdown, available for both single-choice and multiple-choice questions)
* Default value

### Special Fields

| Type           | Description            |
| -------------- | ---------------------- |
| **Attachment** | File upload            |
| **Display**    | Read-only instructions |
| **Calculated** | Auto-computed value    |

## Conditional Logic

Make items appear based on conditions:

<Steps>
  <Step title="Select Item">
    Choose the item to make conditional.
  </Step>

  <Step title="Add Condition">
    Click "Add Enable When" condition.
  </Step>

  <Step title="Configure Condition">
    Select source field, operator, and value.
  </Step>
</Steps>

### Condition Types

| Operator         | Description           |
| ---------------- | --------------------- |
| **Equals**       | Value matches exactly |
| **Not Equals**   | Value doesn't match   |
| **Exists**       | Field has any value   |
| **Greater Than** | Numeric comparison    |
| **Less Than**    | Numeric comparison    |

## Calculated Fields

Create fields that compute values automatically:

<Steps>
  <Step title="Add Calculated Item">
    Add an item with calculated type.
  </Step>

  <Step title="Define Expression">
    Enter the FHIRPath calculation expression.
  </Step>

  <Step title="Test">
    Test the calculation with sample values.
  </Step>
</Steps>

### Example Calculations

| Calculation | Expression Example                            |
| ----------- | --------------------------------------------- |
| **Sum**     | `%context.item.where(...).answer.value.sum()` |
| **BMI**     | `weight / (height * height)`                  |
| **Score**   | `item1 + item2 + item3`                       |

## Validation Rules

Add validation to ensure data quality:

| Rule           | Purpose               |
| -------------- | --------------------- |
| **Required**   | Field must have value |
| **Min/Max**    | Numeric range         |
| **Max Length** | Text length limit     |
| **Pattern**    | Regex matching        |

## Scoring

For assessment questionnaires:

* Assign point values to answer options
* Configure automatic score calculation
* Display scores inline or at summary level

## Template Settings

### Metadata

| Setting         | Description                     |
| --------------- | ------------------------------- |
| **Name**        | Template display name           |
| **Description** | What the questionnaire captures |
| **Version**     | Version identifier              |
| **Status**      | Draft, active, or retired       |

### Visibility

| Setting     | Options                      |
| ----------- | ---------------------------- |
| **Public**  | Visible to all users         |
| **Private** | Visible to organization only |

## Using in Studies

<Steps>
  <Step title="Import to Study">
    In study design, import the questionnaire template.
  </Step>

  <Step title="Customize if Needed">
    Modify for study-specific requirements.
  </Step>

  <Step title="Add to Pathway">
    Include in participant pathways.
  </Step>
</Steps>

## Best Practices

<AccordionGroup>
  <Accordion title="Logical Grouping">
    Group related fields together for easier data entry.
  </Accordion>

  <Accordion title="Clear Labels">
    Use clear, unambiguous field labels.
  </Accordion>

  <Accordion title="Appropriate Validation">
    Add validation to catch errors early.
  </Accordion>

  <Accordion title="Test Thoroughly">
    Test templates with realistic data before use.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Questionnaires" icon="file-lines" href="/data-collection/questionnaires">
    How questionnaires work in data collection.
  </Card>

  <Card title="Governance" icon="shield-check" href="/templates/governance">
    Template management and versioning.
  </Card>
</CardGroup>
