Skip to content

Commit

Permalink
bug fix (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Oct 30, 2023
1 parent 10076c1 commit 34c801d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export(clinicians)
export(compare_conditions)
export(compare_hcpcs)
export(conditions)
export(df2chr)
export(display_long)
export(duration_vec)
export(gen_data)
Expand Down
3 changes: 2 additions & 1 deletion R/conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ conditions <- function(year,
return(invisible(NULL))
}

results <- httr2::resp_body_json(response, simplifyVector = TRUE)
results <- httr2::resp_body_json(response, simplifyVector = TRUE) |>
df2chr()

if (tidy) {
results$year <- year
Expand Down
3 changes: 2 additions & 1 deletion R/open_payments.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ open_payments <- function(year,
httr2::req_error(body = open_payments_error) |>
httr2::req_perform()

results <- httr2::resp_body_json(response, simplifyVector = TRUE)
results <- httr2::resp_body_json(response, simplifyVector = TRUE) |>
df2chr()

if (vctrs::vec_is_empty(results)) {

Expand Down
3 changes: 2 additions & 1 deletion R/quality_payment.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ quality_payment <- function(year,
return(invisible(NULL))
}

results <- httr2::resp_body_json(response, simplifyVector = TRUE)
results <- httr2::resp_body_json(response, simplifyVector = TRUE) |>
df2chr()

if (tidy) {
results$year <- year
Expand Down
3 changes: 2 additions & 1 deletion R/utilization.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ utilization <- function(year,
return(invisible(NULL))
}

results <- httr2::resp_body_json(response, simplifyVector = TRUE)
results <- httr2::resp_body_json(response, simplifyVector = TRUE) |>
df2chr()

if (tidy) {
results$year <- year
Expand Down
11 changes: 11 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ display_long <- function(df, cols = dplyr::everything()) {
tidyr::pivot_longer({{ cols }})
}


#' Convert data.frame cols to character
#' @param df data frame
#' @autoglobal
#' @export
#' @keywords internal
df2chr <- function(df) {

df |> dplyr::mutate(dplyr::across(dplyr::everything(), as.character))
}

#' Tidy a Data Frame
#' @param df data frame
#' @param dt cols to convert to date with [anytime::anydate()]
Expand Down
15 changes: 15 additions & 0 deletions man/df2chr.Rd

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

0 comments on commit 34c801d

Please sign in to comment.