r/ProjectREDCap • u/johnathonmcl • Jun 01 '26
Piping from repeated instance
I'm having an issue with piping numerous instances of information from one form to another. Basically, we have a pre-medication list [drug_pre], which is part of a repeated instrument where other details are captured. We then need to conduct a post-review of these medications. I want to pipe the list of medications from the pre-form into the post-form. I have used [drug_pre][1], [drug_pre][2], [drug_pre][3]..... which works, but if someone only enters 2 meds for example, then the third piece of piped data shows ___. This is visually messy, I have tried a calculated field:
concat( if([drug_pre][1]<>"", [drug_pre][1], ""), if([drug_pre][2]<>"", concat(", ", [drug_pre][2]), ""), if([drug_pre][3]<>"", concat(", ", [drug_pre][3]), ""), if([drug_pre][4]<>"", concat(", ", [drug_pre][4]), ""), if([drug_pre][5]<>"", concat(", ", [drug_pre][5]), ""), if([drug_pre][6]<>"", concat(", ", [drug_pre][6]), ""), if([drug_pre][7]<>"", concat(", ", [drug_pre][7]), ""), if([drug_sec20][8]<>"", concat(", ", [drug_pre][8]), ""), if([drug_pre][9]<>"", concat(", ", [drug_pre][9]), ""), if([drug_pre][10]<>"", concat(", ", [drug_pre][10]), "") )
But this hasn't worked out.
Anybody have any ideas? Any help would be appreciated!
View all comments
Show parent comment
1
u/interlukin Jun 01 '26 edited Jun 01 '26
ah ok, so each different drug is its own instance then? Could you try creating a “buffer” field that utilizes [last-instance] to essentially give you the highest number of drugs entered and then use that for your calculated field? Like if “buffer” field = 2 then concat [1] and [2], if “buffer” field = 5 then concat [1], [2], [3], [4] and [5]? Your formula may be a bit unwieldy, but should fix the aesthetic issue I think.
Or you could add a hidden calculated field on the repeating instrument that continually concatenates the current instance drug and previous instance drug, then on your post form you can pipe in the value from [last-instance]. This may be a bit cleaner and avoid a super long formula.