Skip to content

Instantly share code, notes, and snippets.

@countdigi
Created November 30, 2023 13:38
Show Gist options
  • Save countdigi/5fef6ca3f18818fcb66149d86ab0c385 to your computer and use it in GitHub Desktop.
Save countdigi/5fef6ca3f18818fcb66149d86ab0c385 to your computer and use it in GitHub Desktop.
Parse Florida Blue CSV
#!/usr/bin/env Rscript --vanilla
suppressPackageStartupMessages({
library(argparse)
library(tidyverse)
})
# ----------------------------------------------------------------------------------------------------
parser<-ArgumentParser()
parser$add_argument("csv")
args <- parser$parse_args()
# ----------------------------------------------------------------------------------------------------
df <- readr::read_csv(args$csv, show_col_types = FALSE)
df <- df |>
dplyr::rename_with(tolower) |>
dplyr::rename_with(~ gsub(" ", "_", .x, fixed = TRUE)) |>
dplyr::mutate_all(~ str_replace(., "\\$", "")) |>
dplyr::mutate_all(~ str_replace_all(., ",", "")) |>
dplyr::mutate_all(~ str_replace_all(., " ", ".")) |>
dplyr::rename(
owe = total_amount_you_owe_or_may_have_paid,
copay = copayment_amount,
deductible = deductible_amount,
coins = coinsurance_amount
)
df <- df |>
dplyr::select(
first_name,
date_of_service,
provider_name,
provider_billed,
florida_blue_paid,
copay,
deductible,
coins,
owe
)
write.table(df, file = "", col.names = TRUE, row.names = FALSE, na = "", quote = FALSE, sep = "\t")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment