Skip to content
Merged

Dev #59

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
2 changes: 1 addition & 1 deletion R/chi_compare_estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ chi_compare_estimates <- function(OLD = NULL, NEW = NULL, OLD.year = NULL, NEW.y
qa_type[, qa_type := 'relative']
qa_type[grepl('mean|proportion', result_type, ignore.case = T) & result >= 0.05, qa_type := 'absolute']
qa_type[grepl('rate', result_type, ignore.case = T) & result >= 5, qa_type := 'absolute']
qa_type <- qa_type[, list(indicator_key, qa_type)]
qa_type <- unique(qa_type[, list(indicator_key, qa_type)])

# Merge on qa_type
comp <- merge(comp, qa_type, by = 'indicator_key', all = T)
Expand Down
22 changes: 12 additions & 10 deletions R/chi_update_sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
#'
#' @param CHIestimates data.frame/data.table containing CHI analytic results
#' @param CHImetadata data.frame/data.table containing CHI metadata
#' @param table_name name of SQL Server table to update
#' @param server type of server (\code{'development'} for KCITSQLUATHIP40 and
#' \code{'production'} for KCITSQLPRPHIP40)
#' @param table_name name of SQL Server table to update, e.g., `'acs'`, `'birth'`, `'death'`, etc.
#' @param server type of server (`'development'` for KCITSQLUATHIP40 and
#' `'production'` for KCITSQLPRPHIP40)
#'
#' Default \code{server = 'development'}
#' @param replace_table If TRUE, drop existing table and insert data, if FALSE
#' update matching rows and insert new data
#' @param replace_table If `TRUE`, the existing SQL table is dropped and fully replaced with the
#' new data. If `FALSE`, rows matching the `indicator_key` values in `CHIestimates` and
#' `CHIestimates` are deleted from SQL and then replaced with the new data, leaving all other rows
#' intact.
#'
#' Default \code{replace_table = FALSE}
#' Default `replace_table = FALSE`
#'
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -70,7 +72,7 @@ chi_update_sql <- function(CHIestimates = NULL,
if( inherits(CHImetadata, "data.table") == FALSE){setDT(CHImetadata)}
rads::tsql_validate_field_types(ph.data = CHImetadata, field_types = unlist(chi_get_yaml()$metadata))

# checkt table_name ----
# check table_name ----
if(is.null(table_name)){stop("\n\U0001f47f The table_name argument is missing ")}
if(length(table_name) != 1 | !is.character(table_name)){stop("\n\U0001f47f table_name must be a character vector of length 1")}

Expand All @@ -84,9 +86,9 @@ chi_update_sql <- function(CHIestimates = NULL,
if(!server %in% c('development', 'production')){stop("\n\U0001f47f The server argument is limited to: 'development', 'production'")}
if(length(server) != 1){stop("\n\U0001f47f The `server` argument must be of length 1")}

# check replace argument----
if(!is.logical(replace_table)){stop("\n\U0001f47f The `replace` argument must be a logical, i.e., TRUE | FALSE")}
if(length(replace_table) != 1){stop("\n\U0001f47f The `server` argument must be of length 1")}
# check replace_table argument----
if(!is.logical(replace_table)){stop("\n\U0001f47f The `replace_table` argument must be a logical, i.e., TRUE | FALSE")}
if(length(replace_table) != 1){stop("\n\U0001f47f The `replace_table` argument must be of length 1")}

# open database connection----
if(server %in% c('development')){
Expand Down
8 changes: 5 additions & 3 deletions man/chi_update_sql.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.