diff --git a/.Rbuildignore b/.Rbuildignore index 0b457a9c..7adcfdd0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,4 @@ vignettes ^vignettes/articles$ ^codecov\.yml$ ^data-raw$ +^man-roxygen$ diff --git a/R/affiliations.R b/R/affiliations.R index e86f320c..5354917c 100644 --- a/R/affiliations.R +++ b/R/affiliations.R @@ -1,55 +1,51 @@ #' Provider Facility Affiliations #' -#' @description -#' `r lifecycle::badge("experimental")` -#' -#' [affiliations()] allows the user access to data concerning providers' -#' facility affiliations +#' @description [affiliations()] allows the user access to data concerning +#' providers' facility affiliations #' #' @section Links: -#' + [Physician Facility Affiliations](https://data.cms.gov/provider-data/dataset/27ea-46a8) -#' + [Certification Number (CCN) State Codes](https://www.cms.gov/Medicare/Provider-Enrollment-and-Certification/SurveyCertificationGenInfo/Downloads/Survey-and-Cert-Letter-16-09.pdf) +#' * [Physician Facility Affiliations](https://data.cms.gov/provider-data/dataset/27ea-46a8) +#' * [Certification Number (CCN) State Codes](https://www.cms.gov/Medicare/Provider-Enrollment-and-Certification/SurveyCertificationGenInfo/Downloads/Survey-and-Cert-Letter-16-09.pdf) #' #' *Update Frequency:* **Monthly** #' -#' @param npi < *integer* > 10-digit Individual National Provider Identifier -#' @param pac < *integer* > 10-digit Individual PECOS Associate Control ID -#' @param first,middle,last < *character* > Individual Provider's name -#' @param facility_type < *character* > -#' + `"Hospital"` or `"hp"` -#' + `"Long-term care hospital"` or `"ltch"` -#' + `"Nursing home"` or `"nh"` -#' + `"Inpatient rehabilitation facility"` or `"irf"` -#' + `"Home health agency"` or `"hha"` -#' + `"Skilled nursing facility"` or `"snf"` -#' + `"Hospice"` or `"hs"` -#' + `"Dialysis facility"` or `"df"` -#' @param facility_ccn < *character* > 6-digit CMS Certification Number of -#' facility or unit within hospital where an individual provider provides service -#' @param parent_ccn < *integer* > 6-digit CMS Certification Number of a sub-unit's -#' primary hospital, should the provider provide services in said unit -#' @param offset < *integer* > // __default:__ `0L` API pagination -#' @param tidy < *boolean* > // __default:__ `TRUE` Tidy output -#' @param na.rm < *boolean* > // __default:__ `TRUE` Remove empty rows and columns -#' @param ... Empty -#' -#' @return A [tibble][tibble::tibble-package] with the columns: -#' -#' |**Field** |**Description** | -#' |:---------------|:---------------------------------| -#' |`npi` |10-digit NPI | -#' |`pac` |10-digit individual PAC ID | -#' |`first` |Individual provider's first name | -#' |`middle` |Individual provider's middle name | -#' |`last` |Individual provider's last name | -#' |`suffix` |Individual provider's suffix | -#' |`facility_type` |Category of facility | -#' |`facility_ccn` |Facility's 6-digit CCN | -#' |`parent_ccn` |Primary facility's 6-digit CCN | +#' @template args-npi +#' +#' @template args-pac +#' +#' @param first,middle,last `` Individual provider's first/middle/last name +#' +#' @param facility_type `` Type of facility, one of the following: +#' * `Hospital` (`hp`) +#' * `Long-term care hospital` (`ltch`) +#' * `Nursing home` (`nh`) +#' * `Inpatient rehabilitation facility` (`irf`) +#' * `Home health agency` (`hha`) +#' * `Skilled nursing facility` (`snf`) +#' * `Hospice` (`hs`) +#' * `Dialysis facility` (`df`) +#' +#' @param facility_ccn `` 6-digit CMS Certification Number of facility or +#' unit within hospital where an individual provider provides service. +#' +#' @param parent_ccn `` 6-digit CMS Certification Number of a sub-unit's +#' primary hospital, should the provider provide services in said unit. +#' +#' @template args-offset +#' +#' @template args-tidy +#' +#' @template args-narm +#' +#' @template args-dots +#' +#' @template returns #' #' @examplesIf interactive() #' affiliations(parent_ccn = 670055) +#' #' @autoglobal +#' #' @export affiliations <- function(npi = NULL, pac = NULL, diff --git a/R/globals.R b/R/globals.R index 14b8c14f..f71c6a3a 100644 --- a/R/globals.R +++ b/R/globals.R @@ -186,11 +186,6 @@ utils::globalVariables(c( "apm_affl_1", # "apm_affl_2", # "apm_affl_3", # - "number", # - "mdc", # - "mdc_description", # - "drg_type", # - "drg_abbrev", # "y", # "title", # "title._value", # diff --git a/R/ms_drg.R b/R/ms_drg.R deleted file mode 100644 index 7b24ca61..00000000 --- a/R/ms_drg.R +++ /dev/null @@ -1,65 +0,0 @@ -#' Download the current MS-DRG classification -#' -#' @description -#' `r lifecycle::badge("questioning")` -#' -#' `download_msdrg()` returns a [tibble()] of the current Medicare Severity Diagnosis-Related Group (MS-DRG) codes -#' -#' @section MS-DRGs: -#' The Medicare Severity Diagnosis-Related Group (MS-DRG) is a classification -#' system used by the Centers for Medicare and Medicaid Services (CMS) to group -#' patients with similar clinical characteristics and resource utilization into -#' a single payment category. -#' -#' The system is primarily used for Medicare reimbursement purposes, but it is -#' also adopted by many other payers as a basis for payment determination. -#' -#' MS-DRGs are based on the principal diagnosis, up to 24 additional diagnoses, -#' and up to 25 procedures performed during the stay. In a small number of -#' MS-DRGs, classification is also based on the age, sex, and discharge status -#' of the patient. -#' -#' Hospitals serving more severely ill patients receive increased -#' reimbursements, while hospitals treating less severely ill patients will -#' receive less reimbursement. -#' -#' @return A [tibble][tibble::tibble-package] with the columns: -#' -#' @examplesIf interactive() -#' download_msdrg() -#' @autoglobal -#' @noRd -# nocov start -download_msdrg <- function() { - - url <- "https://www.hipaaspace.com/medical.coding.library/drgs/" - - ms_drg_v36 <- url |> - rvest::read_html() |> - rvest::html_table(na.strings = c("N/A", "N/S"), - convert = FALSE) - - ms_drg_v36[[1]] |> - janitor::clean_names() |> - dplyr::select(-number) |> - dplyr::mutate(mdc = dplyr::na_if(mdc, "N/A"), - mdc_description = dplyr::na_if(mdc_description, "N/S")) |> - tidyr::separate_wider_delim(drg_type, " ", names = c("drg_type", "drg_abbrev")) |> - dplyr::mutate(drg_abbrev = stringr::str_remove(drg_abbrev, "\\("), - drg_abbrev = stringr::str_remove(drg_abbrev, "\\)"), - drg_abbrev = dplyr::na_if(drg_abbrev, "")) - -} - -download_icd10 <- function() { - - base <- "https://ftp.cdc.gov/pub/Health_Statistics/NCHS/Publications/ICD10CM/" - x <- rvest::session(base) |> - rvest::session_follow_link("2024") |> - rvest::html_elements("a") |> - rvest::html_attr("href") - - x[2:8] - -} -# nocov end diff --git a/R/nppes.R b/R/nppes.R index f456654f..03efbdda 100644 --- a/R/nppes.R +++ b/R/nppes.R @@ -1,116 +1,130 @@ #' National Registry of Health Care Providers #' -#' @description -#' [nppes()] allows the user to search the National Plan and Provider -#' Enumeration System (NPPES) NPI Registry, a free directory of all active NPI -#' records. -#' -#' @section __National Provider Identifier (NPI)__: -#' Healthcare providers acquire their unique 10-digit NPIs to identify -#' themselves in a standard way throughout their industry. Once CMS supplies -#' an NPI, they publish the parts of the NPI record that have public relevance, -#' including the provider’s name, taxonomy and practice address. -#' -#' @section __Entity/Enumeration Type__: -#' Two categories of health care providers exist for NPI enumeration purposes: -#' -#' __Type 1__: Individual providers may get an NPI as _Entity Type 1_. -#' -#' _Sole Proprietorship_ -#' A sole proprietor is one who does not conduct business as a corporation and, -#' thus, __is not__ an incorporated individual. -#' -#' An __incorporated individual__ is an individual provider who forms and -#' conducts business under a corporation. This provider may have a Type 1 NPI -#' while the corporation has its own Type 2 NPI. -#' -#' A solo practitioner is not necessarily a sole proprietor, and vice versa. The -#' following factors do not affect whether a sole proprietor is a Type 1 entity: -#' + Multiple office locations -#' + Having employees -#' + Having an EIN -#' -#' __Type 2__: Organizational providers are eligible for _Entity Type 2_ NPIs. -#' -#' Organizational or Group providers may have a single employee or thousands of employees. -#' An example is an __incorporated individual__ who is an organization's only -#' employee. -#' -#' Some organization health care providers are made up of parts that work -#' somewhat independently from -#' their parent organization. These parts may offer different types of health -#' care or offer health care in separate physical locations. These parts and -#' their physical locations aren't themselves legal entities but are part of -#' the organization health care provider (which is a legal entity). The NPI -#' Final Rule refers to the parts and locations as sub-parts. An organization -#' health care provider can get its sub-parts their own NPIs. If a sub-part -#' conducts any HIPAA standard transactions on its own (separately from its -#' parent), it must get its own NPI. Sub-part determination makes sure that -#' entities within a covered organization are uniquely identified in HIPAA -#' standard transactions they conduct with Medicare and other covered entities. -#' For example, a hospital offers acute care, laboratory, pharmacy, and -#' rehabilitation services. Each of these sub-parts may need its own NPI because -#' each sends its own standard transactions to one or more health plans. Sub-part -#' delegation doesn't affect Entity Type 1 health care providers. As individuals, -#' these health care providers can't choose sub-parts and are not sub-parts. +#' @description [nppes()] allows the user to search the National Plan and +#' Provider Enumeration System (NPPES) NPI Registry, a free directory of all +#' active NPI records. +#' +#' @section __National Provider Identifier (NPI)__: Healthcare providers acquire +#' their unique 10-digit NPIs to identify themselves in a standard way +#' throughout their industry. Once CMS supplies an NPI, they publish the parts +#' of the NPI record that have public relevance, including the provider’s +#' name, taxonomy and practice address. +#' +#' @section __Entity/Enumeration Type__: Two categories of health care providers +#' exist for NPI enumeration purposes: +#' +#' __Type 1__: Individual providers may get an NPI as _Entity Type 1_. +#' +#' _Sole Proprietorship_ A sole proprietor is one who does not conduct +#' business as a corporation and, thus, __is not__ an incorporated individual. +#' +#' An __incorporated individual__ is an individual provider who forms and +#' conducts business under a corporation. This provider may have a Type 1 NPI +#' while the corporation has its own Type 2 NPI. +#' +#' A solo practitioner is not necessarily a sole proprietor, and vice versa. +#' The following factors do not affect whether a sole proprietor is a Type 1 +#' entity: + Multiple office locations + Having employees + Having an EIN +#' +#' __Type 2__: Organizational providers are eligible for _Entity Type 2_ NPIs. +#' +#' Organizational or Group providers may have a single employee or thousands +#' of employees. An example is an __incorporated individual__ who is an +#' organization's only employee. +#' +#' Some organization health care providers are made up of parts that work +#' somewhat independently from their parent organization. These parts may +#' offer different types of health care or offer health care in separate +#' physical locations. These parts and their physical locations aren't +#' themselves legal entities but are part of the organization health care +#' provider (which is a legal entity). The NPI Final Rule refers to the parts +#' and locations as sub-parts. An organization health care provider can get +#' its sub-parts their own NPIs. If a sub-part conducts any HIPAA standard +#' transactions on its own (separately from its parent), it must get its own +#' NPI. Sub-part determination makes sure that entities within a covered +#' organization are uniquely identified in HIPAA standard transactions they +#' conduct with Medicare and other covered entities. For example, a hospital +#' offers acute care, laboratory, pharmacy, and rehabilitation services. Each +#' of these sub-parts may need its own NPI because each sends its own standard +#' transactions to one or more health plans. Sub-part delegation doesn't +#' affect Entity Type 1 health care providers. As individuals, these health +#' care providers can't choose sub-parts and are not sub-parts. #' #' **Authorized Official**
-#' An appointed official (e.g., chief executive officer, chief financial officer, -#' general partner, chairman of the board, or direct owner) to whom the -#' organization has granted the legal authority to enroll it in the Medicare -#' program, to make changes or updates to the organization's status in the -#' Medicare program, and to commit the organization to fully abide by the -#' statutes, regulations, and program instructions of the Medicare program. +#' An appointed official (e.g., chief executive officer, chief financial +#' officer, general partner, chairman of the board, or direct owner) to whom +#' the organization has granted the legal authority to enroll it in the +#' Medicare program, to make changes or updates to the organization's status +#' in the Medicare program, and to commit the organization to fully abide by +#' the statutes, regulations, and program instructions of the Medicare +#' program. #' #' @section Links: -#' + [NPPES NPI Registry API Documentation](https://npiregistry.cms.hhs.gov/api-page) -#' + [NPPES NPI Registry API Demo](https://npiregistry.cms.hhs.gov/demo-api) -#' + [NPPES Available Countries](https://npiregistry.cms.hhs.gov/help-api/country) +#' * [NPPES NPI Registry API Documentation](https://npiregistry.cms.hhs.gov/api-page) +#' * [NPPES NPI Registry API Demo](https://npiregistry.cms.hhs.gov/demo-api) +#' * [NPPES Available Countries](https://npiregistry.cms.hhs.gov/help-api/country) #' -#' @section Trailing Wildcard Entries: -#' Arguments that allow trailing wildcard entries are denoted in the parameter -#' description with __WC__. Wildcard entries require at least two -#' characters to be entered, e.g. `"jo*"` +#' @section Trailing Wildcard Entries: Arguments that allow trailing wildcard +#' entries are denoted in the parameter description with __WC__. Wildcard +#' entries require at least two characters to be entered, e.g. `"jo*"` #' #' @section Update Frequency: __Weekly__ #' -#' @param npi < *integer | character* > 10-digit Organizational National Provider Identifier -#' @param entype < *character* > Entity/enumeration type _Cannot be the only criteria entered._ -#' * `"I"`: Individual provider (NPI-1) -#' * `"O"`: Organizational provider (NPI-2) -#' @param first,last < *character* > // __WC__ Individual provider's name -#' @param name_type < *character* > Type of individual the name arguments -#' refer to: -#' * `"AO"`: search Authorized Officials only -#' * `"Provider"`: search Individual Providers only -#' @param organization < *character* > // __WC__ Organization's name. Many -#' types of names (LBN, DBA, Former LBN, Other Name) may match. As such, the -#' results might contain a name different from the one entered. -#' @param taxonomy_desc < *character* > Provider's taxonomy description, -#' e.g. `"Pharmacist"`, `"Pediatrics"` -#' @param city < *character* > Provider's city. To search for a military -#' address, enter either `"APO"` or `"FPO"`. -#' @param state < *character* > Provider's state abbreviation. If the only -#' input, one other param besides `entype` and `country` must be input. -#' @param zip < *character* > // __WC__ Provider's zip code -#' @param country < *character* > Provider's country code. Can be used as the -#' only input, as long as the input *is not* `"US"`. -#' @param limit < *integer* > // __default:__ `1200L` Max results to return -#' @param skip < *integer* > // __default:__ `0L` Number of results to skip -#' after those returned -#' @param unnest < *boolean* > // __default:__ `TRUE` Unnest list columns -#' @param tidy < *boolean* > // __default:__ `TRUE` Tidy output -#' @param na.rm < *boolean* > // __default:__ `TRUE` Remove empty rows and columns -#' @param ... Empty -#' -#' @return A [tibble][tibble::tibble-package] containing the search results. -#' -#' @family api +#' @template args-npi +#' +#' @param entype `` Entity type; one of either `I` for Individual (NPI-1) +#' or `O` for Organizational (NPI-2) +#' +#' @param first,last `` __WC__ Individual provider's first and/or last name +#' +#' @param name_type `` Type of individual the `first` and `last` name +#' parameters refer to; one of either `AO` for Authorized Officials or +#' `Provider` for Individual Providers. +#' +#' @param organization `` __WC__ Organizational provider's name. Many types +#' of names (LBN, DBA, Former LBN, Other Name) may match. As such, the results +#' might contain a name different from the one entered. +#' +#' @param taxonomy_desc `` Provider's taxonomy description, e.g. +#' `Pharmacist`, `Pediatrics` +#' +#' @param city `` City name. For military addresses, search for either +#' `APO` or `FPO`. +#' +#' @param state `` 2-character state abbreviation. If it is the only input, +#' one other parameter besides `entype` and `country` is required. +#' +#' @param zip `` __WC__ 5- to 9-digit zip code, without a hyphen. +#' +#' @param country `` 2-character country abbreviation. Can be the only +#' input, as long as it *is not* `US`. +#' +#' @param limit `` Maximum number of results to return; __default__ is +#' `1200L` +#' +#' @param skip `` Number of results to skip after those initially returned +#' by the API; __default__ is `0L` +#' +#' @template args-unnest +#' +#' @template args-tidy +#' +#' @template args-narm +#' +#' @template args-dots +#' +#' @template returns +#' #' @examplesIf interactive() #' nppes(npi = 1528060837) #' -#' nppes(city = "CARROLLTON", state = "GA", zip = 301173889, entype = "I") +#' nppes(city = "CARROLLTON", +#' state = "GA", +#' zip = 301173889, +#' entype = "I") +#' #' @autoglobal +#' #' @export nppes <- function(npi = NULL, entype = NULL, @@ -135,7 +149,15 @@ nppes <- function(npi = NULL, zip <- zip %nn% as.character(zip) if (!is.null(entype)) { + entype <- rlang::arg_match(entype, c("I", "O")) + + # entype <- switch( + # entype, + # "I" = "NPI-1", + # "O" = "NPI-2" + # ) + entype <- dplyr::case_when(entype == "I" ~ "NPI-1", entype == "O" ~ "NPI-2") } diff --git a/R/prescribers.R b/R/prescribers.R index 5866aad7..eda73437 100644 --- a/R/prescribers.R +++ b/R/prescribers.R @@ -131,36 +131,36 @@ NULL #' @param tidy < *boolean* > // __default:__ `TRUE` Tidy output #' @param nest < *boolean* > // __default:__ `TRUE` Nest output #' @param na.rm < *boolean* > // __default:__ `TRUE` Remove empty rows and columns -#' @param ... Empty +#' @param ... For future use. #' @rdname prescribers #' @autoglobal #' @export prescribers <- function(year, type, - npi = NULL, - first = NULL, - last = NULL, - organization = NULL, - credential = NULL, - gender = NULL, - entype = NULL, - city = NULL, - state = NULL, - zip = NULL, - fips = NULL, - ruca = NULL, - country = NULL, - specialty = NULL, - brand_name = NULL, - generic_name = NULL, - level = NULL, - opioid = NULL, - opioidLA = NULL, - antibiotic = NULL, + npi = NULL, + first = NULL, + last = NULL, + organization = NULL, + credential = NULL, + gender = NULL, + entype = NULL, + city = NULL, + state = NULL, + zip = NULL, + fips = NULL, + ruca = NULL, + country = NULL, + specialty = NULL, + brand_name = NULL, + generic_name = NULL, + level = NULL, + opioid = NULL, + opioidLA = NULL, + antibiotic = NULL, antipsychotic = NULL, - tidy = TRUE, - nest = TRUE, - na.rm = TRUE, + tidy = TRUE, + nest = TRUE, + na.rm = TRUE, ...) { rlang::check_required(year) @@ -293,9 +293,9 @@ prescribers <- function(year, results$year <- year results <- switch(type, - 'Provider' = tidyup_provider.rx(results, nest = nest), - 'Drug' = tidyup_drug.rx(results, nest = nest), - 'Geography' = tidyup_geography.rx(results)) + 'Provider' = tidyup_provider.rx(results, nest = nest), + 'Drug' = tidyup_drug.rx(results, nest = nest), + 'Geography' = tidyup_geography.rx(results)) if (na.rm) results <- narm(results) @@ -364,7 +364,7 @@ tidyup_drug.rx <- function(results, nest = TRUE) { 'suppress_ge65', 'suppress_bene_ge65'))) } - return(results) + return(results) } #' @param results data frame from [prescribers(type = "Provider")] @@ -438,6 +438,7 @@ tidyup_provider.rx <- function(results, nest = TRUE) { 'tot_benes_opioid_la', 'tot_claims_antibioc', 'tot_cost_antibioc', + 'tot_benes_antibioc', 'suppress_brand', 'suppress_generic', 'suppress_other', @@ -450,11 +451,14 @@ tidyup_provider.rx <- function(results, nest = TRUE) { 'bene_age_lt65', 'bene_age_65_74', 'bene_age_75_84', + 'bene_age_gt84', + 'bene_gen_female', + 'bene_gen_male', 'bene_race_wht', 'bene_race_nonwht', 'bene_race_api', 'bene_race_nat', - 'bene_race_other', + 'bene_race_oth', 'bene_dual', 'bene_ndual'))) |> tidyr::nest(gte_65 = dplyr::any_of(c( diff --git a/R/taxonomy.R b/R/taxonomy.R index 455f9289..dcf0886e 100644 --- a/R/taxonomy.R +++ b/R/taxonomy.R @@ -1,8 +1,6 @@ #' Provider Taxonomies #' #' @description -#' `r lifecycle::badge("questioning")` -#' #' `taxonomy_codes()` returns a [tibble()] of the current Health Care Provider #' Taxonomy code set #' diff --git a/data-raw/taxonomy_codeset.R b/data-raw/taxonomy_codeset.R index 66b4f13c..f6f22c8f 100644 --- a/data-raw/taxonomy_codeset.R +++ b/data-raw/taxonomy_codeset.R @@ -9,3 +9,95 @@ board |> pins::pin_write(nucc, type = "qs") board |> pins::write_board_manifest() + +x <- rvest::session("https://www.nucc.org") |> + rvest::session_follow_link("Code Sets") |> + rvest::session_follow_link("Taxonomy") |> + rvest::session_follow_link("CSV") |> + rvest::html_elements("a") |> + rvest::html_attr("href") |> + stringr::str_subset("taxonomy") |> + stringr::str_subset("csv") + +x <- rvest::session(paste0("https://www.nucc.org", x)) |> + rvest::session_follow_link("Version") + +x <- x$response$url + +taxonomy <- data.table::fread(x) |> + dplyr::tibble() |> + janitor::clean_names() |> + dplyr::mutate( + dplyr::across(dplyr::everything(), ~ dplyr::na_if(., "")), + dplyr::across(dplyr::everything(), ~ stringr::str_squish(.))) |> + dplyr::mutate(version = as.character(240), + release_date = lubridate::ymd("2024-01-01")) +taxonomy <- taxonomy |> + dplyr::select( + code, + display_name, + section, + grouping, + classification, + specialization, + definition, + notes, + version, + release_date + ) +# https://www.nucc.org/images/stories/CSV/nucc_taxonomy_240.csv +# "2023-07-01" +# "2024-01-01" + +info <- taxonomy |> + dplyr::select(code, display_name, definition, notes) + +long <- taxonomy |> + dplyr::select(code, + section, + grouping, + classification, + specialization) |> + dplyr::mutate(section_level = 0, .before = section) |> + dplyr::mutate(grouping_level = 1, .before = grouping) |> + dplyr::mutate(classification_level = 2, .before = classification) |> + dplyr::mutate(specialization_level = 3, .before = specialization) |> + tidyr::unite("section", section:section_level, remove = TRUE) |> + tidyr::unite("grouping", grouping:grouping_level, remove = TRUE) |> + tidyr::unite("classification", classification:classification_level, remove = TRUE, na.rm = TRUE) |> + tidyr::unite("specialization", specialization:specialization_level, remove = TRUE, na.rm = TRUE) |> + tidyr::pivot_longer(!code, names_to = "level", values_to = "description") |> + dplyr::filter(description != "3") |> + tidyr::separate_wider_delim(description, delim = "_", names = c("description", "group")) |> + dplyr::mutate(group = NULL, + level = factor(level, + levels = c("section", "grouping", "classification", "specialization"), + labels = c("I. Section", "II. Grouping", "III. Classification", "IV. Specialization"), + ordered = TRUE)) + +longnest <- long |> + dplyr::left_join(info, by = "code") |> + tidyr::nest(hierarchy = c(level, description)) |> + dplyr::select(code, display_name, hierarchy, definition, notes) + +# Update Pin +board <- pins::board_folder(here::here("inst/extdata/pins")) + +board |> + pins::pin_write(taxonomy, + name = "taxonomy", + title = "Provider Taxonomy Code Set", + description = "NUCC Health Care Provider Taxonomy Code Set January 2024", + type = "qs") + +board |> + pins::pin_write(longnest, + name = "taxlong", + title = "Provider Taxonomy Code Set", + description = "NUCC Health Care Provider Taxonomy Code Set January 2024", + type = "qs") + +board |> pins::write_board_manifest() + +# pins::pin_search(board) +# pins::pin_delete(board, "tax_long") diff --git a/man-roxygen/args-dots.R b/man-roxygen/args-dots.R new file mode 100644 index 00000000..3798ab6d --- /dev/null +++ b/man-roxygen/args-dots.R @@ -0,0 +1 @@ +#' @param ... Empty dots diff --git a/man-roxygen/args-narm.R b/man-roxygen/args-narm.R new file mode 100644 index 00000000..fcbd10cb --- /dev/null +++ b/man-roxygen/args-narm.R @@ -0,0 +1 @@ +#' @param na.rm `` Remove empty rows and columns; __default__ is `TRUE` diff --git a/man-roxygen/args-npi.R b/man-roxygen/args-npi.R new file mode 100644 index 00000000..768a1cf3 --- /dev/null +++ b/man-roxygen/args-npi.R @@ -0,0 +1,2 @@ +#' @param npi `` Unique 10-digit National Provider Identifier number issued +#' by CMS to US healthcare providers through NPPES. diff --git a/man-roxygen/args-offset.R b/man-roxygen/args-offset.R new file mode 100644 index 00000000..71d4181e --- /dev/null +++ b/man-roxygen/args-offset.R @@ -0,0 +1 @@ +#' @param offset `` API pagination, __default__ is `0L` diff --git a/man-roxygen/args-pac.R b/man-roxygen/args-pac.R new file mode 100644 index 00000000..b9a2a9bc --- /dev/null +++ b/man-roxygen/args-pac.R @@ -0,0 +1,6 @@ +#' @param pac `` Unique 10-digit Provider Associate-level Control ID (PAC), +#' assigned to each individual or organization in PECOS. The PAC ID links all +#' entity-level information (e.g., tax identification numbers and +#' organizational names) and may be associated with multiple enrollment IDs if +#' the individual or organization enrolled multiple times under different +#' circumstances. diff --git a/man-roxygen/args-tidy.R b/man-roxygen/args-tidy.R new file mode 100644 index 00000000..9f252655 --- /dev/null +++ b/man-roxygen/args-tidy.R @@ -0,0 +1 @@ +#' @param tidy `` Tidy output; __default__ is `TRUE` diff --git a/man-roxygen/args-unnest.R b/man-roxygen/args-unnest.R new file mode 100644 index 00000000..ce6fcfb4 --- /dev/null +++ b/man-roxygen/args-unnest.R @@ -0,0 +1 @@ +#' @param unnest `` Unnest list columns; __default__ is `TRUE` diff --git a/man-roxygen/returns.R b/man-roxygen/returns.R new file mode 100644 index 00000000..d2bf7928 --- /dev/null +++ b/man-roxygen/returns.R @@ -0,0 +1 @@ +#' @returns A [tibble][tibble::tibble-package] containing the search results. diff --git a/man/affiliations.Rd b/man/affiliations.Rd index aaf2cc10..b4669630 100644 --- a/man/affiliations.Rd +++ b/man/affiliations.Rd @@ -20,57 +20,50 @@ affiliations( ) } \arguments{ -\item{npi}{< \emph{integer} > 10-digit Individual National Provider Identifier} +\item{npi}{\verb{} Unique 10-digit National Provider Identifier number issued +by CMS to US healthcare providers through NPPES.} -\item{pac}{< \emph{integer} > 10-digit Individual PECOS Associate Control ID} +\item{pac}{\verb{} Unique 10-digit Provider Associate-level Control ID (PAC), +assigned to each individual or organization in PECOS. The PAC ID links all +entity-level information (e.g., tax identification numbers and +organizational names) and may be associated with multiple enrollment IDs if +the individual or organization enrolled multiple times under different +circumstances.} -\item{first, middle, last}{< \emph{character} > Individual Provider's name} +\item{first, middle, last}{\verb{} Individual provider's first/middle/last name} -\item{facility_type}{< \emph{character} > +\item{facility_type}{\verb{} Type of facility, one of the following: \itemize{ -\item \code{"Hospital"} or \code{"hp"} -\item \code{"Long-term care hospital"} or \code{"ltch"} -\item \code{"Nursing home"} or \code{"nh"} -\item \code{"Inpatient rehabilitation facility"} or \code{"irf"} -\item \code{"Home health agency"} or \code{"hha"} -\item \code{"Skilled nursing facility"} or \code{"snf"} -\item \code{"Hospice"} or \code{"hs"} -\item \code{"Dialysis facility"} or \code{"df"} +\item \code{Hospital} (\code{hp}) +\item \verb{Long-term care hospital} (\code{ltch}) +\item \verb{Nursing home} (\code{nh}) +\item \verb{Inpatient rehabilitation facility} (\code{irf}) +\item \verb{Home health agency} (\code{hha}) +\item \verb{Skilled nursing facility} (\code{snf}) +\item \code{Hospice} (\code{hs}) +\item \verb{Dialysis facility} (\code{df}) }} -\item{facility_ccn}{< \emph{character} > 6-digit CMS Certification Number of -facility or unit within hospital where an individual provider provides service} +\item{facility_ccn}{\verb{} 6-digit CMS Certification Number of facility or +unit within hospital where an individual provider provides service.} -\item{parent_ccn}{< \emph{integer} > 6-digit CMS Certification Number of a sub-unit's -primary hospital, should the provider provide services in said unit} +\item{parent_ccn}{\verb{} 6-digit CMS Certification Number of a sub-unit's +primary hospital, should the provider provide services in said unit.} -\item{offset}{< \emph{integer} > // \strong{default:} \code{0L} API pagination} +\item{offset}{\verb{} API pagination, \strong{default} is \code{0L}} -\item{tidy}{< \emph{boolean} > // \strong{default:} \code{TRUE} Tidy output} +\item{tidy}{\verb{} Tidy output; \strong{default} is \code{TRUE}} -\item{na.rm}{< \emph{boolean} > // \strong{default:} \code{TRUE} Remove empty rows and columns} +\item{na.rm}{\verb{} Remove empty rows and columns; \strong{default} is \code{TRUE}} -\item{...}{Empty} +\item{...}{Empty dots} } \value{ -A \link[tibble:tibble-package]{tibble} with the columns:\tabular{ll}{ - \strong{Field} \tab \strong{Description} \cr - \code{npi} \tab 10-digit NPI \cr - \code{pac} \tab 10-digit individual PAC ID \cr - \code{first} \tab Individual provider's first name \cr - \code{middle} \tab Individual provider's middle name \cr - \code{last} \tab Individual provider's last name \cr - \code{suffix} \tab Individual provider's suffix \cr - \code{facility_type} \tab Category of facility \cr - \code{facility_ccn} \tab Facility's 6-digit CCN \cr - \code{parent_ccn} \tab Primary facility's 6-digit CCN \cr -} +A \link[tibble:tibble-package]{tibble} containing the search results. } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -\code{\link[=affiliations]{affiliations()}} allows the user access to data concerning providers' -facility affiliations +\code{\link[=affiliations]{affiliations()}} allows the user access to data concerning +providers' facility affiliations } \section{Links}{ diff --git a/man/nppes.Rd b/man/nppes.Rd index b8fae36d..7af4a043 100644 --- a/man/nppes.Rd +++ b/man/nppes.Rd @@ -25,123 +25,115 @@ nppes( ) } \arguments{ -\item{npi}{< \emph{integer | character} > 10-digit Organizational National Provider Identifier} +\item{npi}{\verb{} Unique 10-digit National Provider Identifier number issued +by CMS to US healthcare providers through NPPES.} -\item{entype}{< \emph{character} > Entity/enumeration type \emph{Cannot be the only criteria entered.} -\itemize{ -\item \code{"I"}: Individual provider (NPI-1) -\item \code{"O"}: Organizational provider (NPI-2) -}} +\item{entype}{\verb{} Entity type; one of either \code{I} for Individual (NPI-1) +or \code{O} for Organizational (NPI-2)} -\item{first, last}{< \emph{character} > // \strong{WC} Individual provider's name} +\item{first, last}{\verb{} \strong{WC} Individual provider's first and/or last name} -\item{organization}{< \emph{character} > // \strong{WC} Organization's name. Many -types of names (LBN, DBA, Former LBN, Other Name) may match. As such, the -results might contain a name different from the one entered.} +\item{organization}{\verb{} \strong{WC} Organizational provider's name. Many types +of names (LBN, DBA, Former LBN, Other Name) may match. As such, the results +might contain a name different from the one entered.} -\item{name_type}{< \emph{character} > Type of individual the name arguments -refer to: -\itemize{ -\item \code{"AO"}: search Authorized Officials only -\item \code{"Provider"}: search Individual Providers only -}} +\item{name_type}{\verb{} Type of individual the \code{first} and \code{last} name +parameters refer to; one of either \code{AO} for Authorized Officials or +\code{Provider} for Individual Providers.} -\item{taxonomy_desc}{< \emph{character} > Provider's taxonomy description, -e.g. \code{"Pharmacist"}, \code{"Pediatrics"}} +\item{taxonomy_desc}{\verb{} Provider's taxonomy description, e.g. +\code{Pharmacist}, \code{Pediatrics}} -\item{city}{< \emph{character} > Provider's city. To search for a military -address, enter either \code{"APO"} or \code{"FPO"}.} +\item{city}{\verb{} City name. For military addresses, search for either +\code{APO} or \code{FPO}.} -\item{state}{< \emph{character} > Provider's state abbreviation. If the only -input, one other param besides \code{entype} and \code{country} must be input.} +\item{state}{\verb{} 2-character state abbreviation. If it is the only input, +one other parameter besides \code{entype} and \code{country} is required.} -\item{zip}{< \emph{character} > // \strong{WC} Provider's zip code} +\item{zip}{\verb{} \strong{WC} 5- to 9-digit zip code, without a hyphen.} -\item{country}{< \emph{character} > Provider's country code. Can be used as the -only input, as long as the input \emph{is not} \code{"US"}.} +\item{country}{\verb{} 2-character country abbreviation. Can be the only +input, as long as it \emph{is not} \code{US}.} -\item{limit}{< \emph{integer} > // \strong{default:} \code{1200L} Max results to return} +\item{limit}{\verb{} Maximum number of results to return; \strong{default} is +\code{1200L}} -\item{skip}{< \emph{integer} > // \strong{default:} \code{0L} Number of results to skip -after those returned} +\item{skip}{\verb{} Number of results to skip after those initially returned +by the API; \strong{default} is \code{0L}} -\item{unnest}{< \emph{boolean} > // \strong{default:} \code{TRUE} Unnest list columns} +\item{unnest}{\verb{} Unnest list columns; \strong{default} is \code{TRUE}} -\item{tidy}{< \emph{boolean} > // \strong{default:} \code{TRUE} Tidy output} +\item{tidy}{\verb{} Tidy output; \strong{default} is \code{TRUE}} -\item{na.rm}{< \emph{boolean} > // \strong{default:} \code{TRUE} Remove empty rows and columns} +\item{na.rm}{\verb{} Remove empty rows and columns; \strong{default} is \code{TRUE}} -\item{...}{Empty} +\item{...}{Empty dots} } \value{ A \link[tibble:tibble-package]{tibble} containing the search results. } \description{ -\code{\link[=nppes]{nppes()}} allows the user to search the National Plan and Provider -Enumeration System (NPPES) NPI Registry, a free directory of all active NPI -records. +\code{\link[=nppes]{nppes()}} allows the user to search the National Plan and +Provider Enumeration System (NPPES) NPI Registry, a free directory of all +active NPI records. } \section{\strong{National Provider Identifier (NPI)}}{ - -Healthcare providers acquire their unique 10-digit NPIs to identify -themselves in a standard way throughout their industry. Once CMS supplies -an NPI, they publish the parts of the NPI record that have public relevance, -including the provider’s name, taxonomy and practice address. + Healthcare providers acquire +their unique 10-digit NPIs to identify themselves in a standard way +throughout their industry. Once CMS supplies an NPI, they publish the parts +of the NPI record that have public relevance, including the provider’s +name, taxonomy and practice address. } \section{\strong{Entity/Enumeration Type}}{ - -Two categories of health care providers exist for NPI enumeration purposes: + Two categories of health care providers +exist for NPI enumeration purposes: \strong{Type 1}: Individual providers may get an NPI as \emph{Entity Type 1}. -\emph{Sole Proprietorship} -A sole proprietor is one who does not conduct business as a corporation and, -thus, \strong{is not} an incorporated individual. +\emph{Sole Proprietorship} A sole proprietor is one who does not conduct +business as a corporation and, thus, \strong{is not} an incorporated individual. An \strong{incorporated individual} is an individual provider who forms and conducts business under a corporation. This provider may have a Type 1 NPI while the corporation has its own Type 2 NPI. -A solo practitioner is not necessarily a sole proprietor, and vice versa. The -following factors do not affect whether a sole proprietor is a Type 1 entity: -\itemize{ -\item Multiple office locations -\item Having employees -\item Having an EIN -} +A solo practitioner is not necessarily a sole proprietor, and vice versa. +The following factors do not affect whether a sole proprietor is a Type 1 +entity: + Multiple office locations + Having employees + Having an EIN \strong{Type 2}: Organizational providers are eligible for \emph{Entity Type 2} NPIs. -Organizational or Group providers may have a single employee or thousands of employees. -An example is an \strong{incorporated individual} who is an organization's only -employee. +Organizational or Group providers may have a single employee or thousands +of employees. An example is an \strong{incorporated individual} who is an +organization's only employee. Some organization health care providers are made up of parts that work -somewhat independently from -their parent organization. These parts may offer different types of health -care or offer health care in separate physical locations. These parts and -their physical locations aren't themselves legal entities but are part of -the organization health care provider (which is a legal entity). The NPI -Final Rule refers to the parts and locations as sub-parts. An organization -health care provider can get its sub-parts their own NPIs. If a sub-part -conducts any HIPAA standard transactions on its own (separately from its -parent), it must get its own NPI. Sub-part determination makes sure that -entities within a covered organization are uniquely identified in HIPAA -standard transactions they conduct with Medicare and other covered entities. -For example, a hospital offers acute care, laboratory, pharmacy, and -rehabilitation services. Each of these sub-parts may need its own NPI because -each sends its own standard transactions to one or more health plans. Sub-part -delegation doesn't affect Entity Type 1 health care providers. As individuals, -these health care providers can't choose sub-parts and are not sub-parts. +somewhat independently from their parent organization. These parts may +offer different types of health care or offer health care in separate +physical locations. These parts and their physical locations aren't +themselves legal entities but are part of the organization health care +provider (which is a legal entity). The NPI Final Rule refers to the parts +and locations as sub-parts. An organization health care provider can get +its sub-parts their own NPIs. If a sub-part conducts any HIPAA standard +transactions on its own (separately from its parent), it must get its own +NPI. Sub-part determination makes sure that entities within a covered +organization are uniquely identified in HIPAA standard transactions they +conduct with Medicare and other covered entities. For example, a hospital +offers acute care, laboratory, pharmacy, and rehabilitation services. Each +of these sub-parts may need its own NPI because each sends its own standard +transactions to one or more health plans. Sub-part delegation doesn't +affect Entity Type 1 health care providers. As individuals, these health +care providers can't choose sub-parts and are not sub-parts. \strong{Authorized Official} \if{html}{\out{
}} -An appointed official (e.g., chief executive officer, chief financial officer, -general partner, chairman of the board, or direct owner) to whom the -organization has granted the legal authority to enroll it in the Medicare -program, to make changes or updates to the organization's status in the -Medicare program, and to commit the organization to fully abide by the -statutes, regulations, and program instructions of the Medicare program. +An appointed official (e.g., chief executive officer, chief financial +officer, general partner, chairman of the board, or direct owner) to whom +the organization has granted the legal authority to enroll it in the +Medicare program, to make changes or updates to the organization's status +in the Medicare program, and to commit the organization to fully abide by +the statutes, regulations, and program instructions of the Medicare +program. } \section{Links}{ @@ -154,10 +146,9 @@ statutes, regulations, and program instructions of the Medicare program. } \section{Trailing Wildcard Entries}{ - -Arguments that allow trailing wildcard entries are denoted in the parameter -description with \strong{WC}. Wildcard entries require at least two -characters to be entered, e.g. \code{"jo*"} + Arguments that allow trailing wildcard +entries are denoted in the parameter description with \strong{WC}. Wildcard +entries require at least two characters to be entered, e.g. \code{"jo*"} } \section{Update Frequency}{ @@ -168,7 +159,9 @@ characters to be entered, e.g. \code{"jo*"} \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} nppes(npi = 1528060837) -nppes(city = "CARROLLTON", state = "GA", zip = 301173889, entype = "I") +nppes(city = "CARROLLTON", + state = "GA", + zip = 301173889, + entype = "I") \dontshow{\}) # examplesIf} } -\concept{api} diff --git a/man/taxonomy_codes.Rd b/man/taxonomy_codes.Rd index c7a8a7d2..c79efd74 100644 --- a/man/taxonomy_codes.Rd +++ b/man/taxonomy_codes.Rd @@ -16,8 +16,6 @@ taxonomy_codes(shape = c("wide", "long")) A \link[tibble:tibble-package]{tibble} with the columns: } \description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#questioning}{\figure{lifecycle-questioning.svg}{options: alt='[Questioning]'}}}{\strong{[Questioning]}} - \code{taxonomy_codes()} returns a \code{\link[=tibble]{tibble()}} of the current Health Care Provider Taxonomy code set