knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(claims)
library(odbc)

Introduction

claims_elig is the backbone of the claims package. It provides a way of obtaining a member cohort with specified parameters, including coverage time period, coverage characteristics, and member demographics. It generates a SQL query based on the provided arguments, runs that query, and returns the result as a dataframe.

Arguments

There is an overwhelming number of arguments, but most of them can be ignored except for the purposes of subsetting the data.

The arguments to always account for include:

1) conn \<- The database connection to use to access the data (see create_db_connection and dbConnect usage in PHSKC repos for how to set this up) 2) source \<- The claims data source to pull data from (All Payer Claims Database, Medicaid, Medicaid/Medicare, Medicare, or Medicare/Medicaid/Public Housing Authority) 3) server \<- Whether to access the data from the PHClaims server or HHSAW (note that this has to align with your conn)

Other common arguments include:

1) from_date and to_date \<- These default to 18 and 6 months before the current date, respectively. Otherwise, input YYYY-MM-DD format dates for each to determine the time period of the cohort.

2) age_min and age_max \<- Minimum and maximum ages for the cohort (calculated as age on the last day of the date range).

3) female, male, gender_me, gender_recent \<- These arguments all pertain to gender of the cohort. The female and male arguments specify whether to include the respective genders alone or in combination with other genders. gender_me specifies a single or list of genders to look for out of the most commonly reported gender for each person in the cohort (e.g. c("female", "multiple")). Finally, gender_recent can only be used for APCD and Medicaid data, and subsets based on the most recently reported gender for each person in the cohort.

4) show_query \<- This will print the SQL query that is generated by the specified arguments, which is often useful for debugging or documentation.

Most of the remaining arguments are not applicable to all data sources, so it is important to read through the options that are available to see which ones are relevant (e.g. race, language, geographies).

Example uses

Let's say that we wanted to query Medicaid data from the PHClaims server. The most basic call would be to set up our database connection and then run a plain call with only the basic arguments:

# Set up DB connection to PHClaims before running the line below
mcaid_data <- claims_elig(conn = db_claims, source = "mcaid", server="phclaims", show_query = T)

The above call returns a cohort from 18 to 6 months ago, but this is very big and can take a while to execute. Now we can add some of the basic arguments to help subset to a more reasonable query size.

mcaid_data <- claims_elig(conn = db_claims, source = "mcaid", server="phclaims", 
                          from_date = "2014-01-01", to_date = "2014-03-01",
                          age_min = 18, age_max = 24, female = 1,
                          show_query = T)

This will give us back a female cohort over a 2-month period from ages 18-24 years. Finally, let's try a little exercise to practice figuring out other arguments to use. Before looking at the code below, try and write down your best guess at obtaining the following cohort: You are working on a project that involves looking at how Medicaid claims progressed from the start of the COVID-19 pandemic (stay-at-home order) to the end of 2020 in Native Hawaiian and Pacific Islander women.

mcaid_data <- claims_elig(conn = db_claims, source = "mcaid", server="phclaims", 
                          from_date = "2020-03-23", to_date = "2020-12-31",
                          age_min = 18, female = 1, race_nhpi = 1,
                          show_query = T)

If your call looked something like the one above, great! You're ready to use the base function of the package and move on to others.



PHSKC-APDE/claims_data documentation built on May 2, 2024, 8:16 p.m.