diff --git a/NAMESPACE b/NAMESPACE index 782dee2..c416dab 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(crosswalk_footnotes) export(crosswalk_raw) export(crosswalk_taxonomy) export(get_pin) diff --git a/R/crosswalk.R b/R/crosswalk.R index 9356d10..43851fa 100644 --- a/R/crosswalk.R +++ b/R/crosswalk.R @@ -59,3 +59,37 @@ crosswalk_taxonomy <- function(taxonomy_code = NULL, return(pin) } + +#' Medicare Specialty Crosswalk Footnotes +#' +#' @param taxonomy_code `` Health Care Provider Taxonomy code, a unique +#' alphanumeric code, ten characters in length +#' +#' @param specialty_code `` Medicare Specialty Code, an alphanumeric code, +#' two characters in length +#' +#' @returns `` of search results +#' +#' @examples +#' crosswalk_footnotes(taxonomy_code = "251E00000X") +#' +#' crosswalk_footnotes(specialty_code = "A0) +#' +#' @importFrom fuimus search_in_if +#' +#' @autoglobal +#' +#' @export +crosswalk_footnotes <- function(taxonomy_code = NULL, + specialty_code = NULL) { + + check_nchar(taxonomy_code, 10) + check_nchar(specialty_code, 2) + + pin <- get_pin("cross_notes") + + pin <- search_in_if(pin, pin[["taxonomy_code"]], taxonomy_code) + pin <- search_in_if(pin, pin[["specialty_code"]], specialty_code) + + return(pin) +} diff --git a/R/taxonomy.R b/R/taxonomy.R index 13e9cf0..622328b 100644 --- a/R/taxonomy.R +++ b/R/taxonomy.R @@ -14,6 +14,8 @@ #' #' taxonomy_raw(taxonomy_code = "101Y00000X") #' +#' taxonomy_raw(taxonomy_code = c("101YM0800X", "101YP2500X")) |> print(n = 100) +#' #' @importFrom fuimus search_in_if #' #' @autoglobal @@ -78,8 +80,11 @@ taxonomy_sources <- function(taxonomy_code = NULL) { #' #' @export taxonomy_changelog <- function(taxonomy_code = NULL) { + check_nchar(taxonomy_code, 10) + pin <- get_pin("tax_changelog") + search_in_if(pin, pin[["code"]], taxonomy_code) } @@ -101,8 +106,11 @@ taxonomy_changelog <- function(taxonomy_code = NULL) { #' #' @export taxonomy_hierarchy <- function(taxonomy_code = NULL) { + check_nchar(taxonomy_code, 10) + pin <- get_pin("tax_hierarchy") + search_in_if(pin, pin[["code"]], taxonomy_code) } @@ -124,8 +132,11 @@ taxonomy_hierarchy <- function(taxonomy_code = NULL) { #' #' @export taxonomy_display <- function(taxonomy_code = NULL) { + check_nchar(taxonomy_code, 10) + pin <- get_pin("tax_display") + search_in_if(pin, pin[["code"]], taxonomy_code) } @@ -147,7 +158,10 @@ taxonomy_display <- function(taxonomy_code = NULL) { #' #' @export taxonomy_definition <- function(taxonomy_code = NULL) { + check_nchar(taxonomy_code, 10) + pin <- get_pin("tax_definitions") + search_in_if(pin, pin[["code"]], taxonomy_code) } diff --git a/data-raw/12_crosswalk_footnotes.R b/data-raw/12_crosswalk_footnotes.R index ed5cf86..d839fd5 100644 --- a/data-raw/12_crosswalk_footnotes.R +++ b/data-raw/12_crosswalk_footnotes.R @@ -8,8 +8,46 @@ footnotes <- dplyr::tibble( "raw", "taxonomy_notes.txt"))) + +notes <- walk |> + dplyr::left_join(footnotes, by = dplyr::join_by(type_note == note)) |> + dplyr::left_join(footnotes, by = dplyr::join_by(code_note == note)) |> + dplyr::filter(!is.na(type_note) | !is.na(code_note)) |> + dplyr::rename( + type_note_description = note_description.x, + code_note_description = note_description.y) |> + dplyr::select(-.id) + + +notes <- vctrs::vec_rbind( + notes |> + dplyr::select( + taxonomy_code, + specialty_code, + # specialty_type, + type_note, + type_note_description) |> + dplyr::filter(!is.na(type_note) | !is.na(type_note_description)) |> + dplyr::mutate( + footnote = stringr::str_glue("({type_note}) {type_note_description}"), + type_note = NULL, + type_note_description = NULL), + notes |> + dplyr::select( + taxonomy_code, + specialty_code, + code_note, + code_note_description) |> + dplyr::filter(!is.na(code_note) | !is.na(code_note_description)) |> + dplyr::mutate( + footnote = stringr::str_glue("({code_note}) {code_note_description}"), + code_note = NULL, + code_note_description = NULL) +) + + pin_update( - footnotes, + notes, "cross_notes", "Medicare Taxonomy Crosswalk Footnotes 2024", "Medicare Provider and Supplier Taxonomy Crosswalk Footnotes 2024" diff --git a/inst/extdata/pins/_pins.yaml b/inst/extdata/pins/_pins.yaml index f7307ef..b4143f9 100644 --- a/inst/extdata/pins/_pins.yaml +++ b/inst/extdata/pins/_pins.yaml @@ -1,5 +1,5 @@ cross_notes: -- cross_notes/20241202T103456Z-f72f3/ +- cross_notes/20241202T154954Z-7cf6a/ cross_raw: - cross_raw/20241129T223149Z-59f58/ cross_tax: diff --git a/inst/extdata/pins/cross_notes/20241202T103456Z-f72f3/cross_notes.qs b/inst/extdata/pins/cross_notes/20241202T103456Z-f72f3/cross_notes.qs deleted file mode 100644 index fad1083..0000000 Binary files a/inst/extdata/pins/cross_notes/20241202T103456Z-f72f3/cross_notes.qs and /dev/null differ diff --git a/inst/extdata/pins/cross_notes/20241202T154954Z-7cf6a/cross_notes.qs b/inst/extdata/pins/cross_notes/20241202T154954Z-7cf6a/cross_notes.qs new file mode 100644 index 0000000..79287f8 Binary files /dev/null and b/inst/extdata/pins/cross_notes/20241202T154954Z-7cf6a/cross_notes.qs differ diff --git a/inst/extdata/pins/cross_notes/20241202T103456Z-f72f3/data.txt b/inst/extdata/pins/cross_notes/20241202T154954Z-7cf6a/data.txt similarity index 73% rename from inst/extdata/pins/cross_notes/20241202T103456Z-f72f3/data.txt rename to inst/extdata/pins/cross_notes/20241202T154954Z-7cf6a/data.txt index ee1367d..6750fac 100644 --- a/inst/extdata/pins/cross_notes/20241202T103456Z-f72f3/data.txt +++ b/inst/extdata/pins/cross_notes/20241202T154954Z-7cf6a/data.txt @@ -1,10 +1,10 @@ file: cross_notes.qs -file_size: 981 -pin_hash: f72f35f03df16118 +file_size: 1296 +pin_hash: 7cf6a84209eb0b3a type: qs title: Medicare Taxonomy Crosswalk Footnotes 2024 description: Medicare Provider and Supplier Taxonomy Crosswalk Footnotes 2024 tags: ~ urls: ~ -created: 20241202T103456Z +created: 20241202T154954Z api_version: 1 diff --git a/man/crosswalk_footnotes.Rd b/man/crosswalk_footnotes.Rd new file mode 100644 index 0000000..cf65f86 --- /dev/null +++ b/man/crosswalk_footnotes.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/crosswalk.R +\name{crosswalk_footnotes} +\alias{crosswalk_footnotes} +\title{Medicare Specialty Crosswalk Footnotes} +\usage{ +crosswalk_footnotes(taxonomy_code = NULL, specialty_code = NULL) +} +\arguments{ +\item{taxonomy_code}{\verb{} Health Care Provider Taxonomy code, a unique +alphanumeric code, ten characters in length} + +\item{specialty_code}{\verb{} Medicare Specialty Code, an alphanumeric code, +two characters in length} +} +\value{ +\verb{} of search results +} +\description{ +Medicare Specialty Crosswalk Footnotes +} diff --git a/man/taxonomy_raw.Rd b/man/taxonomy_raw.Rd index 162f0e1..cacfe6a 100644 --- a/man/taxonomy_raw.Rd +++ b/man/taxonomy_raw.Rd @@ -25,4 +25,6 @@ taxonomy_raw(year = 2024, taxonomy_code = "101Y00000X") taxonomy_raw(taxonomy_code = "101Y00000X") +taxonomy_raw(taxonomy_code = c("101YM0800X", "101YP2500X")) |> print(n = 100) + }