Skip to content
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

Add number_*dp and time* text validation types #27

Open
pbchase opened this issue Mar 5, 2025 · 0 comments
Open

Add number_*dp and time* text validation types #27

pbchase opened this issue Mar 5, 2025 · 0 comments

Comments

@pbchase
Copy link
Contributor

pbchase commented Mar 5, 2025

Add functions to handle REDCap text validation rules. REDCap data structures that enumerate all of the field types and text validation types are available in the REDCapR source code.

These types are done:

  • date_*
  • datetime_*
  • email
  • integer
  • number
  • phone
  • zipcode

The text validation types (TVTs) should be next:

  • number_1dp
  • number_2dp
  • number_3dp
  • number_4dp
  • time
  • time_hh_mm_ss
  • time_mm_ss

get_long_text_fields.R

Look first at get_long_text_fields.R. Add you next TVT at these two places:

In between, you'll need to write a function to set the appropriate values for generating data that conforms to this TVT. In this step you are not generating the data--you are setting parameters to be feed into the functions that will generate the data.

For the number_* fields, just point their functions at tvt_number. e.g. tvt_number_1dp <- tvt_number.

For the time fields, copy tvt_datetime and strip out the date elements. Set mean = 3600 * 12 (aka 12 noon). Set sd = 3600 * 10 / 6 to get most dates between 7 am and 5 p.m.

get_long_text_field_values.R

Then look at get_long_text_field_values.R. Add functions for each TVT type added above.

number_*dp

For number_*dp, consider parameterizing digits in tvt_number
...setting a default of 2 for digits.

Then add tiny shell functions for the number_*dp TVTs that call tvt_number with the write values for digits.

time*

For the time* copy tvt_datetime but have it generate a number of seconds using mean and sd, convert that to the appropriate precision time. Review the lubridate functions as they might streamline the process.

Tests

Revises the exists test for these functions to challenge the new features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant