Main website for OHP Data and Reports is here. The website for fee schedules is here.
File name format is in the form
http://www.oregon.gov/oha/healthplan/DataReportsDocs/[monthname]%20YYYY%20Fee%20Schedule%20-%20CSV.csv
monthname
is generally Februrary, May, August, November; but is not consistent.
Manual checking at the OHP fee schedules website is required.
report_date
is not exact
In [1]:
library(data.table)
readFS <- function (url) {
require(data.table, quietly=TRUE)
require(lubridate, quietly=TRUE)
x <- strsplit(url, "(%20)|/|-")[[1]]
i <- grep("20[01][0-9]", x)
year <- x[i]
month <- x[i - 1]
D <- fread(url, colClasses="character", na.strings=c(""))
old <- names(D)
new <- tolower(gsub("(\\s+)|(\\n)", "_", old))
new <- gsub("^proc_code$", "procedure_code", new)
new <- gsub("mod1|mod_1", "modifier_1", new)
new <- gsub("mod2|mod_2", "modifier_2", new)
setnames(D, old, new)
D <- D[procedure_code != ""]
D <- D[grep("^[0-9]+$", procedure_code), procedure_code := sprintf("%05d", as.integer(procedure_code))]
D <- D[, price := as.numeric(gsub("(\\$)|(,)", "", price))]
D <- D[, effective_date := fast_strptime(effective_date, "%Y%m%d")]
D <- D[, report_date := as.Date(paste(month, "01", year), format="%B %d %Y")]
if (!("modifier_2" %in% names(D))) {D <- D[, modifier_2 := NA_character_]}
if (!("rate_type" %in% names(D))) {D <- D[, rate_type := NA_character_]}
D[,
.(procedure_code,
description,
modifier_1,
modifier_2,
rate_type,
price,
effective_date,
report_date)]
}
In [2]:
urlStem <- "http://www.oregon.gov/oha/healthplan/DataReportsDocs/"
fs <- rbindlist(list(
readFS(paste0(urlStem, "March%202010%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "May%202010%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "August%202010%20Fee%20Schedule%20-%20CSV.csv")),
# readFS(paste0(urlStem, "December%202010%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "February%202011%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "May%202011%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "August%202011%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "November%202011%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "February%202012%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "May%202012%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "August%202012%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "November%202012%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "March%202013%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "August%202013%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "Nov%202013%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "February-March%202014%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "May-June%202014%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "August%202014%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "November%202014%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "February-March%202015%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "May%202015%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "August-September%202015%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "December%202015%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "February%202016%20Fee%20Schedule%20-%20CSV.csv")),
readFS(paste0(urlStem, "April%202016%20Fee%20Schedule%20-%20CSV.csv"))
))
str(fs)
In [3]:
fs[, .N, report_date][order(report_date)]
Out[3]:
In [4]:
head(fs)
tail(fs)
Out[4]:
Out[4]:
The December 2010 fee schedule throws an error.
This can be fixed by using the dev version (1.9.7) of data.table, which adds a fill=
argument to fread
.
In [5]:
readFS(paste0(urlStem, "December%202010%20Fee%20Schedule%20-%20CSV.csv"))
readLines(paste0(urlStem, "December%202010%20Fee%20Schedule%20-%20CSV.csv"))[15169]
Out[5]: