Skip to content

Commit

Permalink
testing recoding factors: hospitals (#38)
Browse files Browse the repository at this point in the history
fixed missing col in hospitals output
reassignments documentation
  • Loading branch information
andrewallenbruce committed Nov 5, 2023
1 parent 05088e7 commit 0b00599
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
34 changes: 32 additions & 2 deletions R/hospitals.R
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ hospitals <- function(npi = NULL,
dplyr::mutate(proprietary_nonprofit = dplyr::case_match(proprietary_nonprofit,
"P" ~ "Proprietary",
"N" ~ "Non-Profit",
.default = NA)) |>
.default = NA),
proprietary_nonprofit = fct_reg(proprietary_nonprofit)) |>
cols_hosp(1)

if (pivot) {
Expand All @@ -301,14 +302,42 @@ hospitals <- function(npi = NULL,
values_to = "flag") |>
dplyr::mutate(subgroup = stringr::str_remove(subgroup, "Subgroup ")) |>
dplyr::filter(flag == TRUE) |>
dplyr::mutate(flag = NULL)
dplyr::mutate(flag = NULL,
subgroup = fct_sub(subgroup))

}
if (na.rm) results <- narm(results)
}
return(results)
}

#' @param x vector
#' @autoglobal
#' @noRd
fct_reg <- function(x) {
factor(x, levels = c("Non-Profit", "Proprietor"))
}

#' @param x vector
#' @autoglobal
#' @noRd
fct_sub <- function(x) {
factor(x, levels = c("Acute Care",
"Alcohol Drug",
"Childrens' Hospital",
"General",
"Long-term",
"None",
"Other",
"Psychiatric",
"Psychiatric Unit",
"Rehabilitation",
"Rehabilitation Unit",
"Short-Term",
"Specialty Hospital",
"Swing-Bed Approved"))
}

#' @param df data frame
#' @param step step 1 or 2 in pipeline
#' @autoglobal
Expand Down Expand Up @@ -371,6 +400,7 @@ cols_hosp <- function(df, step = c(1, 2)) {
'state',
'zip',
'location_type',
'registration',
'multi_npi',
'reh_date',
'reh_ccns',
Expand Down
18 changes: 17 additions & 1 deletion R/reassignments.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,21 @@
#' @param tidy < *boolean* > // __default:__ `TRUE` Tidy output
#' @param na.rm < *boolean* > // __default:__ `TRUE` Remove empty rows and columns
#'
#' @return A [tibble][tibble::tibble-package] containing the search results.
#' @return A [tibble][tibble::tibble-package] with the columns:
#'
#' |**Field** |**Description** |
#' |:---------------|:------------------------------------------------------------------|
#' |`npi` |_Individual_ National Provider Identifier |
#' |`pac` |_Individual_ PECOS Associate Control ID |
#' |`enid` |_Individual_ Medicare Enrollment ID |
#' |`first` |_Individual_ Provider's First Name |
#' |`last` |_Individual_ Provider's Last Name |
#' |`associations` |Number of Organizations _Individual_ Reassigns Benefits To |
#' |`pac_org` |_Organization's_ PECOS Associate Control ID |
#' |`enid_org` |_Organization's_ Medicare Enrollment ID |
#' |`state_org` |State _Organization_ Enrolled in Medicare |
#' |`reassignments` |Number of Individuals the _Organization_ Accepts Reassignment From |
#' |`entry` |Whether Entry is for _Reassignment_ or _Employment_ |
#'
#' @examplesIf interactive()
#' reassignments(enid = "I20200929003184")
Expand Down Expand Up @@ -153,7 +167,9 @@ record_type <- function(x) {

#' @autoglobal
#' @noRd
# nocov start
georgia_reassignments <- function() {
pins::board_url(github_raw("andrewallenbruce/provider/main/pkgdown/assets/pins-board/")) |>
pins::pin_read("georgia_reassignments")
}
# nocov end
15 changes: 14 additions & 1 deletion man/reassignments.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-cols.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ test_that("cols_hosp() works", {
state = 1,
zip = 1,
location_type = 1,
registration = 1,
multi_npi = 1,
reh_date = 1,
reh_ccns = 1,
Expand Down

0 comments on commit 0b00599

Please sign in to comment.