Recipe: branching a study on an answer

What you get: a study whose participants follow different paths, decided by an answer on a form. Everyone completes the same forms up to the point where the paths split. From there, each participant sees only the forms for their own path, in the app and on their record, with no one on your team placing them by hand. Correct the answer and the participant moves to the other path.

What you need: one form that holds the deciding answer, a group per path with automatic membership switched on, and the path's forms scoped to that group.

This recipe joins up features that each have their own article. Read those for the details of each setting, then come back here for how they fit together:

Two kinds of branching

Trialflare branches in two places, and it is worth being clear which one you need.

Within a form, a field's Show if condition shows or hides a question depending on an earlier answer on the same form. Use this when the paths differ by a few questions. See Stages: Configuring a field.

Across the study, which is what this recipe covers, a whole set of forms applies to some participants and not others. Use this when the paths have their own forms, their own schedule, or their own visits.

The example

The steps below build a study that splits at baseline:

  • Everyone completes Eligibility and Baseline.
  • Baseline includes a choice field, Treatment pathway, with the options Surgery and Medication.
  • The surgical path has a Pre-operative assessment, an Operation note that staff complete, and follow-ups at 30 and 90 days after surgery.
  • The medication path has a weekly Medication diary for twelve weeks.

Swap in your own forms as you go. The shape stays the same whether you have two paths or six.

Step 1 — Map the study before you build it

Write down three lists:

  1. The shared forms that everyone completes, whatever their path. These are left unscoped, which is the default.
  2. The deciding question: the form it is on, the field, and which answer leads to which path.
  3. The forms for each path.

The deciding question has to be a field Trialflare can test, such as a choice, a yes/no or a number. Each path is described the way a Show if condition is: is equal to, is not equal to, is more than, is less than or has an answer. If your paths are decided by a judgement call rather than an answer, see Paths chosen by a person below.

Step 2 — Build the deciding form

Build Baseline as normal, with Treatment pathway on it. Two things matter here:

  • Make the field required. A blank answer never puts anyone on a path. Someone who skips the question stays on the shared forms only, and nothing flags it.
  • Leave the form unscoped, or scope it no more narrowly than the participants who need to answer it. A deciding form scoped to one of its own paths could never be seen by anyone not yet on that path, so no one would ever join.

The deciding form can be completed by the participant in the app, or by staff on their record. Membership follows the answer whoever entered it.

Step 3 — Create a group for each path

Go to Participants > Participant groups and create one group per path: Surgical pathway and Medication pathway. Give each a distinct colour, since that colour is how you will recognise the path on tags throughout the interface.

On each group, tick Add participants automatically and choose When they give a particular answer on a form:

Group Stage Condition
Surgical pathway Baseline Treatment pathway is equal to Surgery
Medication pathway Baseline Treatment pathway is equal to Medication

When you save the rule, participants already in the study are checked in the background. Anyone whose Baseline already meets the condition joins straight away.

A catch-all path. For a "standard care" path that everyone not on a named path should follow, use is not equal to with the named paths' options selected. It still needs an answer, so it does not catch participants who have not reached the deciding form yet.

Step 4 — Scope each path's forms to its group

Open each path's forms in turn, go to the Availability tab and, under Stage scope, choose Add scoping rule and then Group:

  • Pre-operative assessment, Operation note and the follow-ups: Surgical pathway.
  • Medication diary: Medication pathway.

A participant in neither group sees none of these forms. That covers everyone who has not completed Baseline yet, so each path's forms appear for a participant only once their answer puts them on it.

Back on the stage list, each scoped form carries a badge naming its group. Run your eye down it to check that every path form is scoped, and that no shared form is.

Step 5 — Schedule each path from the point it starts

This is the step most often got wrong.

A stage set to plain Available to participants counts as due from the day the stage was created, not from the day a participant reaches it. When someone joins a path weeks into the study, that path's forms appear already overdue, and once the participant has submitted anything themselves they are immediately marked behind schedule.

Schedule each path's first form from the decision instead. Either of these works:

  • Make available after… Baseline completion, with a delay of 0 days or more. Use this for the medication path: set the Medication diary to repeat every 7 days, 12 times, and make it available after Baseline. The whole series is then scheduled from the day Baseline was completed.
  • An anchor. Use this when the path runs to a date of its own, such as surgery. Create a Surgery date anchor, set by hand or by When a stage is completed from a date field on the Operation note. Then make the follow-ups Anchor-scheduled at day 30 and day 90. See Anchors.

Forms that only staff complete, such as the Operation note, can stay Not available to participants. Scoping still applies to them, so the form appears on the records of surgical participants only.

Step 6 — Tidy up the participant record (optional)

On a study with several visits, give each path its own stage groups, for example Surgery: pre-op, Surgery: follow-up and Medication: diaries. On a participant's record, a stage group tab is hidden when none of its stages applies to that participant. Staff on the surgical path never see the medication tabs, and the reverse.

Step 7 — Reach each path separately (optional)

Automatic membership gives you a group you can use anywhere else that takes one:

  • Messages. Under Messages > Automatic, a scheduled or anchor-based message can be sent to one group's members only, so each path gets its own reminders and instructions.
  • Staff access. Group permissions can limit a member of staff to the participants on one path, which suits a team where each path has its own clinicians.
  • The participants table. Filter it by group, or use View participants on the group, to see who is on each path. A small lightning icon on a group tag means a rule added that participant, not a person.

Step 8 — Test both paths before you go live

Create one test participant per path and walk each one through:

  1. Complete the shared forms, and check that no path forms appear yet.
  2. Complete Baseline with the answer for this path.
  3. Check that the participant has joined the right group, with the lightning icon on its tag.
  4. Check that the participant sees this path's forms and none of the other path's, both in the app and on the Responses tab of their record.
  5. Check that the first path form is due from today, not from some date in the past.
  6. Change the answer on Baseline and check that the participant moves to the other path.

Archive or delete the test participants before you start recruiting.

What happens when the answer changes

Correcting the deciding answer moves the participant. They leave the group the rule put them in, join the group for the new answer, and the forms they can see change to match.

Nothing is lost when that happens. Any form from the old path that already holds data stays on their record, marked Not for this participant. Every join and leave is recorded in the trial's event log under Settings > Logs as a group change made by the system, with the rule that caused it.

Progress follows the path. A participant's completion percentage counts only the forms they can see, so a participant on the medication path is not held back by surgical forms, and a switch of path can move their percentage in either direction.

Paths chosen by a person

Not every study decides the path from an answer. In a randomised study, the arm is allocated, not answered. Scoping works exactly the same way with a group you fill yourself: allocate participants to arm groups by hand or in bulk (round robin, random uniform or random blocks when you create them; see Participant management), and scope each arm's forms to its group. Steps 4 to 8 apply unchanged.

You can also mix the two. Adding a participant to a rule's group by hand takes that membership out of the rule's hands: the rule never removes them, whatever their answer later says. To move a participant to a different path for good, correct the deciding answer rather than removing them from the group. A rule whose condition the participant still meets puts them back the next time the deciding form is saved, or the rule is changed.

Going further

Paths within paths. Put a second deciding question on a form inside a path, and scope that form to the path. For example, a Post-operative complications form on the surgical path could fill a Complications follow-up group. The second split then only ever happens within the first.

Paths that differ by site. Scope a form to a group and to a site, and it reaches only participants who are in both. Use this when one site runs a variant of a path's form.

Branching at screening. The deciding form can be a screening questionnaire. When a submission is allocated to a participant, its answers are checked against your rules straight away, so a participant can arrive on the right path at the moment they are enrolled. The consent and screening recipe builds the front half of that flow.

Groups that follow progress. A group can also fill itself when a participant starts or completes all their forms, which is useful for an "Onboarded" or "Completed" group to message. Such groups cannot be used to scope a stage, because the scoping would change the progress that decides membership. They are not offered there.

What this flow will not do for you

A repeated deciding form adds paths but does not take them away. On a form completed more than once, one matching submission is enough to join a group, and a later submission that does not match does not take the participant out. If the deciding question is asked at every visit, a participant can end up on two paths. Put the decision on a form that is completed once.

A path cannot follow a score. Rules test one field's answer, not a form's total score. If the path depends on a score, have staff record the outcome as a choice and branch on that.

No answer means no path. A participant who has not answered the deciding question sees the shared forms only, and isn't flagged for it. To catch them, look for participants who have completed the deciding form but carry none of the path groups' tags.