vubiostat / redcapAPI

R interface to REDCap (http://www.project-redcap.org/)
21 stars 27 forks source link

move DS validation from hard-coded to function driven #392

Open couthcommander opened 5 months ago

couthcommander commented 5 months ago

This PR is to create a discussion. do not merge

Rather than hard-code validation into vectors/data.frames (which will not support branching logic with version), the code in "redcapDataStructure" could be updated into functions. This could grow into something very difficult to maintain. I have an incomplete version to at least start a dialogue about the best approach. I have moved the hard-coded information into a CSV file.

couthcommander commented 5 months ago

Here's an example - the old approach:

REDCAP_SYSTEM_FIELDS <- c("redcap_event_name", 
                          "redcap_data_access_group", 
                          "redcap_repeat_instrument", 
                          "redcap_repeat_instance",
                          "redcap_survey_identifier")

incomplete approach:

REDCAP_SYSTEM_FIELDS <- .getStructure('f_SYSTEM', '14.4.0')

The final approach would replace all instances of "REDCAP_SYSTEM_FIELDS" with .getStructure('f_SYSTEM', rcon$version())

spgarbet commented 4 months ago

@couthcommander I changed this to a draft PR.

spgarbet commented 4 months ago

@nutterb thoughts?

The existing structure is easier but will grow increasingly complex over time. This is to make it driven by an editable configuration file.

nutterb commented 4 months ago

Ignore my previous comment. For some reason I thought @couthcommander 's work used a json file somewhere. And then proceeded to describe exactly what he has coded.

I think I might be sleep deprived.

But yes, I think this is a necessary change. And having independently determined that this approach would be a feasible strategy, I'm on board with it.

spgarbet commented 3 months ago

I'm ready for this to move from draft to being considered.