> ## 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.

# AI Pathway Builder

> Let the AI propose pathway structure, section contents, and questionnaire edits inline in the editor

The AI Pathway Builder proposes structural changes to a participant pathway as inline "ghost" suggestion cards — faded previews that appear in the pathway editor alongside your existing content. You accept, reject, or accept-and-continue each suggestion; the AI updates the underlying CRF version only on acceptance.

## What It Does

Three AI tools are available when you are editing a CRF version (participant pathway):

| Tool                   | What it proposes                                                                                        |
| ---------------------- | ------------------------------------------------------------------------------------------------------- |
| **Pathway Outline**    | Section titles and descriptions — the skeleton of the pathway                                           |
| **Section Detail**     | Question groups and activities that fill a specific section                                             |
| **Questionnaire Edit** | Additions, removals, reorders, or modifications to an existing question group, shown as a coloured diff |

The AI decides which tool to call based on your prompt and the current state of the pathway. A typical flow is outline → detail-per-section → targeted edits to refine individual question groups.

## Where It Runs

* Open a **CRF version** and open the AI Agent side panel.
* Ask the AI to help build or modify the pathway. For example: *"Draft a pathway for a 12-week safety follow-up with screening, baseline, week 4, week 8, and end-of-study visits."*
* Suggestions render inline in the pathway editor — not in the chat panel.

<Note>
  Only **Draft** CRF versions are editable. Testing, Approved, and Retired versions are locked, so suggestions cannot be applied to them — copy them as a new draft first. See [Pathway Versioning](/study-design/pathway-versioning).
</Note>

## Ghost Suggestion Cards

Suggestions appear as dashed-border cards positioned where they will be inserted:

* **Green cards** — new sections, question groups, or activities to add
* **Orange cards** — edits to existing content, shown as a diff with added, removed, and unchanged lines highlighted

Each card carries three buttons:

| Button                  | Behaviour                                                                     |
| ----------------------- | ----------------------------------------------------------------------------- |
| **Accept**              | Apply the suggestion and dismiss the card                                     |
| **Accept and continue** | Apply the suggestion, then prompt the AI to keep going from where it left off |
| **Reject**              | Dismiss without applying; the AI learns not to re-suggest the same thing      |

When suggestions are off-screen, a sticky "*N* suggestion(s) above/below" button appears in the editor so you can scroll to them.

## Auto-Continuation

**Accept and continue** is the fastest way to build a pathway end-to-end: accept an outline, then let the AI populate each section one suggestion at a time, reviewing as you go. Behind the scenes the editor sends the AI a short "continue where you left off" prompt so you do not have to re-describe what you want on every step.

## PDF-Driven Extraction

You can seed the AI with a protocol PDF:

<Steps>
  <Step title="Upload the Protocol">
    Upload the PDF to Study Documents.
  </Step>

  <Step title="Attach to the Chat">
    Open the AI Agent side panel in the pathway editor and attach the PDF.
  </Step>

  <Step title="Ask for a Pathway">
    Prompt the AI to draft a pathway based on the schedule of activities in the document.
  </Step>

  <Step title="Review Suggestions">
    The AI extracts the PDF contents (preserving tables, lists, and section structure) and proposes matching pathway structure as ghost cards.
  </Step>
</Steps>

<Tip>
  Extracted PDF content is cached. Re-attaching the same document in a later conversation is instant.
</Tip>

## Permissions

Using the AI Pathway Builder requires the **Study AI Prompts** permission. Roles that carry it by default:

* Chief Coordinating Investigator
* Deputy Coordinating Investigator
* Study Administrator

Users without this permission still see the CRF version they are viewing, but the AI tools do not appear in their chat panel.

## Best Practices

<AccordionGroup>
  <Accordion title="Start with the Outline">
    Ask for the outline first, review and adjust, then ask for section detail. It is easier to course-correct at the outline level than after a hundred questions are proposed.
  </Accordion>

  <Accordion title="Reject Quickly">
    Rejecting a bad suggestion teaches the AI faster than editing it post-acceptance. Use Reject generously.
  </Accordion>

  <Accordion title="Work in a Draft Version">
    Always build or refactor pathways inside a Draft CRF version. You can promote to Testing and then Approved when you are confident — see [Pathway Versioning](/study-design/pathway-versioning).
  </Accordion>

  <Accordion title="Cite Your Protocol">
    Attach the protocol PDF so the AI can ground suggestions in your actual study design rather than general clinical convention.
  </Accordion>
</AccordionGroup>

## Limitations

* AI Pathway Builder operates only on **CRF versions** (participant pathways), not study pathways or site workflows.
* Suggestions are best-effort. Always review clinical logic (eligibility, conditional branching, scoring) before approving a version.
* The AI cannot modify locked versions directly — Testing, Approved, and Retired CRF versions are immutable by design.

## Related

<CardGroup cols={2}>
  <Card title="Pathway Versioning" icon="code-branch" href="/study-design/pathway-versioning">
    Draft, Testing, Approved, and Retired lifecycle.
  </Card>

  <Card title="Conversational AI" icon="comments" href="/ai-features/conversational-ai">
    The AI Agent side panel and model selection.
  </Card>
</CardGroup>
