Skip to content

Commit

Permalink
quality_payment gains "eligibility" option (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewallenbruce committed Dec 3, 2023
1 parent df6da8c commit c0cab4d
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 128 deletions.
73 changes: 47 additions & 26 deletions R/globals.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,29 @@ utils::globalVariables(c(
"confirmed", # <laboratories>
"confirmed_date", # <laboratories>
"type_of_action", # <laboratories>
"y", # <mips_2021>
"org_pac_id", # <mips_2021>
"facility_name", # <mips_2021>
"aco_id_1", # <mips_2021>
"aco_nm_1", # <mips_2021>
"aco_id_2", # <mips_2021>
"aco_nm_2", # <mips_2021>
"measure_cd", # <mips_2021>
"measure_title", # <mips_2021>
"invs_msr", # <mips_2021>
"attestation_value", # <mips_2021>
"prf_rate", # <mips_2021>
"patient_count", # <mips_2021>
"star_value", # <mips_2021>
"five_star_benchmark", # <mips_2021>
"collection_type", # <mips_2021>
"ccxp_ind", # <mips_2021>
"ind_pac_id", # <mips_2021>
"provider_first_name", # <mips_2021>
"provider_last_name", # <mips_2021>
"apm_affl_1", # <mips_2021>
"apm_affl_2", # <mips_2021>
"apm_affl_3", # <mips_2021>
"number", # <download_msdrg>
"mdc", # <download_msdrg>
"mdc_description", # <download_msdrg>
Expand Down Expand Up @@ -190,29 +213,6 @@ utils::globalVariables(c(
"tot_benes", # <tidyup_provider.rx>
"bene_race_wht", # <tidyup_provider.rx>
"y", # <providers>
"y", # <mips_2021>
"org_pac_id", # <mips_2021>
"facility_name", # <mips_2021>
"aco_id_1", # <mips_2021>
"aco_nm_1", # <mips_2021>
"aco_id_2", # <mips_2021>
"aco_nm_2", # <mips_2021>
"measure_cd", # <mips_2021>
"measure_title", # <mips_2021>
"invs_msr", # <mips_2021>
"attestation_value", # <mips_2021>
"prf_rate", # <mips_2021>
"patient_count", # <mips_2021>
"star_value", # <mips_2021>
"five_star_benchmark", # <mips_2021>
"collection_type", # <mips_2021>
"ccxp_ind", # <mips_2021>
"ind_pac_id", # <mips_2021>
"provider_first_name", # <mips_2021>
"provider_last_name", # <mips_2021>
"apm_affl_1", # <mips_2021>
"apm_affl_2", # <mips_2021>
"apm_affl_3", # <mips_2021>
"y", # <quality_eligibility>
"organizations", # <quality_eligibility>
"organizations_individualScenario", # <quality_eligibility>
Expand All @@ -221,20 +221,41 @@ utils::globalVariables(c(
"organizations_virtualGroups", # <quality_eligibility>
"npi_type", # <quality_eligibility>
"org_state", # <quality_eligibility>
"first_approved_date", # <quality_eligibility>
"timelength_days", # <quality_eligibility>
"org_name", # <quality_eligibility>
"year", # <cols_qelig>
"npi", # <cols_qelig>
"org_name", # <cols_qelig>
"value", # <cols_qelig>
"name", # <cols_qelig>
"ind_status", # <cols_qelig>
"grp_status", # <cols_qelig>
"distro", # <quality_payment>
"y", # <quality_payment>
"set", # <quality_payment>
"participation_type", # <quality_payment>
"org_state", # <quality_payment>
"val", # <quality_payment>
"set", # <quality_payment>
"score", # <quality_payment>
"measure", # <quality_payment>
"status", # <quality_payment>
"category", # <quality_payment>
"status", # <quality_payment>
"qualified", # <quality_payment>
"org_size", # <quality_payment>
"org_id", # <quality_payment>
"npi_type", # <quality_payment>
"first", # <quality_payment>
"middle", # <quality_payment>
"last", # <quality_payment>
"first_approved_date", # <quality_payment>
"years_in_medicare", # <quality_payment>
"specialty_type", # <quality_payment>
"specialty_cat", # <quality_payment>
"ind_specialty_code", # <quality_payment>
"org_name", # <quality_payment>
"org_address", # <quality_payment>
"org_city", # <quality_payment>
"org_zip", # <quality_payment>
"y", # <reassignments>
"individual_state_code", # <reassignments>
"group_state_code", # <reassignments>
Expand Down
File renamed without changes.
76 changes: 44 additions & 32 deletions R/quality_eligibility.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ quality_eligibility <- function(year,
results <- tidyup(results,
dtype = 'ymd',
int = c('year',
# 'years_in_medicare',
'ind_hosp_vbp_score',
'ind_hosp_vbp_score'
# 'apms_lvt_patients',
# 'apms_lvt_year'
'pecos_year'),
),
# dbl = 'apms_lvt_payments',
zip = 'org_zip',
lgl = c('newly_enrolled',
Expand Down Expand Up @@ -291,7 +290,17 @@ quality_eligibility <- function(year,
'grp_lvt_switch',
'grp_eligible')) |>
dplyr::mutate(npi_type = fct_entype(npi_type),
org_state = fct_stabb(org_state))
org_state = fct_stabb(org_state)) |>
make_interval(start = first_approved_date,
end = lubridate::ymd(paste0(year, '-12-31'))) |>
dplyr::mutate(years_in_medicare = round(timelength_days / 365),
.after = first_approved_date) |>
dplyr::mutate(interval = NULL,
period = NULL,
timelength_days = NULL) |>
dplyr::group_by(year) |>
dplyr::mutate(org_id = dplyr::row_number(), .before = org_name) |>
dplyr::ungroup()

if (pivot) {
by <- dplyr::join_by(year, npi, org_name)
Expand Down Expand Up @@ -367,9 +376,9 @@ cols_qelig <- function(df, type = c('tidyup', 'top', 'apms', 'ind', 'grp')) {
'last' = 'lastName',
'first_approved_date' = 'firstApprovedDate',
# 'years_in_medicare' = 'yearsInMedicare',
'pecos_year' = 'pecosEnrollmentDate',
# 'pecos_year' = 'pecosEnrollmentDate',
'newly_enrolled' = 'newlyEnrolled',
'specialty_desc' = 'specialty.specialtyDescription',
'specialty' = 'specialty.specialtyDescription',
'specialty_type' = 'specialty.typeDescription',
'specialty_cat' = 'specialty.categoryReference',
'is_maqi' = 'isMaqi',
Expand Down Expand Up @@ -484,30 +493,31 @@ cols_qelig <- function(df, type = c('tidyup', 'top', 'apms', 'ind', 'grp')) {
if (type == 'top') {

top_cols <- c('year',
'npi',
'npi_type',
'first',
'middle',
'last',
'first_approved_date',
'pecos_year',
'newly_enrolled',
'specialty_desc',
'specialty_type',
'specialty_cat',
'is_maqi',
'org_name',
'org_hosp_vbp_name',
'org_facility_based',
'org_address',
'org_city',
'org_state',
'org_zip',
'qp_status',
'ams_mips_eligible',
'qp_score_type',
'error_message',
'error_type')
'npi',
'npi_type',
'first',
'middle',
'last',
'first_approved_date',
'years_in_medicare',
'newly_enrolled',
'specialty',
'specialty_type',
'specialty_cat',
'is_maqi',
'org_id',
'org_name',
'org_hosp_vbp_name',
'org_facility_based',
'org_address',
'org_city',
'org_state',
'org_zip',
'qp_status',
'ams_mips_eligible',
'qp_score_type',
'error_message',
'error_type')

results <- df |> dplyr::select(dplyr::any_of(top_cols))

Expand Down Expand Up @@ -582,7 +592,8 @@ cols_qelig <- function(df, type = c('tidyup', 'top', 'apms', 'ind', 'grp')) {
dplyr::filter(!is.na(value)) |>
dplyr::filter(value == TRUE) |>
dplyr::mutate(value = NULL) |>
tidyr::nest(ind_status = name) |>
dplyr::rename(ind_status = name) |>
tidyr::nest(ind_status = ind_status) |>
janitor::remove_empty(which = c("rows", "cols"))

}
Expand Down Expand Up @@ -621,7 +632,8 @@ cols_qelig <- function(df, type = c('tidyup', 'top', 'apms', 'ind', 'grp')) {
dplyr::filter(!is.na(value)) |>
dplyr::filter(value == TRUE) |>
dplyr::mutate(value = NULL) |>
tidyr::nest(grp_status = name) |>
dplyr::rename(grp_status = name) |>
tidyr::nest(grp_status = grp_status) |>
janitor::remove_empty(which = c("rows", "cols"))

}
Expand Down
Loading

0 comments on commit c0cab4d

Please sign in to comment.