REDCap conditional logic in automated survey invitations - date of scheduled invitations not changing

338 views Asked by At

I am trying to trigger a questionnaire to be sent 3-months after a specified date (which will be different for all my research participants - I will enter the date into the field date_insulation_completed). I also need participants to have completed their baseline surveys and for me to have checked a box saying insulation completed.

enter image description here

My question is - if I change the specified data_insulation_completed field should the logic automatically refresh inline with this new date - i.e., if the insulation was due to be completed tomorrow but now it will be a week later due to delays will the 3-month survey circulation date also shift - i've clicked 'Ensure logic is still true before sending invitation' however when I test this with different dates the dates of the schdeduled invites that are due to go out don't change from their original scheduled date.

1

There are 1 answers

0
Jangari On

The moment an ASI is triggered, its send date is fixed and cannot be programmatically updated (you can manually change it from the survey invitation log, clicking the pencil icon and entering a new date). By using the option to send based on a date field, REDCap will look to the value of that field when the record satisfies the other logic (conditions in step 2), and schedule the email based on the offset you've defined. So if the date then changes, the ASI will not.

There are two ways around this problem:

1. Make sure the ASI is triggered only when the [date_insulation_completed] has its correct value

This depends on your setup, but if there's something that you can reference in logic that would only be true when the [date_insulation_completed] field has been updated, then incorporate that logic in Step 2. In your case it could be simpler.

In your existing logic you have [insulation_complete]='1'. You mentioned above that this is a field that you check off before the participant has their ASI scheduled. If you wait until the [date_insulation_completed] date is confirmed before checking the [insulation_complete] field, you should get the behaviour you want.

2. Configure the ASI to trigger when the period between [date_insulation_completed] and today's date is 90 days

This is how we used to have to configure ASIs whose send-date related to other date fields in the past, before REDCap introduced the 'send X days after/before [datefield]' option. But due to the slightly different way it works, it is more controllable.

Update the logic in step 2 to the following:

[insulation_complete]='1' AND datediff([date_insulation_completed], 'today', 'd', true) >= 89

And then change step 3 to send the alert 'the next day' at a time of your choosing.

The datediff function will cause REDCap to check the logic for this alert every day (every 4 hours as a matter of fact) to see if it is true yet. It will become true 89 days after the [date_insulation_completed] date, and as this is re-checked every day, it is sensitive to that date field being updated.

Then, on the day it is true, the ASI is triggered and its date set in stone, as the next day at the time you selected in Step 3.

This setup is more difficult to test. You might have to set the delay to 1 day instead of 89 so you don't have to wait 3 months for a test record to come through, only to find out that it should have been 88 days. I would manually set the [date_insulation_completed] date to 87 days in the past and then only have to wait one or two days.

Why not just use 90 days in the datediff and send immediately?

Since REDCap checks the datediff logic every four hours, the first check for this is going to be between midnight and 4:00 on the 89th day since [date_insulation_completed]. If you used the 'send immediately' option, the participant would receive their email at a pretty bad time. So triggering the ASI the day before, and then using the option to send the next day, allows you to set the precise time.

Why >=89 and not just =89?

Why do you use the greater than or equal to with the datediff? If you used =, then you would have to also have the 'ensure logic is still true before sending' option unchecked, as REDCap will continue checking the logic every four hours, and if it becomes untrue, it will delete the ASI. This would happen if you waited for the next day to send. In other words, datediff(...) = 89 will be true on exactly one day, whereas >=89 will be true on that day and every day thereafter.