National Plan and Provider Enumeration System (NPPES)

Build Status Build status

The National Plan and Provider Enumeration System (NPPES) contains information about every medical provider, insurance plan, and clearinghouse actively operating in the United States healthcare industry.

  • A single large table with one row per enumerated health care provider.

  • A census of individuals and organizations who bill for medical services in the United States.

  • Updated monthly with new providers.

  • Maintained by the United States Centers for Medicare & Medicaid Services (CMS)

Simplified Download and Importation

The R lodown package easily downloads and imports all available NPPES microdata by simply specifying "nppes" with an output_dir = parameter in the lodown() function. Depending on your internet connection and computer processing speed, you might prefer to run this step overnight.

library(lodown)
lodown( "nppes" , output_dir = file.path( path.expand( "~" ) , "NPPES" ) )

Analysis Examples with base R  

Load a data frame:

column_names <-
    names( 
        read.csv( 
            file.path( path.expand( "~" ) , "NPPES" , "nppes.csv" ) , 
            nrow = 1 )[ FALSE , , ] 
    )

column_names <- gsub( "\\." , "_" , tolower( column_names ) )

column_types <-
    ifelse( 
        grepl( "code" , column_names ) & 
        !grepl( "country|state|gender|taxonomy|postal" , column_names ) , 
        'n' , 'c' 
    )

columns_to_import <-
    c( "entity_type_code" , "provider_gender_code" , "provider_enumeration_date" ,
    "is_sole_proprietor" , "provider_business_practice_location_address_state_name" )

stopifnot( all( columns_to_import %in% column_names ) )

# readr::read_csv() columns must match their order in the csv file
columns_to_import <-
    columns_to_import[ order( match( columns_to_import , column_names ) ) ]

nppes_df <- 
    data.frame( 
        readr::read_csv( 
            file.path( path.expand( "~" ) , "NPPES" , 
                "nppes.csv" ) , 
            col_names = columns_to_import , 
            col_types = 
                paste0( 
                    ifelse( column_names %in% columns_to_import , column_types , '_' ) , 
                    collapse = "" 
                ) ,
            skip = 1
        ) 
    )

Variable Recoding

Add new columns to the data set:

nppes_df <- 
    transform( 
        nppes_df , 
        
        individual = as.numeric( entity_type_code ) ,
        
        provider_enumeration_year = as.numeric( substr( provider_enumeration_date , 7 , 10 ) )
        
    )

Unweighted Counts

Count the unweighted number of records in the table, overall and by groups:

nrow( nppes_df )

table( nppes_df[ , "provider_gender_code" ] , useNA = "always" )

Descriptive Statistics

Calculate the mean (average) of a linear variable, overall and by groups:

mean( nppes_df[ , "provider_enumeration_year" ] , na.rm = TRUE )

tapply(
    nppes_df[ , "provider_enumeration_year" ] ,
    nppes_df[ , "provider_gender_code" ] ,
    mean ,
    na.rm = TRUE 
)

Calculate the distribution of a categorical variable, overall and by groups:

prop.table( table( nppes_df[ , "is_sole_proprietor" ] ) )

prop.table(
    table( nppes_df[ , c( "is_sole_proprietor" , "provider_gender_code" ) ] ) ,
    margin = 2
)

Calculate the sum of a linear variable, overall and by groups:

sum( nppes_df[ , "provider_enumeration_year" ] , na.rm = TRUE )

tapply(
    nppes_df[ , "provider_enumeration_year" ] ,
    nppes_df[ , "provider_gender_code" ] ,
    sum ,
    na.rm = TRUE 
)

Calculate the median (50th percentile) of a linear variable, overall and by groups:

quantile( nppes_df[ , "provider_enumeration_year" ] , 0.5 , na.rm = TRUE )

tapply(
    nppes_df[ , "provider_enumeration_year" ] ,
    nppes_df[ , "provider_gender_code" ] ,
    quantile ,
    0.5 ,
    na.rm = TRUE 
)

Subsetting

Limit your data.frame to California:

sub_nppes_df <- subset( nppes_df , provider_business_practice_location_address_state_name = 'CA' )

Calculate the mean (average) of this subset:

mean( sub_nppes_df[ , "provider_enumeration_year" ] , na.rm = TRUE )

Measures of Uncertainty

Calculate the variance, overall and by groups:

var( nppes_df[ , "provider_enumeration_year" ] , na.rm = TRUE )

tapply(
    nppes_df[ , "provider_enumeration_year" ] ,
    nppes_df[ , "provider_gender_code" ] ,
    var ,
    na.rm = TRUE 
)

Regression Models and Tests of Association

Perform a t-test:

t.test( provider_enumeration_year ~ individual , nppes_df )

Perform a chi-squared test of association:

this_table <- table( nppes_df[ , c( "individual" , "is_sole_proprietor" ) ] )

chisq.test( this_table )

Perform a generalized linear model:

glm_result <- 
    glm( 
        provider_enumeration_year ~ individual + is_sole_proprietor , 
        data = nppes_df
    )

summary( glm_result )

Analysis Examples with dplyr  

The R dplyr library offers an alternative grammar of data manipulation to base R and SQL syntax. dplyr offers many verbs, such as summarize, group_by, and mutate, the convenience of pipe-able functions, and the tidyverse style of non-standard evaluation. This vignette details the available features. As a starting point for NPPES users, this code replicates previously-presented examples:

library(dplyr)
nppes_tbl <- tbl_df( nppes_df )

Calculate the mean (average) of a linear variable, overall and by groups:

nppes_tbl %>%
    summarize( mean = mean( provider_enumeration_year , na.rm = TRUE ) )

nppes_tbl %>%
    group_by( provider_gender_code ) %>%
    summarize( mean = mean( provider_enumeration_year , na.rm = TRUE ) )