OuhscBbmc / REDCapR

R utilities for interacting with REDCap
https://ouhscbbmc.github.io/REDCapR
Other
112 stars 45 forks source link

Pipes in checkbox entry #503

Open wibeasley opened 11 months ago

wibeasley commented 11 months ago

@BlairCooper, if you're itching for a regex challenge (similar to #500, #501, #502)... what can you do if the entry contains pipes?

I think I'm ok documenting that users shouldn't use pipes and expect this to work correctly. But if you're up for it, I'm curious if any solution exists.

image

From data dictionary:

"1, American Indian/Alaska Native | -2, Asian | 3, Native Hawaiian |or| Other Pacific Islander | 4, Black or African American | 5, White | 66, Unknown / Not Reported"
nutterb commented 8 months ago

I'm certain that this is impossible. Deconstructing the problem:

REDCap identifies codes and labels on the algorithm [code] [first comma] [label] [line break]

There's no restriction on [label] preventing the user from including commas or or pipes.

Unfortunately, when the API pushes out the definitions, it replaces the line break with a pipe. So there is no dedicated character for delimiting one code-label pairing from another. Quite literally, what we receive from the API is fundamentally different than what REDCap is parsing on its side.

So the combination of 1) replacing the line break with the pipe, and 2) allowing both pipes and commas in the label makes it impossible to generalize a solution that can properly parse labels that include a pipe.