vubiostat / redcapAPI

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

Bug in importMetaData #381

Closed berryld1 closed 5 months ago

berryld1 commented 6 months ago

importMetaData() is giving me an error on values in text_validation_type_or_show_slider_number: vmrn autocomplete Those are legit values (at least, vmrn is for VUMC redcap instance) "autocomplete" needs to be allowed for field_type = "dropdown", but not for text fields, weirdly. Redcap seems to have shoved this into the text_validation... field instead adding new field or something

spgarbet commented 6 months ago

Can you share the error output?

spgarbet commented 6 months ago

Is this what you're seeing? https://github.com/vubiostat/redcapAPI/blob/main/R/importMetaData.R#L188

berryld1 commented 6 months ago

That's the one! As well as line 212 in same, "The following fields should not have..." - that's with the "autocomplete", which redcap appears to have jammed into the text_validation_type_or_show_slider_number, but it's actually relevant for a dropdown field. So, in the case of that value only, okay to have content in this field for dropdown only. thank you!

spgarbet commented 6 months ago

The fix is up on the main branch. Can you test it and see if it works @berryld1 ?

berryld1 commented 6 months ago

please remind me for the millionth time how to install the edge version from gh? sorry!!!! i did write it down - but where???

spgarbet commented 6 months ago

devtools::install_github('vubiostat/redcapAPI')

berryld1 commented 5 months ago

Of course, I could not remember which project this was. For my future reference, CUSP. Anyhow, importMetaData still mad about the "autocomplete" in textvalidation... for dropdown fields: image

spgarbet commented 5 months ago

@berryld1 Try this latest attempt:

remotes::install_github("vubiostat/redcapAPI@6ef28e3df36150956fafa192e86754cb4a9633ee")
berryld1 commented 5 months ago

Nope, still made about that autocomplete. I think I installed correctly and had success; closed all my open session, opened a new session:

image

spgarbet commented 5 months ago

@nutterb What am I missing?

berryld1 commented 5 months ago

@spgarbet it's here: .isPropertyOnAppropriateField(field_name = data$field_name, field_type = data$field_type, permissible_field_type = c("text", "slider", "file"), property = data$text_validation_type_or_show_slider_number, property_name = "text_validation_type_or_show_slider_number", coll = coll)

The thing is - redcap has appropriated the text_validation_type_or_show_slider_number field for the "autocomplete" indicator for dropdown fields - so, it's a bit tricky, because a value in this field needs to be allowed for dropdown, but only this one value. Side question: Not sure what value would be in here for file? Can file type be restricted. Gonna go check that out!

spgarbet commented 5 months ago

@berryld1 Yes, that is what was patched.

remotes::install_github("vubiostat/redcapAPI@6ef28e3df36150956fafa192e86754cb4a9633ee")

should have installed this patch:

https://github.com/vubiostat/redcapAPI/commit/6ef28e3df36150956fafa192e86754cb4a9633ee

berryld1 commented 5 months ago

@spgarbet okay! I see.

So, there are two different things:

for the first one, you must have added "vmrn" and "autocomplete" to the global REDCAP_METADATA_VALIDATION_TYPE, because I no longer get the "illegal validation type" message (paraphrasing).

I ONLY get: "illegal field type for validation" (again, paraphrasing).

In that patch, you've added "autocomplete" and "vmrn" to the argument of permissible field_type to have a value in text_validation_type_or_show_slider_number.

But these will never be values in field_type (they are not valid field_type)- they will only ever be values in text_validation_type_or_show_slider_number.

In other words:

So... you could add "dropdown" to that argument (instead of adding "vrmn" and "autocomplete") - however, what I think really needs to happen is the check needs to be a little more sophisticated in checking field_type against the specific value in text_validation_type_or_show_slider_number - rather than each in isolation.

So: field_type = dropdown, text_validation_type... = "autocomplete" - good field_type = dropdown, text_validation_type = anything else - bad field_type = (current set), text_validation_type... = "autocomplete" - bad field_type = (current set), text_val.... = anything else in REDCAP_METADATA_VALIDATION_TYPE - good

How to get there? Over to you on that! (I also don't mind if you just add "dropdown" to the permissible field types argument in .isPropertyOnAppropriateField(), but I tend to think that's not what you'd want to do.)

spgarbet commented 5 months ago

Can you check that the appropriate patch installed properly. I.e.,

library(redcapAPI)
redcapAPI:::importMetaData.redcapApiConnection

and examine that it matches that patch.

As far as validation, these are pre call checks. Making the checks data dependent and interrelated is possible, but the first goal is to just get it accept and pass these parameters in those fields.

nutterb commented 5 months ago

I'll be able to take a look on Thursday. I'm wrapping up a 5 day, 100 mile cycling trip with a dozen scouts.

I will welcome a new challenge I can do sitting in a soft chair. 😂

spgarbet commented 5 months ago

@berryld1 Here's my understanding of your suggestion:

remotes::install_github("vubiostat/redcapAPI@0164472935da93e100a3d30cb0f6547cae20325a")

Let me know.

berryld1 commented 5 months ago

Bingo! That's the one! thank you!!!

spgarbet commented 5 months ago

Fix merged to main