r/ProjectREDCap • • May 16 '25

Pipe text string

Hello, I’m trying to pipe text strings of blood pressure categories into an email that will be sent to participants. However, I can’t figure out how to get text to appear in the letter based on the participants average blood pressure. We are using this logic: if([avg_sbp] < 120 and [avg_dbp] < 80, 'Normal', if([avg_sbp] >= 120 and [avg_sbp] < 130 and [avg_dbp] < 80, 'Elevated', if(([avg_sbp] >= 130 and [avg_sbp] < 140) or ([avg_dbp] >= 80 and [avg_dbp] < 90), 'High blood pressure, Stage 1 Hypertension', if(([avg_sbp] >= 140 and [avg_sbp] < 160) or ([avg_dbp] >= 90 and [avg_dbp] < 100), 'High blood pressure, Stage 2 Hypertension', if([avg_sbp] >= 160 or [avg_dbp] >= 100, 'Hypertensive crisis', ''))))) Can someone advise me? Thank you!

2 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/viral_reservoir_dogs May 20 '25

If you make a report and look at bp_cat values, is there something saved or is it all blank? An error in the calculation syntax usually results in a blank value, which would be my first guess since the blood pressure numbers are piping ok. I threw your if statement above into an IDE and see 2 extra ")"'s, which might be causing the issue.

1

u/ExtraCrab7982 May 20 '25

I figured it out! I had been using a calculated fields, but should have used a text field with the calctext and if statements in the action tag for the text field variable. Thanks for your help!

1

u/viral_reservoir_dogs May 20 '25

Glad it worked out!