Medicare Hospital Spending Per Patient - Hospital The “Medicare hospital spending per patient (Medicare Spending per Beneficiary)” measure shows whether Medicare spends more, less or about the same per Medicare patient treated in a specific hospital, compared to how much Medicare spends per patient nationally. This measure includes any Medicare Part A and Part B payments made for services provided to a patient during the 3 days prior to the hospital stay, during the stay, and during the 30 days after discharge from the hospital.

See https://data.medicare.gov/data/hospital-compare# and https://data.medicare.gov/Hospital-Compare/Medicare-Hospital-Spending-Per-Patient-Hospital/rrqw-56er

library(tidyr)
library(dplyr)
library(stringr)
library(utils)

filename <- "C:/Users/vikas/cuny/data607/projects/Project_2/Hospital_Compare_Datasets/Medicare_Hospital_Spending_Per_Patient_-_Hospital.csv"

ms_full <- read.csv(filename, stringsAsFactors = FALSE)
dim(ms_full)
## [1] 4812   15
names(ms_full)
##  [1] "Provider.ID"        "Hospital.Name"      "Address"           
##  [4] "City"               "State"              "ZIP.Code"          
##  [7] "County.Name"        "Phone.Number"       "Measure.Name"      
## [10] "Measure.ID"         "Score"              "Footnote"          
## [13] "Measure.Start.Date" "Measure.End.Date"   "Location"

It appears that the Measure.ID and Measure.Name may be constant throughout this data set – if so, we can remove them entirely.

length(unique(ms_full$Measure.ID))
## [1] 1
ms_full[1,]$Measure.ID
## [1] "MSPB_1"
length(unique(ms_full$Measure.Name))
## [1] 1
ms_full[1,]$Measure.Name
## [1] "Medicare hospital spending per patient (Medicare Spending per Beneficiary)"

Similarly, Measure.Start.Date and Measure.End.Date may be removed without loss of information.

unique(ms_full$Measure.End.Date)
## [1] "12/31/2015"
unique(ms_full$Measure.Start.Date)
## [1] "01/01/2015"
ms <- ms_full %>% select(-Measure.ID, -Measure.Name, -Measure.End.Date, -Measure.Start.Date)
dim(ms)
## [1] 4812   11
names(ms)
##  [1] "Provider.ID"   "Hospital.Name" "Address"       "City"         
##  [5] "State"         "ZIP.Code"      "County.Name"   "Phone.Number" 
##  [9] "Score"         "Footnote"      "Location"

We can now attempt to find the top few providers with the lowest Medicare spending per patient.

ms$Score <- as.numeric(ms$Score)
## Warning: NAs introduced by coercion
# Now can find the top 10 Providers with the least Score (Medicare Spending per patient)

s1 <- order(ms$Score)

Print the Provider ID and Hospital Names of the top 10.

for (i in 1:10) {
    index <- s1[i]
    print("======")
    print(ms[index,]$Provider.ID)
    print(ms[index,]$Hospital.Name)
    print(ms[index,]$Score)
}
## [1] "======"
## [1] 170166
## [1] "MORTON COUNTY HOSPITAL"
## [1] 0.61
## [1] "======"
## [1] 320070
## [1] "DHHS USPHS INDIAN HEALTH SERVICES"
## [1] 0.64
## [1] "======"
## [1] 230279
## [1] "BRIGHTON HOSPITAL"
## [1] 0.64
## [1] "======"
## [1] 320062
## [1] "CROWNPOINT HEALTHCARE FACILITY"
## [1] 0.65
## [1] "======"
## [1] 30078
## [1] "PHOENIX INDIAN MEDICAL CENTER"
## [1] 0.66
## [1] "======"
## [1] 670078
## [1] "BAPTIST EMERGENCY HOSPITAL"
## [1] 0.66
## [1] "======"
## [1] 30074
## [1] "SELLS HOSPITAL"
## [1] 0.67
## [1] "======"
## [1] 320067
## [1] "GUADALUPE COUNTY HOSPITAL"
## [1] 0.67
## [1] "======"
## [1] 350063
## [1] "P H S INDIAN HOSP AT BELCOURT-QUENTIN N BURDICK"
## [1] 0.69
## [1] "======"
## [1] 370170
## [1] "USPHS LAWTON INDIAN HOSPITAL"
## [1] 0.69