Skip to content

Commit

Permalink
added crosswalk_footnotes function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Dec 2, 2024
1 parent aab5424 commit c64e4b9
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(crosswalk_footnotes)
export(crosswalk_raw)
export(crosswalk_taxonomy)
export(get_pin)
Expand Down
34 changes: 34 additions & 0 deletions R/crosswalk.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,37 @@ crosswalk_taxonomy <- function(taxonomy_code = NULL,

return(pin)
}

#' Medicare Specialty Crosswalk Footnotes
#'
#' @param taxonomy_code `<chr>` Health Care Provider Taxonomy code, a unique
#' alphanumeric code, ten characters in length
#'
#' @param specialty_code `<chr>` Medicare Specialty Code, an alphanumeric code,
#' two characters in length
#'
#' @returns `<tibble>` 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)
}
14 changes: 14 additions & 0 deletions R/taxonomy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}
40 changes: 39 additions & 1 deletion data-raw/12_crosswalk_footnotes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/pins/_pins.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cross_notes:
- cross_notes/20241202T103456Z-f72f3/
- cross_notes/20241202T154954Z-7cf6a/
cross_raw:
- cross_raw/20241129T223149Z-59f58/
cross_tax:
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions man/crosswalk_footnotes.Rd

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

2 changes: 2 additions & 0 deletions man/taxonomy_raw.Rd

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

0 comments on commit c64e4b9

Please sign in to comment.