CHOP-CGTInformatics / REDCapTidieR

Makes it easy to read REDCap Projects into R
https://chop-cgtinformatics.github.io/REDCapTidieR/
Other
32 stars 8 forks source link

Both repeating and nonrepeating instances #169

Closed bcuer closed 7 months ago

bcuer commented 7 months ago

Hello,

I appreciate your package's utility for REDCap and R integration, especially for providing databases organized into separate data tables and for maintaining factor formats and labels. Thank you for your job.

I'm encountering an issue with importing data from repeated forms. Here's an example from a test database: a laboratory results form repeats during monthly visits (M01, M02, M03) but not during enrollment. This is a situation I regularly encounter in real clinical databases hosted on REDCap.

When using the REDCapTidieR package and the read_redcap function, it produces this error:

Error in clean_redcap_long(): 
✖ Instruments detected that have both repeating and nonrepeating instances 
defined in the project: lab_date, lab_albu, lab_creat, lab_chol, and resultats_laboratoire_complete.

To better understand, attached is a screenshot of the test database:

REDCapTidiesR_issue_screenshot

Currently, I can avoid importing this form, and the process succeeds. My question is: how can I import all data, including all forms? I can also make the data accessible via the API to replicate the error if needeed.

Thank you for your assistance.

Benjamin

skadauke commented 7 months ago

Hi, by design REDCapTidieR doesn't work with instruments that have repeating and non-repeating instances. This is because otherwise the resulting table (resultats_laboratoire) has inconsistent granularity, which violates tidy principles. Can you make the table repeating in the "Enrolement" event? This should fix things.


From: bcuer @.> Sent: Friday, January 26, 2024 9:15 AM To: CHOP-CGTInformatics/REDCapTidieR @.> Cc: Subscribed @.***> Subject: [External][CHOP-CGTInformatics/REDCapTidieR] Both repeating and nonrepeating instances (Issue #169)

Hello,

I appreciate your package's utility for REDCap and R integration, especially for providing databases organized into separate data tables and for maintaining factor formats and labels. Thank you for your job.

I'm encountering an issue with importing data from repeated forms. Here's an example from a test database: a laboratory results form repeats during monthly visits (M01, M02, M03) but not during enrollment. This is a situation I regularly encounter in real clinical databases hosted on REDCap.

When using the REDCapTidieR package and the read_redcap function, it produces this error:

Error in clean_redcap_long(): ✖ Instruments detected that have both repeating and nonrepeating instances defined in the project: lab_date, lab_albu, lab_creat, lab_chol, and resultats_laboratoire_complete.

To better understand, attached is a screenshot of the test database:

REDCapTidiesR_issue_screenshot.png (view on web)https://github.com/CHOP-CGTInformatics/REDCapTidieR/assets/42000413/b1d18f14-e6e0-41d5-82a4-63d00e9f396c

Currently, I can avoid importing this form, and the process succeeds. My question is: how can I import all data, including all forms? I can also make the data accessible via the API to replicate the error if needeed.

Thank you for your assistance.

Benjamin

— Reply to this email directly, view it on GitHubhttps://github.com/CHOP-CGTInformatics/REDCapTidieR/issues/169, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACTGHWQ2QYPYK6ITVXVJDLDYQO3AJAVCNFSM6AAAAABCMGX2WOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGEYDEMRYG44TKMA. You are receiving this because you are subscribed to this thread.Message ID: @.***>

This email originated from an EXTERNAL sender to CHOP. Proceed with caution when replying, opening attachments, or clicking links. Do not disclose your CHOP credentials, employee information, or protected health information to a potential hacker.

bcuer commented 7 months ago

Thank you for your prompt and precise response. I appreciate the points you've raised. The proposed solution here works effectively. To further enhance it, it would be beneficial to restrict the number of instances in REDCap to one in this context. Benjamin

rsh52 commented 7 months ago

Thank you for addressing @skadauke and for bringing up the question regardless @bcuer.

I will close this issue for now, but we can consider reopening should there be anything else to address.

brianmsm commented 7 months ago

I have a question as to whether this Redcap project structure is planned to be supported with repeated and non-repeated instruments.

rsh52 commented 7 months ago

I have a question as to whether this Redcap project structure is planned to be supported with repeated and non-repeated instruments.

Hi @brianmsm. REDCapTidieR supports REDCap projects that have repeating and non-repeating instruments separately. This specific case of having a single instrument that is both repeating and non-repeating is not supported, and likely will not be. As @skadauke mentioned, this violates the tidy principles our package abides by. You can also refer to our vignette on longitudinal projects for more information.

brianmsm commented 6 months ago

Hi @rsh52 . I understand. I also saw that the way it would work would be for the instrument to be enabled to repeat on events that are not doing so. Unfortunately this is not always in the control of the analyst. I wish there was a way to bypass this tidy principle check.

skadauke commented 6 months ago

Hi, I thought this might come up at some time. I think we could consider implementing a solution where a nonrepeat instrument in this context is treated like a repeat instrument with only one repeat throughout. Thoughts?

rsh52 commented 6 months ago

We could. Two things to consider: