Skip to content

Commit

Permalink
updated long pin, retrieval function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Nov 29, 2024
1 parent 2ec7076 commit 683c103
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 28 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: arktax
Title: Archive: NUCC Taxonomy Codesets, 2009 - 2024
Version: 0.0.0.9000
Authors@R:
person("Andrew", "Bruce", , "andrewallenbruce@gmail.com", role = c("aut", "cre", "cph"))
person(c("Andrew", "Allen"), "Bruce", , "andrewallenbruce@gmail.com", role = c("aut", "cre", "cph"))
Maintainer: Andrew Bruce <andrewallenbruce@gmail.com>
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Expand All @@ -17,7 +17,7 @@ Imports:
Suggests:
qs,
roxyglobals,
testthat (>= 3.0.0),
testthat (>= 3.0.0)
Remotes:
andrewallenbruce/fuimus
Config/roxyglobals/filename: generated-globals.R
Expand Down
14 changes: 10 additions & 4 deletions R/arktax.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
#'
#' @param year `<int>` year of source file release; options are `2009:2024`
#'
#' @param code `<chr>` Taxonomy code
#' @param version `<int>` version of source file; options are `0` or `1`
#'
#' @param which `<chr>` wide or long version of the taxonomy; options are `wide` or `long`
#' @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
#'
#' @returns `<tibble>` of search results
#'
#' @examples
#' retrieve_ark(year = 2024, code = "101Y00000X", which = "wide")
#'
#' retrieve_ark(year = 2024, code = "101Y00000X", which = "long")
#' retrieve_ark(code = "101Y00000X", which = "long")
#'
#' @importFrom fuimus search_in_if
#'
#' @autoglobal
#'
#' @export
retrieve_ark <- function(year = NULL,
version = NULL,
code = NULL,
which = c("wide", "long")) {

Expand All @@ -28,7 +31,10 @@ retrieve_ark <- function(year = NULL,
long = get_pin("ark_long")
)

ark <- search_in_if(ark, ark[["year"]], year)
if (which == "wide") {
ark <- search_in_if(ark, ark[["year"]], year)
ark <- search_in_if(ark, ark[["version"]], version)
}

ark <- search_in_if(ark, ark[["code"]], code)

Expand Down
10 changes: 0 additions & 10 deletions data-raw/gert_git.R

This file was deleted.

6 changes: 3 additions & 3 deletions data-raw/nucc_pins.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ ark_long |>
dplyr::arrange(year) |>
print(n = 100)

# ark_long <- get_pin("ark_long") |>
# dplyr::distinct(code, level, description)

pin_update(
ark_long,
name = "ark_long",
Expand All @@ -168,6 +171,3 @@ ark_long |>
dplyr::arrange(code, level, year) |>
dplyr::filter(code == "133VN1201X") |>
print(n = 100)



14 changes: 14 additions & 0 deletions data-raw/raw/Taxonomy Notes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[1] Medicare no longer enrolls this provider type.
"[2] This is an arrangement whereby immunization services are rendered by health care providers who are under contract to the entity/individual who is enrolled in Medicare as a ""Mass Immunization Roster Biller"". The Healthcare Provider Taxonomy Code(s) would be that (those) of the health care provider(s) who render the immunization services. "
"[3] Medicare carriers use Specialty Code 87 for Pharmacies when processing prescription drugs that are paid through the Medicare Physician Fee Schedule. However, the description for Specialty Code 87 remains All Other Suppliers."
"[4] Because the Medicare Provider Type Physician/Undefined Physician Type applies to physicians,Unknown Supplier/Provider Specialty applies to other than physicians. Because Medicare does not enroll every non-physician supplier/provider type in the Healthcare Provider Taxonomy Code Set, we cannot arbitrarily link this Medicare Provider Type to all remaining supplier/provider types in the Healthcare Provider Taxonomy Code Set. In truth, this Medicare Provider Type would link to every Healthcare Provider Taxonomy Code (except those that describe physicians) that is listed in this document. We do not list them here because doing so would greatly increase the size of this document."
"[5] Because the Medicare Provider Type indicates that the provider/supplier is a Physician, we have linked this to the most generic Allopathic & Osteopathic Physicians classification. It could technically link to every Allopathic & Osteopathic Physician."
[6] Medicare specialty code designation is for Part B DMEPOS purposes.
[7] Medicare specialty code designation is for Part B DMEPOS purposes.
[8] Medicare specialty code designation is for Part B DMEPOS purposes.
[9] Medicare specialty code designation is for Part B DMEPOS purposes.
[10] Medicare specialty code designation is for Part B DMEPOS purposes.
[11] Medicare specialty code designation is for Part B DMEPOS purposes.
"[12] There is no linkage to specific ""Healthcare Provider Taxonomy Codes"" because an ""Indian Health Service""facility can be various provider types/classifications."
[13] Medicare specialty code designation is for Part B DMEPOS purposes.
[14] Does not meet the definition of health care provider at 45 CFR 160.103 is not eligible for an NPI.
56 changes: 56 additions & 0 deletions data-raw/splitting.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
source(here::here("data-raw", "pins_internal.R"))

wide <- arktax::retrieve_ark(year = 2024, which = "wide") |>
dplyr::select(-modified, -effective, -deactivated)

base <- wide |>
dplyr::select(code, notes) |>
dplyr::distinct(code, notes, .keep_all = TRUE) |>
dplyr::mutate(
.id = dplyr::row_number(),
updates = stringr::str_extract_all(notes, "\\[.*\\]"),
sources = stringr::str_remove_all(notes, "\\s?\\[.*\\]") |> dplyr::na_if(""),
notes = NULL) |>
tidyr::unnest(updates, keep_empty = TRUE)

updates <- base |>
dplyr::select(-sources) |>
dplyr::filter(not_na(updates)) |>
tidyr::separate_longer_delim(
cols = updates,
delim = stringr::fixed("; ")) |>
dplyr::mutate(
updates = stringr::str_remove_all(updates, "(^\\[)|(\\]$)"),
first = stringr::str_extract_all(updates, ", \\d{1,2}")) |>
tidyr::unnest(first, keep_empty = TRUE) |>
dplyr::mutate(
first = str_remove(first, ", "),
multi = str_count(updates, ", \\d{1}/\\d{1}/\\d{4}"))

updates <- vctrs::vec_rbind(
updates |> dplyr::filter(multi == 0),
updates |>
dplyr::filter(multi > 0) |>
tidyr::separate_longer_delim(
cols = updates,
delim = stringr::regex(", \\d{1,2}")) |>
dplyr::mutate(updates = dplyr::if_else(
stringr::str_detect(updates, "^[/]"),
stringr::str_glue("{first}{updates}"), updates))
) |>
dplyr::select(-first, -multi) |>
dplyr::mutate(
dates = stringr::str_extract_all(updates, "\\d{1,2}[/]\\d{1,2}[/]\\d{4}"),
updates = stringr::str_remove_all(updates, "\\d{1,2}[/]\\d{1,2}[/]\\d{4}[:, ]\\s?")) |>
tidyr::unnest(dates, keep_empty = TRUE) |>
dplyr::mutate(dates = clock::date_parse(dates, format = "%m/%d/%Y"))

updates |>
dplyr::mutate(
date_type = dplyr::case_when(
stringr::str_detect(updates, "[Nn]ew") ~ "effective",
stringr::str_detect(updates, "inactive") ~ "deactivated",
.default = "modified") |> forcats::as_factor()) |>
dplyr::arrange(code, dates) |>
dplyr::count(updates, sort = TRUE) |>
print(n = 50)
2 changes: 1 addition & 1 deletion inst/extdata/pins/_pins.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ark_long:
- ark_long/20241124T223231Z-c6e54/
- ark_long/20241129T111715Z-13827/
ark_taxonomy:
- ark_taxonomy/20241124T214441Z-05252/
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
file: ark_long.qs
file_size: 26012
pin_hash: c6e54d54d4b7fdd4
file_size: 13738
pin_hash: 13827f0ad127660e
type: qs
title: NUCC Taxonomy Archive 2009-2024 (Long)
description: Health Care Provider Taxonomy Code Set Archive 2009-2024 (Long)
tags: ~
urls: ~
created: 20241124T223231Z
created: 20241129T111715Z
api_version: 1
2 changes: 1 addition & 1 deletion man/arktax-package.Rd

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

15 changes: 11 additions & 4 deletions man/retrieve_ark.Rd

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

0 comments on commit 683c103

Please sign in to comment.