R/search_umls_key.R

Defines functions search_umls_key

Documented in search_umls_key

#' Search umls key for a term
#' @param path_to_key path to key file
#' @param string string to search
#' @importFrom readr read_csv
#' @import dplyr
#' @export
#'

search_umls_key <-
        function(path_to_key = "/Users/patelm9/GitHub/MSK/biblio-tech/KEY/REDCap/KEY_TO_UMLS.csv",
                 string,
                 type = c("like", "exact")) {

                key_data <-
                        readr::read_csv(path_to_key,
                                        col_types = cols(.default = "c"))

                if (type == "exact") {
                        string <- paste0("^", string, "$")
                } else {
                        string <- string
                }

                output <-
                        key_data %>%
                        dplyr::filter_all(any_vars(grepl(string, ., ignore.case = TRUE)))

                return(output)
        }
patelm9/cartographR4 documentation built on April 8, 2020, 7:21 p.m.