Reputation: 89
I'm setting up some automated invitations for a survey on REDCap where form-2 is supposed to be sent 7 days after form-1 has been completed by a participant. The problem is there are participants who have already completed form-1 some time ago, so I can't select "Send the invitation 7 days after.." in Step 3 of automating invites, since the invite would be sent 7 days later to participants who should get them sooner.
So instead I'm trying to set up some logic in Step 2 to calculate the difference between the current date and the date form-1 was completed.
datediff('today',[survey-date-completed:form-1:value],'d',true) >= 7
In Step 2, I have "When the following survey is completed: form-1" AND the above logic check marked.
However, when I test with a record that had form-1 completed over 7 days ago, the logic returns false, and I'm not sure why.
I would greatly appreciate any help!
Upvotes: 0
Views: 235
Reputation: 16
It appears that [survey-date-completed:form-1:value]
does not work in the filter logic box because [survey-date-completed:form-1] != ""
returns False for me.
To get a readable survey date, you can create a new field date_surv_1
in form1 that pulls in the date using @CALCTEXT
. Create this field as a textbox, and within the "Action Tags / Field Annotation" box, enter:
@CALCTEXT([survey-date-completed:form-1:value])
@HIDDEN
@HIDDEN
prevents the field from showing up in the survey. This field will pull in the date whenever a new survey is completed but for old surveys, you will need to update the calculation. You can do this by going to Data Quality (under Applications on the left-hand side of REDCap), executing rule H, and clicking "View", and then clicking "Fix calcs now".
Finally, you should be able update the logic in Step 2 to this:
datediff('today',[date_surv_1],'d') >= 7
Note that I removed 'true' since the surveys will always be completed on or before today and the original function returned integers < 1.
I hope this resolves your issue.
Upvotes: 0