HealthCare Data
Health policy researchers and the media download the Hospital Compare database as an easy way to obtain a large set of data regarding outcome of care for a number of different conditions including heart attack, pneumonia, and heart failure. The data in the Downloadable Database come from the data that are displayed on Hospital Compare, but also include additional information about the hospital ownership that is not displayed on the website. You can find Hospital Compare data on data.medicare.gov. This website allows you to view the data files embedded on a webpage without downloading them, but as of July 2013, the downloadable data is not available here.
The collection period for the process of care quality measures is generally 12 months. As new measures are added, the collection period varies.
What was the goal of the project?
In this project, I was interested in querying quality of care for different conditions including heart attack, pneumonia, and heart failure across different states. I wrote a script which allows the user to find hospitals with a given rank of quality of care measures for any of the conditions listed in "outcome-of-care-measures.csv"
.
First, we read in outcome data and isolate for the columns that we are interested in. In this case, we care about the hospital name, state, and the three health conditions, “heart attack”, “heart failure”, and “pneumonia.”
tableAll <- read.csv("outcome-of-care-measures.csv", colClasses = "character")
tableAll <- tableAll[, c(2, 7, 11, 17, 23)]
names(tableAll) <- c("Hospital.Name", "State", "heart.attack", "heart.failure", "pneumonia")
Next, let’s pretend that we are interested in the outcome “heart failure”. To deal with the way that R names columns, we need to do a tiny bit of processing on the name and check that it is in our dataframe. If it isn’t, we throw an error.
outcome <- "heart failure"
outcome <- gsub(" ", ".", outcome)
## Check that state and outcome are valid
if(!(outcome %in% names(tableAll)))
{
stop("invalid outcome")
}
Next, we’d like to find hospitals of a given rank in all states. Let’s say we are looking for the “best” hospital in each state for quality of care for heart failure.
num <- 1
tableAll <- data.frame(tableAll[1:2], lapply(tableAll[3:5], as.numeric))
## Warning in lapply(tableAll[3:5], as.numeric): NAs introduced by coercion
## Warning in lapply(tableAll[3:5], as.numeric): NAs introduced by coercion
## Warning in lapply(tableAll[3:5], as.numeric): NAs introduced by coercion
good <- complete.cases(tableAll) #make sure the hospitals have data for the condition we are looking for
tableAll <- tableAll[good,]
s <- split(tableAll, tableAll$State)
s <- lapply(s, function(x) x[order(x[[outcome]], x$Hospital.Name), ])
if(num == "best")
{
num = 1
}
s <- lapply(s, function(x) if(num <= nrow(x)) x[num, ] else NA)
s <- do.call(rbind.data.frame, s)
s <- s[order(s$State), ][, c(1,2)]
s
## Hospital.Name State
## AK MAT-SU REGIONAL MEDICAL CENTER AK
## AL GEORGE H. LANIER MEMORIAL HOSPITAL AL
## AR VA CENTRAL AR. VETERANS HEALTHCARE SYSTEM LR AR
## AZ BANNER GOOD SAMARITAN MEDICAL CENTER AZ
## CA CENTINELA HOSPITAL MEDICAL CENTER CA
## CO PARKER ADVENTIST HOSPITAL CO
## CT YALE-NEW HAVEN HOSPITAL CT
## DC PROVIDENCE HOSPITAL DC
## DE BAYHEALTH - KENT GENERAL HOSPITAL DE
## FL FLORIDA HOSPITAL HEARTLAND MEDICAL CENTER FL
## GA HOUSTON MEDICAL CENTER GA
## GU GUAM MEMORIAL HOSPITAL AUTHORITY GU
## HI KUAKINI MEDICAL CENTER HI
## IA MERCY MEDICAL CENTER - CEDAR RAPIDS IA
## ID SAINT ALPHONSUS MEDICAL CENTER - NAMPA ID
## IL RUSH UNIVERSITY MEDICAL CENTER IL
## IN ST CATHERINE HOSPITAL INC IN
## KS HAYS MEDICAL CENTER KS
## KY OWENSBORO MEDICAL HEALTH SYSTEM KY
## LA WILLIS KNIGHTON MEDICAL CENTER LA
## MA ST ELIZABETH'S MEDICAL CENTER MA
## MD MEDSTAR GOOD SAMARITAN HOSPITAL MD
## ME MILES MEMORIAL HOSPITAL (LINCOLN COUNTY HEALTHCARE ME
## MI HARPER UNIVERSITY HOSPITAL MI
## MN ESSENTIA HEALTH ST JOSEPH'S MEDICAL CENTER MN
## MO NORTH KANSAS CITY HOSPITAL MO
## MS SOUTH CENTRAL REG MED CTR MS
## MT COMMUNITY MEDICAL CENTER INC MT
## NC FIRSTHEALTH MOORE REGIONAL HOSPITAL NC
## ND ESSENTIA HEALTH-FARGO ND
## NE FREMONT AREA MEDICAL CENTER NE
## NH VALLEY REGIONAL HOSPITAL NH
## NJ EAST ORANGE GENERAL HOSPITAL NJ
## NM MINERS' COLFAX MEDICAL CENTER NM
## NV MOUNTAINVIEW HOSPITAL NV
## NY KINGSBROOK JEWISH MEDICAL CENTER NY
## OH FAIRVIEW HOSPITAL OH
## OK DUNCAN REGIONAL HOSPITAL, INC OK
## OR PORTLAND VA MEDICAL CENTER OR
## PA PHILADELPHIA VA MEDICAL CENTER PA
## PR SAN LUKE'S MEMORIAL HOSPITAL INC PR
## RI WESTERLY HOSPITAL RI
## SC PALMETTO HEALTH BAPTIST SC
## SD AVERA HEART HOSPITAL OF SOUTH DAKOTA LLC SD
## TN CENTENNIAL MEDICAL CENTER TN
## TX FORT DUNCAN MEDICAL CENTER TX
## UT VA SALT LAKE CITY HEALTHCARE - GEORGE E. WAHLEN VA MEDICAL CENTER UT
## VA SENTARA POTOMAC HOSPITAL VA
## VI GOV JUAN F LUIS HOSPITAL & MEDICAL CTR VI
## VT SPRINGFIELD HOSPITAL VT
## WA HARBORVIEW MEDICAL CENTER WA
## WI AURORA ST LUKES MEDICAL CENTER WI
## WV FAIRMONT GENERAL HOSPITAL WV
## WY CHEYENNE REGIONAL MEDICAL CENTER WY
We can check for the best hospital for heart failure in California with
s["CA",]
## Hospital.Name State
## CA CENTINELA HOSPITAL MEDICAL CENTER CA