Conditional Generation for Variables

Conditional Variable Generation lets you generate a variable value only when it’s truly needed. This feature reduces unnecessary compute, speeds up project runs, and gives you more precise control over how your variable library behaves.

Use it when certain variables only matter in specific clinical contexts, such as when a note is from a particular date range, contains a meaningful title, or when another variable has already signaled that it’s relevant.

Why Use Conditional Generation?

Conditional generation offers two major benefits:

1. Save Compute Cost

Each variable value run consumes tokens. If a variable is irrelevant for a large portion of your notes (e.g., oncology-specific questions run on primary care notes), conditional generation prevents Brim from generating that variable unnecessarily.

2. Save Time

By skipping unneeded LLM calls, your projects can finish faster. This is especially helpful for high-volume datasets.

Where do I find Conditional Generation?

You can find conditional generation in the "References" section of your Edit Variable screen in Project Setup.

Generation Conditions Based on Note Date

You can instruct Brim only to generate for documents with a certain date.


  1. Go to Conditional Generation and select "Note Date" as your leading value.
  2. Select your operator. Your options are:
    1. is on date
    2. is NOT on date
    3. is before
    4. is after
    5. is before or on
    6. is after or on
    7. is empty
    8. is NOT empty
    9. is in list
    10. is NOT in list
    11. is within
    12. is NOT within
  3. (for some operators) Choose what you want to compare to. This can be:
    1. a static date that you type in or choose with the date picker
    2. the value of an Input Variable
    3. For is in list & is NOT in list: a comma-separated list of static dates in YYYY-MM-DD format.
    4. For is within & is NOT within: a value, the + or - operator, and the number of days you want the value to be within.

Example:

Generate “Treatment Intent” only for notes dated after diagnosis.

Generation Conditions Based on Note Title

You can instruct Brim only to generate for documents with certain note titles.


  1. Go to Conditional Generation and select "Note title" as your leading value.
  2. Select your operator. Your options are:
    1. is equal to
    2. is NOT equal to
    3. is empty
    4. is NOT empty
    5. contains value
    6. does NOT contain value
    7. is in list
    8. is NOT in list
  3. (for some operators) Choose what you want to compare to. This can be:
    1. static text that you type in
    2. the value of an Input Variable
    3. For is in list & is NOT in list: a comma-separated list of text strings.

Generation Conditions Based on the Value of Another Variable


Scope Restrictions

Brim can only do conditional generation for a variable value if there's one clear value to reference for that value. Practically this means:

  • "Many Labels Per Note" variables cannot be used for conditional generation for any variable because it's ambiguous which variable value to use.
  • "One Label Per Note" variables cannot be used for conditional generation on One Per Patient variables because it is ambiguous which variable value to use.

The full list of scope restrictions is below.

Scope of Main Variable Condition on Many per Note Variable Condition on One per Note Variable Condition on One per Patient Variable
Many per Note NO

YES

(uses the value for that note)

YES

(uses the value for that patient)

One per Note NO

YES

(uses the value for that note)

YES

(uses the value for that patient)

One per Patient NO NO

YES

(uses the value for that patient)


How to Build a Generation Condition based on the Value of another Variable

Use the result of one variable to determine whether this variable should run or be skipped.

Examples:

  • Only generate “Metastasis Site” if “Evidence of Cancer” = True.
  • Only generate “NICU Discharge Readiness Criteria” if “Encounter Type” = NICU.

This is the most powerful way to focus compute where it matters.


  1. Go to Input Variables and add all variables you want to use for conditional generation to your list of Input Variables.
  2. Go to Conditional Generation
  3. Select the variable you want to use as your leading value.
  4. Select your operator. Your options depend on the data type of your leading variable.
    1. is empty
    2. is NOT empty
    3. is default value
    4. is NOT default value
    5. is in list
    6. is NOT in list
    7. is equal to (text, integer, float, boolean)
    8. is NOT equal to (text, integer, float, boolean)
    9. contains value (text)
    10. does NOT contain value (text)
    11. is on date (timestamp)
    12. is NOT on date (timestamp)
    13. is before (timestamp)
    14. is after (timestamp)
    15. is before or on (timestamp)
    16. is after or on (timestamp)
    17. is within (timestamp, int, float)
    18. is NOT within (timestamp, int, float)
    19. is less than (int, float)
    20. is greater than (int, float)
    21. is less than or equal to (int, float)
    22. is greater than or equal to (int, float)
  5. (for some operators) Choose what you want to compare to. This can be:
    1. static text that you type in
    2. the value of another input variable
    3. For is in list & is NOT in list: a comma-separated list of values
    4. For is within & is NOT within: a value, the + or - operator, and the interval that should be used for "within".

Combining Conditions: AND / OR

You can create complex logic by adding multiple conditions:

  1. Click "Add Condition+"
  2. Configure your new condition.
  3. Choose whether to combine your conditions using AND or OR.
    1. You can only use one across all of your conditions if you have more than 2 total.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.