-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
103 additions
and
12 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ config(materialized='external', location=var('output_path') + '/' + this.name + '.parquet') }} | ||
|
||
SELECT | ||
YEAR AS year, | ||
"AVG" AS consumer_price_index | ||
FROM {{ ref('download_consumer_price_index') }} |
13 changes: 13 additions & 0 deletions
13
data_processing/models/bls.gov/download_consumer_price_index.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pandas as pd | ||
import os | ||
import requests | ||
|
||
def model(dbt, session): | ||
# URL to the Excel file containing the Consumer Price Index data | ||
output_path = dbt.config.get('output_path') | ||
base_path = os.path.expanduser(output_path) | ||
excel_path = os.path.join(base_path, "r-cpi-u-rs-allitems.xlsx") | ||
# cpi_url = "https://www.bls.gov/cpi/research-series/r-cpi-u-rs-allitems.xlsx" | ||
# download and save to output path as r-cpi-u-rs-allitems.xlsx | ||
consumer_price_index_df = pd.read_excel(excel_path, skiprows=5, usecols=['YEAR', 'AVG']) | ||
return consumer_price_index_df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: download_consumer_price_index | ||
config: | ||
data_path: "{{ var('data_path') }}" | ||
output_path: "{{ var('output_path') }}" | ||
- name: ahrq.gov | ||
config: | ||
data_path: "{{ var('data_path') }}" | ||
output_path: "{{ var('output_path') }}" |
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
data_processing/models/figures/insurance_plan_payment_histogram_inflation_adjusted.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{ config(materialized='external', location=var('output_path') + '/' + this.name + '.parquet') }} | ||
|
||
WITH cpi_adjustment AS ( | ||
SELECT | ||
year, | ||
consumer_price_index | ||
FROM {{ ref('consumer_price_index') }} | ||
), | ||
latest_cpi AS ( | ||
SELECT | ||
MAX(consumer_price_index) AS cpi_2022 | ||
FROM cpi_adjustment | ||
WHERE year = 2022 | ||
), | ||
inflation_adjustment_factors AS ( | ||
SELECT | ||
2016 AS year, | ||
(lc.cpi_2022 / ca.consumer_price_index) AS adjustment_factor_to_2022 | ||
FROM cpi_adjustment ca | ||
CROSS JOIN latest_cpi lc | ||
WHERE ca.year = 2016 | ||
), | ||
commercial_data AS ( | ||
SELECT | ||
PLAN_PMT_AMT * iaf.adjustment_factor_to_2022 AS Payment, | ||
COUNT(*) AS count, | ||
'Commercial' AS Insurance | ||
FROM read_parquet('/Users/me/data/syh_dr/syhdr_commercial_inpatient_2016.parquet') cd | ||
JOIN inflation_adjustment_factors iaf ON 1 = 1 | ||
GROUP BY PLAN_PMT_AMT, iaf.adjustment_factor_to_2022 | ||
), | ||
medicaid_data AS ( | ||
SELECT | ||
PLAN_PMT_AMT * iaf.adjustment_factor_to_2022 AS Payment, | ||
COUNT(*) AS count, | ||
'Medicaid' AS Insurance | ||
FROM read_parquet('/Users/me/data/syh_dr/syhdr_medicaid_inpatient_2016.parquet') md | ||
JOIN inflation_adjustment_factors iaf ON 1 = 1 | ||
GROUP BY PLAN_PMT_AMT, iaf.adjustment_factor_to_2022 | ||
), | ||
medicare_data AS ( | ||
SELECT | ||
PLAN_PMT_AMT * iaf.adjustment_factor_to_2022 AS Payment, | ||
COUNT(*) AS count, | ||
'Medicare' AS Insurance | ||
FROM read_parquet('/Users/me/data/syh_dr/syhdr_medicare_inpatient_2016.parquet') mcd | ||
JOIN inflation_adjustment_factors iaf ON 1 = 1 | ||
GROUP BY PLAN_PMT_AMT, iaf.adjustment_factor_to_2022 | ||
), | ||
combined_data AS ( | ||
SELECT * FROM commercial_data | ||
UNION ALL | ||
SELECT * FROM medicaid_data | ||
UNION ALL | ||
SELECT * FROM medicare_data | ||
) | ||
SELECT | ||
Payment, | ||
count, | ||
Insurance | ||
FROM combined_data | ||
ORDER BY Insurance, Payment |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,6 @@ ipykernel | |
jupysql | ||
pip-tools | ||
duckdb-engine | ||
pdfplumber | ||
pdfplumber | ||
openpyxl | ||
pip-tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters