spsanderson/healthyR

Add function `service_line_augment`

spsanderson opened this issue · 0 comments

service_line_augment <- function(.data, .dx_col, .px_col, .drg_col){
  
  # Tidyeval ----
  dx_col <- rlang::enquo(.dx_col)
  px_col <- rlang::enquo(.px_col)
  drg_col <- rlang::enquo(.drg_col)
  
  # Data ----
  data <- tibble::as_tibble(.data)
  
  data <- data %>%
    dplyr::select(
      {{dx_col}},
      {{px_col}},
      {{drg_col}},
      dplyr::everything()
    )
  
  # Run vec func
  ret <- healthyR::service_line_vec(
    .data = data,
    .dx_col = {{dx_col}}, 
    .px_col = {{px_col}}, 
    .drg_col = {{drg_col}}
    )
  
  data <- cbind(data, ret) %>%
    tibble::as_tibble() %>%
    dplyr::mutate(dplyr::across(.cols = where(is.character), .fns = stringr::str_squish))
  
  # Return ----
  return(data)
  
}