Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
.Rproj.user
.Rhistory
.RData
Expand Down
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ License: Apache License (>= 2)
Encoding: UTF-8
LazyData: true
Imports:
bit64,
dplyr,
jsonlite,
lubridate,
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export(connect_to_rcc_billing_db)
export(draft_communication_record_from_line_item)
export(fix_data_in_invoice_line_item)
export(fix_data_in_invoice_line_item_communication)
export(fix_data_in_redcap_log_event)
export(fix_data_in_redcap_projects)
export(fix_data_in_redcap_user_information)
export(get_bad_emails_from_log)
Expand Down
179 changes: 0 additions & 179 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,74 +33,6 @@
#' @source \url{https://github.com/ctsit/rcc.billing/issues/3}
"invoice_line_item_test_data"

#' Sample data for service_instance table
#'
#' @format
#' \describe{
#' \item{service_instance_id}{the primary key}
#' \item{service_type_code}{a numeric code that uniquely identifies the service_type}
#' \item{service_identifier}{either a redcap project ID, or redcap username}
#' \item{ctsi_study_id}{CSBT’s unique identifier for a service}
#' \item{active}{a boolean indicating if we expect to continue billing for this service}
#' }
#'
#' @source \url{https://github.com/ctsit/rcc.billing/issues/2}
"service_instance_test_data"

#' Sample data for service_type table
#'
#' @format
#' \describe{
#' \item{service_type_code}{a numeric code that uniquely identifies the service_type}
#' \item{service_type}{short name describing the service_type, in snake case}
#' \item{price}{price for one unit of the service, in US dollars}
#' \item{billing_frequency}{frequency at which this service ir billed, in months}
#' }
#'
#' @source \url{https://github.com/ctsit/rcc.billing/issues/1}
"service_type_test_data"

#' @title invoice_line_item_communications_test_data
#' @description A test dataset for testing functions that write or read invoice_line_item_communications
#' @format A data frame with 26 rows and 32 variables:
#' \describe{
#' \item{\code{id}}{double: the primary key}
#' \item{\code{service_identifier}}{character: either a redcap project ID, or redcap username}
#' \item{\code{service_type_code}}{double: a numeric code that uniquely identifies the service_type}
#' \item{\code{service_instance_id}}{character: a numeric code that uniquely identifies the service_instance}
#' \item{\code{ctsi_study_id}}{double: CSBT's unique identifier for a service}
#' \item{\code{name_of_service}}{character: name of the service}
#' \item{\code{name_of_service_instance}}{character: name of the study}
#' \item{\code{other_system_invoicing_comments}}{character: additional invoice information, either project url, or sponsor and pi}
#' \item{\code{price_of_service}}{double: price of the service, in US dollars}
#' \item{\code{qty_provided}}{double: quantity provided}
#' \item{\code{amount_due}}{double: amount due, in US dollars}
#' \item{\code{fiscal_year}}{character: fiscal year of the invoice}
#' \item{\code{month_invoiced}}{character: month of the invoice}
#' \item{\code{pi_last_name}}{character: last name of the person invoiced}
#' \item{\code{pi_first_name}}{character: first name of the person invoiced}
#' \item{\code{pi_email}}{character: email of the person invoiced}
#' \item{\code{gatorlink}}{character: gatorlink of the person invoiced}
#' \item{\code{crc_number}}{double: Clinical Research Center number}
#' \item{\code{ids_number}}{character: Investigational Drug Service number}
#' \item{\code{ocr_number}}{character: Office of Clinical Research study number}
#' \item{\code{invoice_number}}{double: invoice number}
#' \item{\code{je_number}}{character: journal entry number}
#' \item{\code{je_posting_date}}{POSIXct: journal entry posting date}
#' \item{\code{reason}}{character: reason for the invoice}
#' \item{\code{status}}{character: status of the invoice}
#' \item{\code{created}}{POSIXct: created at timestamp}
#' \item{\code{updated}}{POSIXct: updated at timestamp}
#' \item{\code{sender}}{character: message sender, typically an email address}
#' \item{\code{recipient}}{character: message recipient, typically an email address}
#' \item{\code{date_sent}}{POSIXct: date CTSI sent the message}
#' \item{\code{date_received}}{POSIXct: date CTSIT received the email}
#' \item{\code{script_name}}{character: the script that created this record}
#' }
#'
#' @source \url{https://github.com/ctsit/rcc.billing/issues/7}
"invoice_line_item_communications_test_data"

#' @title CTS-IT Staff
#' @description usernames of CTS-IT staff
#' @format A data frame with 6 rows and 1 variable:
Expand Down Expand Up @@ -434,87 +366,6 @@
#' }
"projects_table_fragment"

#' @title redcap_user_information_test_data
#' @description Test dataset for redcap_user_information
#' @format A data frame with 5 rows and 49 variables:
#' \describe{
#' \item{\code{ui_id}}{integer primary key}
#' \item{\code{username}}{character redcap username}
#' \item{\code{user_email}}{character primary email address}
#' \item{\code{user_email2}}{character}
#' \item{\code{user_email3}}{character}
#' \item{\code{user_phone}}{character}
#' \item{\code{user_phone_sms}}{character}
#' \item{\code{user_firstname}}{character}
#' \item{\code{user_lastname}}{character}
#' \item{\code{user_inst_id}}{character}
#' \item{\code{super_user}}{integer}
#' \item{\code{account_manager}}{integer}
#' \item{\code{access_system_config}}{integer}
#' \item{\code{access_system_upgrade}}{integer}
#' \item{\code{access_external_module_install}}{integer}
#' \item{\code{admin_rights}}{integer}
#' \item{\code{access_admin_dashboards}}{integer}
#' \item{\code{user_creation}}{double}
#' \item{\code{user_firstvisit}}{double}
#' \item{\code{user_firstactivity}}{double}
#' \item{\code{user_lastactivity}}{double}
#' \item{\code{user_lastlogin}}{double}
#' \item{\code{user_suspended_time}}{double}
#' \item{\code{user_expiration}}{double}
#' \item{\code{user_access_dashboard_view}}{double}
#' \item{\code{user_access_dashboard_email_queued}}{character}
#' \item{\code{user_sponsor}}{character}
#' \item{\code{user_comments}}{character}
#' \item{\code{allow_create_db}}{integer}
#' \item{\code{email_verify_code}}{character}
#' \item{\code{email2_verify_code}}{character}
#' \item{\code{email3_verify_code}}{character}
#' \item{\code{datetime_format}}{character}
#' \item{\code{number_format_decimal}}{character}
#' \item{\code{number_format_thousands_sep}}{character}
#' \item{\code{csv_delimiter}}{character}
#' \item{\code{two_factor_auth_secret}}{character}
#' \item{\code{display_on_email_users}}{integer}
#' \item{\code{two_factor_auth_twilio_prompt_phone}}{integer}
#' \item{\code{two_factor_auth_code_expiration}}{integer}
#' \item{\code{api_token}}{character}
#' \item{\code{messaging_email_preference}}{character}
#' \item{\code{messaging_email_urgent_all}}{integer}
#' \item{\code{messaging_email_ts}}{double}
#' \item{\code{messaging_email_general_system}}{integer}
#' \item{\code{messaging_email_queue_time}}{double}
#' \item{\code{ui_state}}{character}
#' \item{\code{api_token_auto_request}}{integer}
#' \item{\code{fhir_data_mart_create_project}}{integer}
#' }
#' @details DETAILS
"redcap_user_information_test_data"

#' @title redcap_log_event_test_data
#' @description a named list of redcap_log_event tables with project lifecycle test data
#' @format A named list of 10 dataframes each with a 0 or more rows of 15 variables.
#' Each dataframe is structured as described here.
#' \describe{
#' \item{\code{log_event_id}}{integer primary key}
#' \item{\code{project_id}}{integer REDCap project_id}
#' \item{\code{ts}}{double a timestamp in the format YYYYMMDDHHMMSS in local time}
#' \item{\code{user}}{character the REDCap username who initiated this event}
#' \item{\code{ip}}{character IP address of that REDCap user}
#' \item{\code{page}}{character relative REDCap URL that initiated this event}
#' \item{\code{event}}{character the type of event. e.g DATA_EXPORT, DELETE, ERROR, INSERT, MANAGE, OTHER, UPDATE}
#' \item{\code{object_type}}{character a REDCap object type e.g., NA, redcap_arms, redcap_auth, redcap_data, redcap_docs, redcap_event_forms, redcap_events, redcap_events_metadata, redcap_metadata, redcap_metadata_temp, redcap_projects, redcap_user_rights}
#' \item{\code{sql_log}}{character the SQL code executed during this event}
#' \item{\code{pk}}{character the primary key of the effected object}
#' \item{\code{event_id}}{integer the REDCap event_id if relevant}
#' \item{\code{data_values}}{character}
#' \item{\code{description}}{character description of the event}
#' \item{\code{legacy}}{integer}
#' \item{\code{change_reason}}{character}
#' }
#' @details DETAILS
"redcap_log_event_test_data"

#' @title csbt_column_names
#' @description Column names useful for CTSI-IT billing
#' @format A data frame with 12 rows and 2 variables:
Expand All @@ -524,25 +375,6 @@
#'}
"csbt_column_names"

#' @title invoice_line_item_reasons
#' @description Provides text for new invoice line items
#' @format A data frame with 3 rows and 2 variables:
#' \describe{
#' \item{\code{code}}{character: A short, static name for the string}
#' \item{\code{label}}{character: A friendly human-readable string}
#'}
"invoice_line_item_reasons"

#' @title invoice_line_item_statuses
#' @description Describes valid invoice line item statuses
#' @format A data frame with 5 rows and 2 variables:
#' \describe{
#' \item{\code{status}}{character: A short, static name for the status code}
#' \item{\code{description}}{character: A human-readable description of the status}
#'}
#' @details DETAILS
"invoice_line_item_statuses"

#' @title fiscal_years
#' @description A dataframe of fiscal years and labels from 2019-2020 to 2039-2040
#' @format A data frame with 21 rows and 2 variables:
Expand All @@ -558,14 +390,3 @@
#' @format A vector with 9 elements
#' @details DETAILS
"log_event_tables"

#' @title redcap_rights_test_data
#' @description A named list of dataframes used to test the functions written for redcap_rights.R
#' @format A named list of 3 dataframes:
#' \describe{
#' \item{\code{redcap_user_information}}{REDCap Core table}
#' \item{\code{redcap_user_rights}}{REDCap Core table}
#' \item{\code{redcap_user_roles}}{REDCap Core table}
#' }
#' @details DETAILS
"redcap_rights_test_data"
33 changes: 0 additions & 33 deletions R/transform.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,39 +175,6 @@ fix_data_in_redcap_user_information <- function(data) {
return(mutate_columns_to_posixct(data, time_columns))
}

#' fix_data_in_redcap_log_event
#'
#' Fixes column data types that can vary between MySQL/MariaDB and SQLite3.
#' This allows testing in SQLite3 while production is MariaDB
#'
#' @param data - a dataframe containing data from the redcap_log_event tables
#'
#' @return The input dataframe with revised data types
#' @export
#'
#' @examples
#' \dontrun{
#' fix_data_in_redcap_log_event(redcap_log_event_test_data)
#' }
fix_data_in_redcap_log_event <- function(data) {
integer64_columns <- c(
"ts"
)
if (nrow(data) == 0) { # zero-row SQLite3 tables get the wrong data type on ts
result <- data |>
dplyr::mutate(
dplyr::across(
dplyr::any_of(integer64_columns),
bit64::as.integer64
)
)
} else {
result <- data
}

return(result)
}

#' Renames columns of a dataframe from CTSIT format to CSBT format
#'
#' Excludes non-CSBT columns and renames CTSIT column names to the corresponding CSBT names.
Expand Down
31 changes: 0 additions & 31 deletions data-raw/invoice_line_items.R

This file was deleted.

57 changes: 0 additions & 57 deletions data-raw/redcap_log_event_test_data.R

This file was deleted.

28 changes: 0 additions & 28 deletions data-raw/redcap_user_information.R

This file was deleted.

Binary file removed data/invoice_line_item_communications_test_data.rda
Binary file not shown.
Binary file removed data/invoice_line_item_reasons.rda
Binary file not shown.
Binary file removed data/invoice_line_item_statuses.rda
Binary file not shown.
Binary file removed data/redcap_log_event_test_data.rda
Binary file not shown.
Binary file removed data/redcap_rights_test_data.rda
Binary file not shown.
Binary file removed data/redcap_user_information_test_data.rda
Binary file not shown.
Binary file removed data/service_instance_test_data.rda
Binary file not shown.
Binary file removed data/service_type_test_data.rda
Binary file not shown.
15 changes: 0 additions & 15 deletions examples/ctsit_staff.R

This file was deleted.

Loading