-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding dateRangeBegin and dateRangeEnd to redcap_read #321
Comments
@pbchase, that would be a different date field for every project, correct? (eg, dob in some projects, specimen collection in others.) How about precomputing the datetime boundary and pass them to the datetime_start <- Sys.time() - lubridate::hours(24)
born_yesterday <- strftime(datetime_start, "%Y-%m-%d %H:%M:%S < [dob]") # Cast to a string w/o the timezone?
ds <-
REDCapR::redcap_read(
redcap_uri = uri,
token = token,
filter_logic = born_yesterday
)$data The value of the If this solves the performance issues, I'll stick an example in the Advanced REDCapR Operations vignette. There's a chance it isn't much faster. I'm guessing that even if yesterday's births are only 100 (our of 200k) records, MySQL is still retrieving all those obs, and the PHP is pivoting to wide (in order to connect |
I agree that your style of date constraint is easier to express in R and more reliable than using REDCap's datediff. Many thanks for that. Yet when I run similar tests in PHP or Curl, the filter logic is unreliable in execute. It keeps returning the entire dataset. REDCap filter logic is not great and it is less great via the API and with dates. Yet that is all beside the point as
The execution is fast. It returned the last two hours of update traffic--614 record IDs--in 1.0 seconds from a project of 12K records. These options are perfect for my goal which is data synchronization with low I/O cost and reduced clock time. I really think these could be worthwhile. Would you entertain a merge if we made a PR? |
I gotcha. So these would need a change to REDCap itself (to connect the event log table to the eav table) and then a change to REDCapR? The former would be a lot more work. Adding a new parameter (plus input validation and testing) to REDCapR is typically only an hour or two. Of course, any PR is welcome. Tell me when you guys start doing it, and I'll help create a REDCap project or two that are dedicated to the unit test for dateRangeBegin/End |
Thanks for the code, @pbchase. I made one minor change: the R function accepts a POSIXct value, so it's guaranteed to be a valid datetime. Then REDCapR uses I added some simple tests too. |
Has anyone considered implementing
dateRangeBegin
ordateRangeEnd
options in redcap_read? We'd love to read only the past hour of updates for some queries. We often use redcap'sdatediff
infilter_logic
, but it is difficult to use and solves a slightly different problem.We might entertain the idea of adding the
dateRangeBegin
option toredcap_read
but I wouldn't want to go down a path that has already proven fruitless. Has anyone tried these options? Are they performant? I need to turn a 20k record read into a 100 record read.The text was updated successfully, but these errors were encountered: