Lucy Ranieri
Lucy Ranieri

Reputation: 21

How to automatically select a categorical variable based on calculated number in REDCap?

I am creating a REDCap tool which gives patients a numerical acuity score based on their medical history. Each numerical score also corresponds to a color code (Green 1-3, Yellow 4-6, Red 7+) that nurses use. Is there a way to automatically display the name of the color code based on the acuity score?

I wanted to use something like a calculated field but it apparently cannot return text answers.

Upvotes: 2

Views: 837

Answers (1)

Jangari
Jangari

Reputation: 868

If you are on a sufficiently recent version, you can use the @CALCTEXT action tag to return the colour code based on the value:

@CALCTEXT(if([acuity]<=3,'Green',if([acuity]<=6,'Yellow','Red')))

Another way (or if you don't have @CALCTEXT) is to have a calculated 'helper' field and use its value in a @DEFAULT action tag. So, a field [acuity_code] would have the calculation:

if([acuity]<=3,1,if([acuity]<=6,2,3))

Them, a field [acuity_colourcode] could have these options:

1, Green
2, Yellow
3, Red

And an action tag:

@DEFAULT='[acuity_code]'

[acuity_colourcode] must be on a different form or page, as piping into @DEFAULT requires that the value exists in the database on page load; it's not dynamic or performed in-browser like branching logic or a calculation. So [acuity] and [acuity_code] would be on one page, and [acuity_colourcode] would be on a subsequent page.

Upvotes: 2

Related Questions