-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added pins: changelog, sources, hierarchy, raw
- Loading branch information
1 parent
683c103
commit 1f01bee
Showing
16 changed files
with
383 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# arktax (development version) | ||
# arktax 0.1.0.9000 (2024-11-16) | ||
|
||
* Initialize package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,129 @@ | ||
#' Get Taxomony Source File | ||
#' Retrieve Taxonomy Source File | ||
#' | ||
#' @param year `<int>` year of source file release; options are `2009:2024` | ||
#' | ||
#' @param version `<int>` version of source file; options are `0` or `1` | ||
#' | ||
#' @param code `<chr>` Health Care Provider Taxonomy code, a unique alphanumeric code, ten characters in length | ||
#' | ||
#' @param which `<chr>` `wide` or `long` version of the taxonomy | ||
#' @param code `<chr>` Health Care Provider Taxonomy code, a unique | ||
#' alphanumeric code, ten characters in length | ||
#' | ||
#' @returns `<tibble>` of search results | ||
#' | ||
#' @examples | ||
#' retrieve_ark(year = 2024, code = "101Y00000X", which = "wide") | ||
#' retrieve_raw(year = 2024, code = "101Y00000X") | ||
#' | ||
#' retrieve_ark(code = "101Y00000X", which = "long") | ||
#' retrieve_raw(code = "101Y00000X") | ||
#' | ||
#' @importFrom fuimus search_in_if | ||
#' | ||
#' @autoglobal | ||
#' | ||
#' @export | ||
retrieve_ark <- function(year = NULL, | ||
retrieve_raw <- function(year = NULL, | ||
version = NULL, | ||
code = NULL, | ||
which = c("wide", "long")) { | ||
|
||
ark <- switch( | ||
which, | ||
wide = get_pin("ark_taxonomy"), | ||
long = get_pin("ark_long") | ||
) | ||
|
||
if (which == "wide") { | ||
ark <- search_in_if(ark, ark[["year"]], year) | ||
ark <- search_in_if(ark, ark[["version"]], version) | ||
} | ||
code = NULL) { | ||
check_nchar(code, 10) | ||
pin <- get_pin("ark_taxonomy") | ||
pin <- search_in_if(pin, pin[["year"]], year) | ||
pin <- search_in_if(pin, pin[["version"]], version) | ||
pin <- search_in_if(pin, pin[["code"]], code) | ||
return(pin) | ||
} | ||
|
||
#' Retrieve Taxonomy Sources | ||
#' | ||
#' @param code `<chr>` Health Care Provider Taxonomy code, a unique | ||
#' alphanumeric code, ten characters in length | ||
#' | ||
#' @returns `<tibble>` of search results | ||
#' | ||
#' @examples | ||
#' retrieve_sources(code = "101Y00000X") | ||
#' | ||
#' retrieve_sources(code = "103TA0400X") | ||
#' | ||
#' @importFrom fuimus search_in_if | ||
#' | ||
#' @autoglobal | ||
#' | ||
#' @export | ||
retrieve_sources <- function(code = NULL) { | ||
check_nchar(code, 10) | ||
pin <- get_pin("sources") | ||
search_in_if(pin, pin[["code"]], code) | ||
} | ||
|
||
#' Retrieve Taxonomy Changelog | ||
#' | ||
#' @param code `<chr>` Health Care Provider Taxonomy code, a unique | ||
#' alphanumeric code, ten characters in length | ||
#' | ||
#' @returns `<tibble>` of search results | ||
#' | ||
#' @examples | ||
#' retrieve_changelog(code = "103GC0700X") | ||
#' | ||
#' retrieve_changelog(code = "103G00000X") | ||
#' | ||
#' @importFrom fuimus search_in_if | ||
#' | ||
#' @autoglobal | ||
#' | ||
#' @export | ||
retrieve_changelog <- function(code = NULL) { | ||
check_nchar(code, 10) | ||
pin <- get_pin("changelog") | ||
search_in_if(pin, pin[["code"]], code) | ||
} | ||
|
||
#' Retrieve Taxonomy Hierarchy | ||
#' | ||
#' @param code `<chr>` Health Care Provider Taxonomy code, a unique | ||
#' alphanumeric code, ten characters in length | ||
#' | ||
#' @returns `<tibble>` of search results | ||
#' | ||
#' @examples | ||
#' retrieve_hierarchy(code = "101Y00000X") | ||
#' | ||
#' retrieve_hierarchy(code = "103TA0400X") | ||
#' | ||
#' @importFrom fuimus search_in_if | ||
#' | ||
#' @autoglobal | ||
#' | ||
#' @export | ||
retrieve_hierarchy <- function(code = NULL) { | ||
check_nchar(code, 10) | ||
pin <- get_pin("ark_long") | ||
search_in_if(pin, pin[["code"]], code) | ||
} | ||
|
||
|
||
#' Check that input is `n` character(s) long | ||
#' | ||
#' @param x `<chr>` string | ||
#' | ||
#' @param n `<int>` number of characters | ||
#' | ||
#' @autoglobal | ||
#' | ||
#' @noRd | ||
check_nchar <- function(x, n) { | ||
|
||
if (!is.null(x)) { | ||
|
||
ark <- search_in_if(ark, ark[["code"]], code) | ||
stopifnot(rlang::is_integerish(n), n > 0) | ||
|
||
return(ark) | ||
arg <- rlang::caller_arg(x) | ||
call <- rlang::caller_env() | ||
|
||
if (any(stringfish::sf_nchar(x) != n, na.rm = TRUE)) { | ||
cli::cli_abort( | ||
"{.arg {arg}} must be {.val {n}} character{?s} long.", | ||
arg = arg, | ||
call = call) | ||
} | ||
stringfish::sf_toupper(x) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.