I am new to REDCap, Usually I work in C# .Net. I have a field inside a repeating instrument. I need to check the past three instances of that field to see if they match.
I have tried [weight][previous-instance]
to get the most recent and that worked for one, but when I try to get the other two, I am finding it difficult to get those without hard-coding a 1,2,3 in there like so: [weight][1], [weight][2], .... n
.
I would like to be able to step through the past three values similar to .Net where I can set:
short maxInstance = current-instance;
for(short i=1; i <= maxInstance; i++;)
{
weight[i];
}
like that.
Can that be done in REDCap?
As far as I'm aware, REDCap currently only has 3 smart variables specific to repeating instruments that are aware of relative instances of that repeating instrument: [current-instance]
, [previous-instance]
, and [next-instance]
. So while you cannot go back to make sure the previous three weights are the same within REDCap, you may be able to do so anyway by leveraging the REDCap API to export your data to your programming language of choice and do it there using the redcap_repeat_instance
variable that gets exported. Of course, this assumes that you have the User Rights enabled to grant you API Export permissions for your specific REDCap project.
There are a number of tools available in different languages, and REDCap also provides an "API Playground" with example code snippets for various languages, such as R, Python, Julia, Perl, and cURL. Hope that helps :)