Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Nov 5, 2023
1 parent 91f938d commit 629f1d4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 39 deletions.
46 changes: 34 additions & 12 deletions R/betos.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ betos <- function(hcpcs = NULL,

if (tidy) {
results <- tidyup(results, dt = c("dt")) |> # nolint
dplyr::mutate(rbcs_major_ind = dplyr::case_match(rbcs_major_ind,
"N" ~ "Non-procedure",
"M" ~ "Major",
"O" ~ "Other")) |>
dplyr::mutate(
rbcs_major_ind = dplyr::case_match(rbcs_major_ind,
"N" ~ "Non-procedure",
"M" ~ "Major",
"O" ~ "Other")) |>
cols_betos()
}
return(results)
Expand All @@ -115,20 +116,41 @@ betos <- function(hcpcs = NULL,
#' @noRd
cols_betos <- function(df) {

cols <- c('hcpcs' = 'hcpcs_cd',
cols <- c('hcpcs' = 'hcpcs_cd',
'rbcs_id',
# 'rbcs_cat',
'category' = 'rbcs_cat_desc',
'category' = 'rbcs_cat_desc',
# 'rbcs_cat_subcat',
'subcategory' = 'rbcs_subcat_desc',
'subcategory' = 'rbcs_subcat_desc',
# 'rbcs_fam_numb',
'family' = 'rbcs_family_desc',
'procedure' = 'rbcs_major_ind',
'family' = 'rbcs_family_desc',
'procedure' = 'rbcs_major_ind',
'hcpcs_start_date' = 'hcpcs_cd_add_dt',
'hcpcs_end_date' = 'hcpcs_cd_end_dt',
'rbcs_start_date' = 'rbcs_assignment_eff_dt',
'rbcs_end_date' = 'rbcs_assignment_end_dt')
'hcpcs_end_date' = 'hcpcs_cd_end_dt',
'rbcs_start_date' = 'rbcs_assignment_eff_dt',
'rbcs_end_date' = 'rbcs_assignment_end_dt')

df |> dplyr::select(dplyr::any_of(cols))
}

#' @param df data frame
#' @autoglobal
#' @noRd
rbcs_util <- function(df) {

rbcs <- df |>
dplyr::distinct(hcpcs) |>
dplyr::pull(hcpcs) |>
purrr::map(\(x) betos(hcpcs = x)) |>
purrr::list_rbind()

if (vctrs::vec_is_empty(rbcs)) {

return(df)

} else {

rbcs <- dplyr::select(rbcs, hcpcs, category, subcategory, family, procedure)
cols_util(dplyr::full_join(df, rbcs, by = dplyr::join_by(hcpcs)), "rbcs")
}
}
16 changes: 16 additions & 0 deletions R/ndc.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,22 @@
#'
#' @param ndc < *character* > // **required** 10- to 11-digit National Drug Code
#' @return A [tibble][tibble::tibble-package] with the columns:
#'
#' |**Field** |**Description** |
#' |:------------|:-----------------------------------------------|
#' |`ndc` |National Drug Code |
#' |`rxcui` |RxNorm Identifier |
#' |`atc` |ATC Identifier |
#' |`status` |Status (NDC) |
#' |`brand_name` |Brand Name (RxCUI) |
#' |`drug_name` |Drug Name (RxCUI) |
#' |`atc_first` |ATC I: Anatomical, Pharmacological |
#' |`atc_first` |ATC II: Pharmacological, Therapeutic |
#' |`atc_first` |ATC III: Chemical, Pharmacological, Therapeutic |
#' |`atc_first` |ATC IV: Chemical, Pharmacological, Therapeutic |
#' |`subject` |Medline Plus: Subject |
#' |`summary` |Medline Plus: Summary |
#'
#' @autoglobal
#' @export
ndc_lookup <- function(ndc) {
Expand Down
2 changes: 0 additions & 2 deletions R/nppes.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,5 @@ cols_nppes <- function(df, step = c(1, 2)) {
'on_org_name' = 'on_organization_name')

}

df |> dplyr::select(dplyr::any_of(cols))

}
2 changes: 1 addition & 1 deletion R/open_payments.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
#' open_payments(year = 2021, payer = "Adaptive Biotechnologies Corporation")
#' open_payments(year = 2021, teaching_hospital = "Nyu Langone Hospitals")
#'
#' # Use the years helper function to retrieve results for all avaliable years:
#' # Use the years helper function to retrieve results for all available years:
#' open_years() |>
#' map(\(x) open_payments(year = x, npi = 1043477615)) |>
#' list_rbind()
Expand Down
3 changes: 1 addition & 2 deletions R/opt_out.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
#' |`state` |Opt-out provider's state |
#' |`zip` |Opt-out provider's zip code |
#'
#' @examples
#' @examplesIf interactive()
#' opt_out(npi = 1043522824)
#'
#' @examplesIf interactive()
#' # For opt-out providers eligible
#' # to order and refer, use [order_refer()]
#' # to look up their eligibility status:
Expand Down
22 changes: 0 additions & 22 deletions R/utilization.R
Original file line number Diff line number Diff line change
Expand Up @@ -531,28 +531,6 @@ cols_util <- function(df, type) {
df |> dplyr::select(dplyr::any_of(cols))
}

#' @param df data frame
#' @autoglobal
#' @noRd
rbcs_util <- function(df) {

rbcs <- df |>
dplyr::distinct(hcpcs) |>
dplyr::pull(hcpcs) |>
purrr::map(\(x) betos(hcpcs = x)) |>
purrr::list_rbind()

if (vctrs::vec_is_empty(rbcs)) {

return(df)

} else {

rbcs <- dplyr::select(rbcs, hcpcs, category, subcategory, family, procedure)
cols_util(dplyr::full_join(df, rbcs, by = dplyr::join_by(hcpcs)), "rbcs")
}
}

#' @param x vector
#' @autoglobal
#' @noRd
Expand Down

0 comments on commit 629f1d4

Please sign in to comment.