diff --git a/.github/workflows/biweekly_dbt_v1.3.0_bigquery_build_full_refresh.yml b/.github/workflows/biweekly_dbt_v1.3.0_bigquery_build_full_refresh.yml deleted file mode 100644 index de755086..00000000 --- a/.github/workflows/biweekly_dbt_v1.3.0_bigquery_build_full_refresh.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: biweekly_dbt_v1.3.0_bigquery_build_full_refresh - -on: - workflow_dispatch: - schedule: - # This job will run at midnight on the 1st and 15th of the month - - cron: '0 0 1,15 * *' - - -env: - DBT_BIGQUERY_TOKEN: ${{ secrets.TUVA_BIGQUERY_TOKEN }} - DBT_BIGQUERY_CI_PROJECT: ${{ secrets.DBT_BIGQUERY_CI_PROJECT }} - - -jobs: - action: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: dbt-deps - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/bigquery" - - - - name: dbt-debug - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/bigquery" - - - name: dbt-build - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/bigquery --vars {"tuva_database":"dev-ci-testing","input_database":"dev-ci-testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' - - - - name: Get the result - if: ${{ always() }} - run: echo "${{ steps.dbt-build.outputs.result }}" - shell: bash diff --git a/.github/workflows/biweekly_dbt_v1.3.0_redshift_build_full_refresh.yml b/.github/workflows/biweekly_dbt_v1.3.0_redshift_build_full_refresh.yml deleted file mode 100644 index 624ce85b..00000000 --- a/.github/workflows/biweekly_dbt_v1.3.0_redshift_build_full_refresh.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: biweekly_dbt_v1.3.0_redshift_build_full_refresh - -on: - workflow_dispatch: - schedule: - # This job will run at midnight on the 1st and 15th of the month - - cron: '0 0 1,15 * *' - -env: - DBT_REDSHIFT_CI_HOST: ${{ secrets.DBT_REDSHIFT_CI_HOST }} - DBT_REDSHIFT_CI_USER: ${{ secrets.DBT_REDSHIFT_CI_USER }} - DBT_REDSHIFT_CI_PASSWORD: ${{ secrets.DBT_REDSHIFT_CI_PASSWORD }} - DBT_REDSHIFT_CI_PORT: ${{ secrets.DBT_REDSHIFT_CI_PORT }} - - -jobs: - action: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: dbt-deps - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/redshift" - - - name: dbt-debug - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/redshift" - - - name: dbt-build - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/redshift --vars {"tuva_database":"dev_ci_testing","input_database":"dev_ci_testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' - - - name: Get the result - if: ${{ always() }} - run: echo "${{ steps.dbt-build.outputs.result }}" - shell: bash diff --git a/.github/workflows/biweekly_dbt_v1.3.0_snowflake_build_full_refresh.yml b/.github/workflows/biweekly_dbt_v1.3.0_snowflake_build_full_refresh.yml deleted file mode 100644 index 2079362c..00000000 --- a/.github/workflows/biweekly_dbt_v1.3.0_snowflake_build_full_refresh.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: biweekly_dbt_v1.3.0_snowflake_build_full_refresh - -on: - workflow_dispatch: - schedule: - # This job will run at midnight on the 1st and 15th of the month - - cron: '0 0 1,15 * *' - -env: - DBT_SNOWFLAKE_CI_ACCOUNT: ${{ secrets.DBT_SNOWFLAKE_CI_ACCOUNT }} - DBT_SNOWFLAKE_CI_DATABASE: ${{ secrets.DBT_SNOWFLAKE_CI_DATABASE }} - DBT_SNOWFLAKE_CI_PASSWORD: ${{ secrets.DBT_SNOWFLAKE_CI_PASSWORD }} - DBT_SNOWFLAKE_CI_ROLE: ${{ secrets.DBT_SNOWFLAKE_CI_ROLE }} - DBT_SNOWFLAKE_CI_SCHEMA: ${{ secrets.DBT_SNOWFLAKE_CI_SCHEMA }} - DBT_SNOWFLAKE_CI_USER: ${{ secrets.DBT_SNOWFLAKE_CI_USER }} - DBT_SNOWFLAKE_CI_WAREHOUSE: ${{ secrets.DBT_SNOWFLAKE_CI_WAREHOUSE }} - -jobs: - action: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: dbt-deps - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/snowflake" - - - name: dbt-debug - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/snowflake" - - - name: dbt-build - uses: mwhitaker/dbt-action@v1.3.0 - with: - dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/snowflake --vars {"tuva_database":"dev_ci_testing","input_database":"dev_ci_testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' - - - name: Get the result - if: ${{ always() }} - run: echo "${{ steps.dbt-build.outputs.result }}" - shell: bash diff --git a/.github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml b/.github/workflows/dbt_v1.6.3_bigquery_build_full_refresh.yml similarity index 84% rename from .github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml rename to .github/workflows/dbt_v1.6.3_bigquery_build_full_refresh.yml index 9ae04ec0..6dae8755 100644 --- a/.github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml +++ b/.github/workflows/dbt_v1.6.3_bigquery_build_full_refresh.yml @@ -1,4 +1,4 @@ -name: dbt_v1.4.6_bigquery_build_full_refresh +name: dbt_v1.6.3_bigquery_build_full_refresh on: workflow_dispatch: @@ -18,17 +18,17 @@ jobs: - uses: actions/checkout@v2 - name: dbt-deps - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/bigquery" - name: dbt-debug - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/bigquery" - name: dbt-build - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/bigquery --vars {"tuva_database":"dev-ci-testing","input_database":"dev-ci-testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' diff --git a/.github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml b/.github/workflows/dbt_v1.6.3_redshift_build_full_refresh.yml similarity index 85% rename from .github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml rename to .github/workflows/dbt_v1.6.3_redshift_build_full_refresh.yml index 3d2f9727..26055db4 100644 --- a/.github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml +++ b/.github/workflows/dbt_v1.6.3_redshift_build_full_refresh.yml @@ -1,4 +1,4 @@ -name: dbt_v1.4.6_redshift_build_full_refresh +name: dbt_v1.6.3_redshift_build_full_refresh on: workflow_dispatch: @@ -19,17 +19,17 @@ jobs: - uses: actions/checkout@v2 - name: dbt-deps - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/redshift" - name: dbt-debug - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/redshift" - name: dbt-build - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/redshift --vars {"tuva_database":"dev_ci_testing","input_database":"dev_ci_testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' diff --git a/.github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml b/.github/workflows/dbt_v1.6.3_snowflake_build_full_refresh.yml similarity index 88% rename from .github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml rename to .github/workflows/dbt_v1.6.3_snowflake_build_full_refresh.yml index 453c08f7..03553dcd 100644 --- a/.github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml +++ b/.github/workflows/dbt_v1.6.3_snowflake_build_full_refresh.yml @@ -1,4 +1,4 @@ -name: dbt_v1.4.6_snowflake_build_full_refresh +name: dbt_v1.6.3_snowflake_build_full_refresh on: workflow_dispatch: @@ -23,17 +23,17 @@ jobs: - uses: actions/checkout@v2 - name: dbt-deps - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/snowflake" - name: dbt-debug - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/snowflake" - name: dbt-build - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/snowflake --vars {"tuva_database":"dev_ci_testing","input_database":"dev_ci_testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' diff --git a/.github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml b/.github/workflows/outside_contributor_dbt_v1.6.3_all_build_full_refresh.yml similarity index 90% rename from .github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml rename to .github/workflows/outside_contributor_dbt_v1.6.3_all_build_full_refresh.yml index 71f4566d..407f33ae 100644 --- a/.github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml +++ b/.github/workflows/outside_contributor_dbt_v1.6.3_all_build_full_refresh.yml @@ -1,4 +1,4 @@ -name: outside_contributor_dbt_v1.4.6_all_build_full_refresh +name: outside_contributor_dbt_v1.6.3_all_build_full_refresh on: workflow_dispatch: @@ -35,17 +35,17 @@ jobs: ref: refs/pull/${{ github.event.inputs.prNumber }}/merge - name: dbt-deps - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/snowflake" - name: dbt-debug - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/snowflake" - name: dbt-build - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/snowflake --vars {"tuva_database":"dev_ci_testing","input_database":"dev_ci_testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' @@ -64,17 +64,17 @@ jobs: ref: refs/pull/${{ github.event.inputs.prNumber }}/merge - name: dbt-deps - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/redshift" - name: dbt-debug - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/redshift" - name: dbt-build - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/redshift --vars {"tuva_database":"dev_ci_testing","input_database":"dev_ci_testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' @@ -94,17 +94,17 @@ jobs: ref: refs/pull/${{ github.event.inputs.prNumber }}/merge - name: dbt-deps - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt deps --profiles-dir ./integration_tests/profiles/bigquery" - name: dbt-debug - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: "dbt debug --profiles-dir ./integration_tests/profiles/bigquery" - name: dbt-build - uses: mwhitaker/dbt-action@v1.4.6 + uses: mwhitaker/dbt-action@v1.6.3 with: dbt_command: 'dbt build --full-refresh --profiles-dir ./integration_tests/profiles/bigquery --vars {"tuva_database":"dev-ci-testing","input_database":"dev-ci-testing","input_schema":"cclf","tuva_schema_prefix":"cclf"}' diff --git a/.gitignore b/.gitignore index 49f147cb..9c8694ea 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,10 @@ target/ dbt_packages/ logs/ +package-lock.yml +.idea/ +.DS_Store +.mise.toml +.venv/ +package-lock.yml +.vscode diff --git a/models/_models.yml b/models/_models.yml index 31d8e60b..aaf6e7de 100644 --- a/models/_models.yml +++ b/models/_models.yml @@ -8,21 +8,21 @@ models: enrollment spans. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_input_layer{% else %}input_layer{%- endif -%} materialized: table - name: medical_claim description: Claim line level medical data. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_input_layer{% else %}input_layer{%- endif -%} materialized: table - name: pharmacy_claim description: Claim line level pharmacy data. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_input_layer{% else %}input_layer{%- endif -%} materialized: table ### intermediate @@ -32,28 +32,28 @@ models: per row). config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_int_input_layer{% else %}_int_input_layer{%- endif -%} - name: dme_claims description: > Mapping of durable medical equipment claims to Tuva claims data model. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_int_input_layer{% else %}_int_input_layer{%- endif -%} - name: institutional_claims description: > Mapping of institution claims to Tuva claims data model. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_int_input_layer{% else %}_int_input_layer{%- endif -%} - name: physician_claims description: > Mapping of professional claims to Tuva claims data model. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_int_input_layer{% else %}_int_input_layer{%- endif -%} - name: procedure_pivot description: > @@ -61,17 +61,47 @@ models: procedure per row). config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_int_input_layer{% else %}_int_input_layer{%- endif -%} ### staging - - name: base_parta_diagnosis_code - description: Base model used as ref for pivot transformation. + - name: stg_beneficiary_demographics + description: Staging model for beneficiary demographics. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} - - name: base_parta_procedure_code - description: Base model used as ref for pivot transformation. + - name: stg_parta_claims_header + description: Staging model for parta claims header. config: schema: | - {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} + + - name: stg_parta_claims_revenue_center_detail + description: Staging model for parta claims revenue center detail. + config: + schema: | + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} + + - name: stg_parta_diagnosis_code + description: Staging model for parta diagnosis codes used as ref for pivot transformation. + config: + schema: | + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} + + - name: stg_parta_procedure_code + description: Staging model for parta procedure codes used as ref for pivot transformation. + config: + schema: | + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} + + - name: stg_partb_dme + description: Staging model for partb dme. + config: + schema: | + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} + + - name: stg_partb_physicians + description: Staging model for partb physicians. + config: + schema: | + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} diff --git a/models/final/eligibility.sql b/models/final/eligibility.sql index 90981357..1011700e 100644 --- a/models/final/eligibility.sql +++ b/models/final/eligibility.sql @@ -22,17 +22,19 @@ with demographics as ( , geo_zip_plc_name , cast(bene_fips_state_cd as {{ dbt.type_string() }} ) as bene_fips_state_cd , bene_zip_cd - from {{ source('medicare_cclf','beneficiary_demographics') }} + , file_name + , ingest_datetime + from {{ ref('stg_beneficiary_demographics') }} -), +) -fips_state as ( +, fips_state as ( - select * from {{ ref('terminology__ansi_fips_state') }} + select * from {{ ref('reference_data__ansi_fips_state') }} -), +) -add_row_num as ( +, add_row_num as ( select * , row_number() over ( @@ -41,9 +43,9 @@ add_row_num as ( ) as row_num from demographics -), +) -add_lag_enrollment as ( +, add_lag_enrollment as ( select bene_mbi_id @@ -55,9 +57,9 @@ add_lag_enrollment as ( ) as lag_enrollment from add_row_num -), +) -calculate_lag_diff as ( +, calculate_lag_diff as ( select bene_mbi_id @@ -67,9 +69,9 @@ calculate_lag_diff as ( , {{ datediff('lag_enrollment', 'bene_member_month', 'month') }} as lag_diff from add_lag_enrollment -), +) -calculate_gaps as ( +, calculate_gaps as ( select bene_mbi_id @@ -83,9 +85,9 @@ calculate_gaps as ( end as gap_flag from calculate_lag_diff -), +) -calculate_groups as ( +, calculate_groups as ( select bene_mbi_id @@ -101,9 +103,9 @@ calculate_groups as ( ) as row_group from calculate_gaps -), +) -enrollment_span as ( +, enrollment_span as ( select bene_mbi_id @@ -114,13 +116,14 @@ enrollment_span as ( from calculate_groups group by bene_mbi_id, row_group -), +) -joined as ( +, joined as ( select cast(enrollment_span.bene_mbi_id as {{ dbt.type_string() }} ) as patient_id , cast(enrollment_span.bene_mbi_id as {{ dbt.type_string() }} ) as member_id + , cast(null as {{ dbt.type_string() }} ) as subscriber_id , case demographics.bene_sex_cd when '0' then 'unknown' when '1' then 'male' @@ -151,19 +154,52 @@ joined as ( , cast(demographics.bene_mdcr_stus_cd as {{ dbt.type_string() }} ) as medicare_status_code , cast(demographics.bene_1st_name as {{ dbt.type_string() }} ) as first_name , cast(demographics.bene_last_name as {{ dbt.type_string() }} ) as last_name + , cast(null as {{ dbt.type_string() }} ) as social_security_number + , cast(null as {{ dbt.type_string() }} ) as subscriber_relation , cast(demographics.bene_line_1_adr as {{ dbt.type_string() }} ) as address , cast(demographics.geo_zip_plc_name as {{ dbt.type_string() }} ) as city , cast(fips_state.ansi_fips_state_name as {{ dbt.type_string() }} ) as state , cast(demographics.bene_zip_cd as {{ dbt.type_string() }} ) as zip_code , cast(NULL as {{ dbt.type_string() }} ) as phone , 'medicare cclf' as data_source + , cast(demographics.file_name as {{ dbt.type_string() }} ) as file_name + , cast(demographics.ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime from enrollment_span - left join demographics + left join demographics on enrollment_span.bene_mbi_id = demographics.bene_mbi_id and enrollment_span.enrollment_end_date_max = demographics.bene_member_month - left join fips_state + left join fips_state on demographics.bene_fips_state_cd = fips_state.ansi_fips_state_code ) -select * from joined \ No newline at end of file +select + patient_id + , member_id + , subscriber_id + , gender + , race + , birth_date + , death_date + , death_flag + , enrollment_start_date + , enrollment_end_date + , payer + , payer_type + , plan + , original_reason_entitlement_code + , dual_status_code + , medicare_status_code + , first_name + , last_name + , social_security_number + , subscriber_relation + , address + , city + , state + , zip_code + , phone + , data_source + , file_name + , ingest_datetime +from joined \ No newline at end of file diff --git a/models/final/medical_claim.sql b/models/final/medical_claim.sql index bf19456b..9fb3143e 100644 --- a/models/final/medical_claim.sql +++ b/models/final/medical_claim.sql @@ -1,5 +1,159 @@ -select * from {{ ref('institutional_claims')}} -union all -select * from {{ ref('physician_claims')}} -union all -select * from {{ ref('dme_claims')}} \ No newline at end of file +with unioned as ( + + select * from {{ ref('institutional_claims')}} + union all + select * from {{ ref('physician_claims')}} + union all + select * from {{ ref('dme_claims')}} + +) + +select + claim_id + , claim_line_number + , claim_type + , patient_id + , member_id + , payer + , plan + , claim_start_date + , claim_end_date + , claim_line_start_date + , claim_line_end_date + , admission_date + , discharge_date + , admit_source_code + , admit_type_code + , discharge_disposition_code + , place_of_service_code + , bill_type_code + , ms_drg_code + , apr_drg_code + , revenue_center_code + , service_unit_quantity + , hcpcs_code + , hcpcs_modifier_1 + , hcpcs_modifier_2 + , hcpcs_modifier_3 + , hcpcs_modifier_4 + , hcpcs_modifier_5 + , rendering_npi + , rendering_tin + , billing_npi + , billing_tin + , facility_npi + , paid_date + , paid_amount + , allowed_amount + , charge_amount + , coinsurance_amount + , copayment_amount + , deductible_amount + , total_cost_amount + , diagnosis_code_type + , diagnosis_code_1 + , diagnosis_code_2 + , diagnosis_code_3 + , diagnosis_code_4 + , diagnosis_code_5 + , diagnosis_code_6 + , diagnosis_code_7 + , diagnosis_code_8 + , diagnosis_code_9 + , diagnosis_code_10 + , diagnosis_code_11 + , diagnosis_code_12 + , diagnosis_code_13 + , diagnosis_code_14 + , diagnosis_code_15 + , diagnosis_code_16 + , diagnosis_code_17 + , diagnosis_code_18 + , diagnosis_code_19 + , diagnosis_code_20 + , diagnosis_code_21 + , diagnosis_code_22 + , diagnosis_code_23 + , diagnosis_code_24 + , diagnosis_code_25 + , diagnosis_poa_1 + , diagnosis_poa_2 + , diagnosis_poa_3 + , diagnosis_poa_4 + , diagnosis_poa_5 + , diagnosis_poa_6 + , diagnosis_poa_7 + , diagnosis_poa_8 + , diagnosis_poa_9 + , diagnosis_poa_10 + , diagnosis_poa_11 + , diagnosis_poa_12 + , diagnosis_poa_13 + , diagnosis_poa_14 + , diagnosis_poa_15 + , diagnosis_poa_16 + , diagnosis_poa_17 + , diagnosis_poa_18 + , diagnosis_poa_19 + , diagnosis_poa_20 + , diagnosis_poa_21 + , diagnosis_poa_22 + , diagnosis_poa_23 + , diagnosis_poa_24 + , diagnosis_poa_25 + , procedure_code_type + , procedure_code_1 + , procedure_code_2 + , procedure_code_3 + , procedure_code_4 + , procedure_code_5 + , procedure_code_6 + , procedure_code_7 + , procedure_code_8 + , procedure_code_9 + , procedure_code_10 + , procedure_code_11 + , procedure_code_12 + , procedure_code_13 + , procedure_code_14 + , procedure_code_15 + , procedure_code_16 + , procedure_code_17 + , procedure_code_18 + , procedure_code_19 + , procedure_code_20 + , procedure_code_21 + , procedure_code_22 + , procedure_code_23 + , procedure_code_24 + , procedure_code_25 + , procedure_date_1 + , procedure_date_2 + , procedure_date_3 + , procedure_date_4 + , procedure_date_5 + , procedure_date_6 + , procedure_date_7 + , procedure_date_8 + , procedure_date_9 + , procedure_date_10 + , procedure_date_11 + , procedure_date_12 + , procedure_date_13 + , procedure_date_14 + , procedure_date_15 + , procedure_date_16 + , procedure_date_17 + , procedure_date_18 + , procedure_date_19 + , procedure_date_20 + , procedure_date_21 + , procedure_date_22 + , procedure_date_23 + , procedure_date_24 + , procedure_date_25 + , in_network_flag + , data_source + , file_name + , ingest_datetime +from unioned \ No newline at end of file diff --git a/models/final/pharmacy_claim.sql b/models/final/pharmacy_claim.sql index 8f8bb370..64ee6828 100644 --- a/models/final/pharmacy_claim.sql +++ b/models/final/pharmacy_claim.sql @@ -1,22 +1,26 @@ select - cast(null as {{ dbt.type_string() }}) as CLAIM_ID - ,cast(null as {{ dbt.type_string() }}) as CLAIM_LINE_NUMBER - ,cast(null as {{ dbt.type_string() }}) as PATIENT_ID - ,cast(null as {{ dbt.type_string() }}) as MEMBER_ID - ,cast(null as {{ dbt.type_string() }}) as PAYER - ,cast(null as {{ dbt.type_string() }}) as PLAN - ,cast(null as {{ dbt.type_string() }}) as PRESCRIBING_PROVIDER_NPI - ,cast(null as {{ dbt.type_string() }}) as DISPENSING_PROVIDER_NPI - ,cast(null as date ) as DISPENSING_DATE - ,cast(null as {{ dbt.type_string() }}) as NDC_CODE - ,cast(null as int) as QUANTITY - ,cast(null as int) as DAYS_SUPPLY - ,cast(null as int) as REFILLS - ,cast(null as date) as PAID_DATE - ,cast(null as numeric) as PAID_AMOUNT - ,cast(null as numeric) as ALLOWED_AMOUNT - ,cast(null as numeric) as COPAYMENT_AMOUNT - ,cast(null as numeric) as COINSURANCE_AMOUNT - ,cast(null as numeric) as DEDUCTIBLE_AMOUNT - ,cast(null as {{ dbt.type_string() }}) as DATA_SOURCE + cast(null as {{ dbt.type_string() }}) as claim_id + , cast(null as {{ dbt.type_string() }}) as claim_line_number + , cast(null as {{ dbt.type_string() }}) as patient_id + , cast(null as {{ dbt.type_string() }}) as member_id + , cast(null as {{ dbt.type_string() }}) as payer + , cast(null as {{ dbt.type_string() }}) as plan + , cast(null as {{ dbt.type_string() }}) as prescribing_provider_npi + , cast(null as {{ dbt.type_string() }}) as dispensing_provider_npi + , cast(null as date ) as dispensing_date + , cast(null as {{ dbt.type_string() }}) as ndc_code + , cast(null as int) as quantity + , cast(null as int) as days_supply + , cast(null as int) as refills + , cast(null as date) as paid_date + , cast(null as numeric) as paid_amount + , cast(null as numeric) as allowed_amount + , cast(null as numeric) as charge_amount + , cast(null as numeric) as coinsurance_amount + , cast(null as numeric) as copayment_amount + , cast(null as numeric) as deductible_amount + , cast(null as int) as in_network_flag + , cast(null as {{ dbt.type_string() }}) as data_source + , cast(null as {{ dbt.type_string() }}) as file_name + , cast(null as {{ dbt.type_timestamp() }}) as ingest_datetime limit 0 \ No newline at end of file diff --git a/models/intermediate/diagnosis_pivot.sql b/models/intermediate/diagnosis_pivot.sql index 4fd83af1..4df3ff3a 100644 --- a/models/intermediate/diagnosis_pivot.sql +++ b/models/intermediate/diagnosis_pivot.sql @@ -13,7 +13,7 @@ with diagnois_pivot as ( , prefix='diagnosis_code_' , quote_identifiers=false ) }} - from {{ ref('base_parta_diagnosis_code') }} + from {{ ref('stg_parta_diagnosis_code') }} group by cur_clm_uniq_id , bene_mbi_id @@ -36,7 +36,7 @@ poa_pivot as ( , prefix='diagnosis_poa_' , quote_identifiers=false ) }} - from {{ ref('base_parta_diagnosis_code') }} + from {{ ref('stg_parta_diagnosis_code') }} group by cur_clm_uniq_id , bene_mbi_id @@ -99,7 +99,7 @@ select , poa.diagnosis_poa_24 , poa.diagnosis_poa_25 from diagnois_pivot as dx -inner join poa_pivot as poa - on dx.cur_clm_uniq_id = poa.cur_clm_uniq_id + inner join poa_pivot as poa + on dx.cur_clm_uniq_id = poa.cur_clm_uniq_id /* filtering out null values from seed file */ where dx.cur_clm_uniq_id is not null \ No newline at end of file diff --git a/models/intermediate/dme_claims.sql b/models/intermediate/dme_claims.sql index 1869bb12..bfec3265 100644 --- a/models/intermediate/dme_claims.sql +++ b/models/intermediate/dme_claims.sql @@ -28,7 +28,9 @@ select , cast(NULL as {{ dbt.type_string() }} ) as hcpcs_modifier_4 , cast(NULL as {{ dbt.type_string() }} ) as hcpcs_modifier_5 , cast(ordrg_prvdr_npi_num as {{ dbt.type_string() }} ) as rendering_npi + , cast(NULL as {{ dbt.type_string() }} ) as rendering_tin , cast(payto_prvdr_npi_num as {{ dbt.type_string() }} ) as billing_npi + , cast(NULL as {{ dbt.type_string() }} ) as billing_tin , cast(NULL as {{ dbt.type_string() }} ) as facility_npi , cast(NULL as date) as paid_date , case @@ -143,5 +145,8 @@ select , cast(NULL as date) as procedure_date_23 , cast(NULL as date) as procedure_date_24 , cast(NULL as date) as procedure_date_25 + , cast(1 as int) as in_network_flag , 'medicare cclf' as data_source -from {{ source('medicare_cclf','partb_dme')}} + , cast(file_name as {{ dbt.type_string() }} ) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime +from {{ ref('stg_partb_dme') }} \ No newline at end of file diff --git a/models/intermediate/institutional_claims.sql b/models/intermediate/institutional_claims.sql index 3df69408..f2bd19e2 100644 --- a/models/intermediate/institutional_claims.sql +++ b/models/intermediate/institutional_claims.sql @@ -1,35 +1,41 @@ with claim_line as ( -select distinct - a.cur_clm_uniq_id as claim_id -, b.clm_line_num as claim_line_number -, row_number() over(partition by a.cur_clm_uniq_id order by b.clm_line_num) as claim_row_number -from {{ source('medicare_cclf','parta_claims_header')}} a -left join {{ source('medicare_cclf','parta_claims_revenue_center_detail')}} b - on a.cur_clm_uniq_id = b.cur_clm_uniq_id + + select distinct + a.cur_clm_uniq_id as claim_id + , b.clm_line_num as claim_line_number + , row_number() over(partition by a.cur_clm_uniq_id order by b.clm_line_num) as claim_row_number + from {{ ref('stg_parta_claims_header') }} as a + left join {{ ref('stg_parta_claims_revenue_center_detail') }} as b + on a.cur_clm_uniq_id = b.cur_clm_uniq_id + ) , add_header_paid_amount as ( -select - a.claim_id -, a.claim_line_number -, a.claim_row_number -, b.clm_pmt_amt as paid_amount -from claim_line a -inner join {{ source('medicare_cclf','parta_claims_header')}} b - on a.claim_id = b.cur_clm_uniq_id -where a.claim_row_number = 1 + + select + a.claim_id + , a.claim_line_number + , a.claim_row_number + , b.clm_pmt_amt as paid_amount + from claim_line as a + inner join {{ ref('stg_parta_claims_header') }} as b + on a.claim_id = b.cur_clm_uniq_id + where a.claim_row_number = 1 + ) , claim_line_a as ( -select - a.claim_id -, a.claim_line_number -, a.claim_row_number -, b.paid_amount -from claim_line a -left join add_header_paid_amount b - on a.claim_id = b.claim_id - and a.claim_row_number = b.claim_row_number + + select + a.claim_id + , a.claim_line_number + , a.claim_row_number + , b.paid_amount + from claim_line as a + left join add_header_paid_amount as b + on a.claim_id = b.claim_id + and a.claim_row_number = b.claim_row_number + ) select @@ -65,12 +71,14 @@ select , cast(d.hcpcs_4_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_4 , cast(d.hcpcs_5_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_5 , cast(h.atndg_prvdr_npi_num as {{ dbt.type_string() }} ) as rendering_npi + , cast(NULL as {{ dbt.type_string() }} ) as rendering_tin , cast(NULL as {{ dbt.type_string() }} ) as billing_npi + , cast(NULL as {{ dbt.type_string() }} ) as billing_tin , cast(h.fac_prvdr_npi_num as {{ dbt.type_string() }} ) as facility_npi , cast(NULL as date) as paid_date - , case - when cast(h.clm_adjsmt_type_cd as {{ dbt.type_string() }} ) = '1' then {{ cast_numeric('a.paid_amount') }} * -1 - else {{ cast_numeric('a.paid_amount') }} + , case + when cast(h.clm_adjsmt_type_cd as {{ dbt.type_string() }} ) = '1' then {{ cast_numeric('a.paid_amount') }} * -1 + else {{ cast_numeric('a.paid_amount') }} end as paid_amount , {{ cast_numeric('NULL') }} as allowed_amount , {{ cast_numeric('h.clm_mdcr_instnl_tot_chrg_amt') }} as charge_amount @@ -187,14 +195,17 @@ select , {{ try_to_cast_date('px.procedure_date_23', 'YYYY-MM-DD') }} as procedure_date_23 , {{ try_to_cast_date('px.procedure_date_24', 'YYYY-MM-DD') }} as procedure_date_24 , {{ try_to_cast_date('px.procedure_date_25', 'YYYY-MM-DD') }} as procedure_date_25 + , cast(1 as int) as in_network_flag , 'medicare cclf' as data_source -from claim_line_a a -left join {{ source('medicare_cclf','parta_claims_header')}} h - on a.claim_id = h.cur_clm_uniq_id -left join {{ source('medicare_cclf','parta_claims_revenue_center_detail')}} d - on a.claim_id = d.cur_clm_uniq_id - and a.claim_line_number = d.clm_line_num -left join {{ ref('procedure_pivot')}} px - on cast(a.claim_id as {{ dbt.type_string() }} ) = cast(px.cur_clm_uniq_id as {{ dbt.type_string() }} ) -left join {{ ref('diagnosis_pivot')}} dx - on cast(a.claim_id as {{ dbt.type_string() }} ) = cast(dx.cur_clm_uniq_id as {{ dbt.type_string() }} ) + , cast(h.file_name as {{ dbt.type_string() }} ) as file_name + , cast(h.ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime +from claim_line_a as a + left join {{ ref('stg_parta_claims_header') }} as h + on a.claim_id = h.cur_clm_uniq_id + left join {{ ref('stg_parta_claims_revenue_center_detail') }} as d + on a.claim_id = d.cur_clm_uniq_id + and a.claim_line_number = d.clm_line_num + left join {{ ref('procedure_pivot') }} as px + on cast(a.claim_id as {{ dbt.type_string() }} ) = cast(px.cur_clm_uniq_id as {{ dbt.type_string() }} ) + left join {{ ref('diagnosis_pivot') }} as dx + on cast(a.claim_id as {{ dbt.type_string() }} ) = cast(dx.cur_clm_uniq_id as {{ dbt.type_string() }} ) \ No newline at end of file diff --git a/models/intermediate/physician_claims.sql b/models/intermediate/physician_claims.sql index 9002a845..8c884005 100644 --- a/models/intermediate/physician_claims.sql +++ b/models/intermediate/physician_claims.sql @@ -28,7 +28,9 @@ select , cast(hcpcs_4_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_4 , cast(hcpcs_5_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_5 , cast(rndrg_prvdr_npi_num as {{ dbt.type_string() }} ) as rendering_npi + , cast(clm_rndrg_prvdr_tax_num as {{ dbt.type_string() }} ) as rendering_tin , cast(NULL as {{ dbt.type_string() }} ) as billing_npi + , cast(NULL as {{ dbt.type_string() }} ) as billing_tin , cast(NULL as {{ dbt.type_string() }} ) as facility_npi , cast(NULL as date) as paid_date , case @@ -146,5 +148,8 @@ select , cast(NULL as date) as procedure_date_23 , cast(NULL as date) as procedure_date_24 , cast(NULL as date) as procedure_date_25 + , cast(1 as int) as in_network_flag , 'medicare cclf' as data_source -from {{ source('medicare_cclf','partb_physicians')}} + , cast(file_name as {{ dbt.type_string() }} ) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime +from {{ ref('stg_partb_physicians') }} \ No newline at end of file diff --git a/models/intermediate/procedure_pivot.sql b/models/intermediate/procedure_pivot.sql index f6b74749..c56b5c28 100644 --- a/models/intermediate/procedure_pivot.sql +++ b/models/intermediate/procedure_pivot.sql @@ -13,7 +13,7 @@ with procedure_pivot as ( , prefix='procedure_code_' , quote_identifiers=false ) }} - from {{ ref('base_parta_procedure_code') }} + from {{ ref('stg_parta_procedure_code') }} group by cur_clm_uniq_id , bene_mbi_id @@ -36,7 +36,7 @@ date_pivot as( , prefix='procedure_date_' , quote_identifiers=false ) }} - from {{ ref('base_parta_procedure_code') }} + from {{ ref('stg_parta_procedure_code') }} group by cur_clm_uniq_id , bene_mbi_id @@ -98,8 +98,8 @@ select , d.procedure_date_23 , d.procedure_date_24 , d.procedure_date_25 -from procedure_pivot px -inner join date_pivot d - on px.cur_clm_uniq_id = d.cur_clm_uniq_id +from procedure_pivot as px + inner join date_pivot as d + on px.cur_clm_uniq_id = d.cur_clm_uniq_id /* filtering out null values from seed file */ where px.cur_clm_uniq_id is not null \ No newline at end of file diff --git a/models/staging/base_parta_diagnosis_code.sql b/models/staging/base_parta_diagnosis_code.sql deleted file mode 100644 index 4fab0d00..00000000 --- a/models/staging/base_parta_diagnosis_code.sql +++ /dev/null @@ -1,16 +0,0 @@ - - select - cast(cur_clm_uniq_id as {{ dbt.type_string() }} ) as cur_clm_uniq_id - , cast(bene_mbi_id as {{ dbt.type_string() }} ) as bene_mbi_id - , cast(bene_hic_num as {{ dbt.type_string() }} ) as bene_hic_num - , cast(clm_type_cd as {{ dbt.type_string() }} ) as clm_type_cd - , cast(clm_prod_type_cd as {{ dbt.type_string() }} ) as clm_prod_type_cd - , cast(clm_val_sqnc_num as {{ dbt.type_string() }} ) as clm_val_sqnc_num - , cast(clm_dgns_cd as {{ dbt.type_string() }} ) as clm_dgns_cd - , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }} ) as bene_eqtbl_bic_hicn_num - , cast(prvdr_oscar_num as {{ dbt.type_string() }} ) as prvdr_oscar_num - , cast(clm_from_dt as {{ dbt.type_string() }} ) as clm_from_dt - , cast(clm_thru_dt as {{ dbt.type_string() }} ) as clm_thru_dt - , cast(clm_poa_ind as {{ dbt.type_string() }} ) as clm_poa_ind - , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) as dgns_prcdr_icd_ind - from {{ source('medicare_cclf','parta_diagnosis_code') }} diff --git a/models/staging/base_parta_procedure_code.sql b/models/staging/base_parta_procedure_code.sql deleted file mode 100644 index e48904ee..00000000 --- a/models/staging/base_parta_procedure_code.sql +++ /dev/null @@ -1,15 +0,0 @@ - - select - cast(cur_clm_uniq_id as {{ dbt.type_string() }} ) as cur_clm_uniq_id - , cast(bene_mbi_id as {{ dbt.type_string() }} ) as bene_mbi_id - , cast(bene_hic_num as {{ dbt.type_string() }} ) as bene_hic_num - , cast(clm_type_cd as {{ dbt.type_string() }} ) as clm_type_cd - , cast(clm_val_sqnc_num as {{ dbt.type_string() }} ) as clm_val_sqnc_num - , cast(clm_prcdr_cd as {{ dbt.type_string() }} ) as clm_prcdr_cd - , cast(clm_prcdr_prfrm_dt as {{ dbt.type_string() }} ) as clm_prcdr_prfrm_dt - , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }} ) as bene_eqtbl_bic_hicn_num - , cast(prvdr_oscar_num as {{ dbt.type_string() }} ) as prvdr_oscar_num - , cast(clm_from_dt as {{ dbt.type_string() }} ) as clm_from_dt - , cast(clm_thru_dt as {{ dbt.type_string() }} ) as clm_thru_dt - , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) as dgns_prcdr_icd_ind - from {{ source('medicare_cclf','parta_procedure_code') }} diff --git a/models/staging/stg_beneficiary_demographics.sql b/models/staging/stg_beneficiary_demographics.sql new file mode 100644 index 00000000..f1d825fa --- /dev/null +++ b/models/staging/stg_beneficiary_demographics.sql @@ -0,0 +1,36 @@ +select + bene_mbi_id + , bene_member_month + , bene_hic_num + , bene_fips_state_cd + , bene_fips_cnty_cd + , bene_zip_cd + , bene_dob + , bene_sex_cd + , bene_race_cd + , bene_age + , bene_mdcr_stus_cd + , bene_dual_stus_cd + , bene_death_dt + , bene_rng_bgn_dt + , bene_rng_end_dt + , bene_1st_name + , bene_midl_name + , bene_last_name + , bene_orgnl_entlmt_rsn_cd + , bene_entlmt_buyin_ind + , bene_part_a_enrlmt_bgn_dt + , bene_part_b_enrlmt_bgn_dt + , bene_line_1_adr + , bene_line_2_adr + , bene_line_3_adr + , bene_line_4_adr + , bene_line_5_adr + , bene_line_6_adr + , geo_zip_plc_name + , geo_usps_state_cd + , geo_zip5_cd + , geo_zip4_cd + , file_name + , ingest_datetime +from {{ source('medicare_cclf','beneficiary_demographics') }} \ No newline at end of file diff --git a/models/staging/stg_parta_claims_header.sql b/models/staging/stg_parta_claims_header.sql new file mode 100644 index 00000000..1081ac49 --- /dev/null +++ b/models/staging/stg_parta_claims_header.sql @@ -0,0 +1,41 @@ +select + cur_clm_uniq_id + , prvdr_oscar_num + , bene_mbi_id + , bene_hic_num + , clm_type_cd + , clm_from_dt + , clm_thru_dt + , clm_bill_fac_type_cd + , clm_bill_clsfctn_cd + , prncpl_dgns_cd + , admtg_dgns_cd + , clm_mdcr_npmt_rsn_cd + , clm_pmt_amt + , clm_nch_prmry_pyr_cd + , prvdr_fac_fips_st_cd + , bene_ptnt_stus_cd + , dgns_drg_cd + , clm_op_srvc_type_cd + , fac_prvdr_npi_num + , oprtg_prvdr_npi_num + , atndg_prvdr_npi_num + , othr_prvdr_npi_num + , clm_adjsmt_type_cd + , clm_efctv_dt + , clm_idr_ld_dt + , bene_eqtbl_bic_hicn_num + , clm_admsn_type_cd + , clm_admsn_src_cd + , clm_bill_freq_cd + , clm_query_cd + , dgns_prcdr_icd_ind + , clm_mdcr_instnl_tot_chrg_amt + , clm_mdcr_ip_pps_cptl_ime_amt + , clm_oprtnl_ime_amt + , clm_mdcr_ip_pps_dsprprtnt_amt + , clm_hipps_uncompd_care_amt + , clm_oprtnl_dsprtnt_amt + , file_name + , ingest_datetime +from {{ source('medicare_cclf','parta_claims_header') }} \ No newline at end of file diff --git a/models/staging/stg_parta_claims_revenue_center_detail.sql b/models/staging/stg_parta_claims_revenue_center_detail.sql new file mode 100644 index 00000000..5ffd9afe --- /dev/null +++ b/models/staging/stg_parta_claims_revenue_center_detail.sql @@ -0,0 +1,26 @@ +select + cur_clm_uniq_id + , clm_line_num + , bene_mbi_id + , bene_hic_num + , clm_type_cd + , clm_line_from_dt + , clm_line_thru_dt + , clm_line_prod_rev_ctr_cd + , clm_line_instnl_rev_ctr_dt + , clm_line_hcpcs_cd + , bene_eqtbl_bic_hicn_num + , prvdr_oscar_num + , clm_from_dt + , clm_thru_dt + , clm_line_srvc_unit_qty + , clm_line_cvrd_pd_amt + , hcpcs_1_mdfr_cd + , hcpcs_2_mdfr_cd + , hcpcs_3_mdfr_cd + , hcpcs_4_mdfr_cd + , hcpcs_5_mdfr_cd + , clm_rev_apc_hipps_cd + , file_name + , ingest_datetime +from {{ source('medicare_cclf','parta_claims_revenue_center_detail') }} \ No newline at end of file diff --git a/models/staging/stg_parta_diagnosis_code.sql b/models/staging/stg_parta_diagnosis_code.sql new file mode 100644 index 00000000..b79d7160 --- /dev/null +++ b/models/staging/stg_parta_diagnosis_code.sql @@ -0,0 +1,15 @@ +select + cast(cur_clm_uniq_id as {{ dbt.type_string() }} ) as cur_clm_uniq_id + , cast(bene_mbi_id as {{ dbt.type_string() }} ) as bene_mbi_id + , cast(bene_hic_num as {{ dbt.type_string() }} ) as bene_hic_num + , cast(clm_type_cd as {{ dbt.type_string() }} ) as clm_type_cd + , cast(clm_prod_type_cd as {{ dbt.type_string() }} ) as clm_prod_type_cd + , cast(clm_val_sqnc_num as {{ dbt.type_string() }} ) as clm_val_sqnc_num + , cast(clm_dgns_cd as {{ dbt.type_string() }} ) as clm_dgns_cd + , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }} ) as bene_eqtbl_bic_hicn_num + , cast(prvdr_oscar_num as {{ dbt.type_string() }} ) as prvdr_oscar_num + , cast(clm_from_dt as {{ dbt.type_string() }} ) as clm_from_dt + , cast(clm_thru_dt as {{ dbt.type_string() }} ) as clm_thru_dt + , cast(clm_poa_ind as {{ dbt.type_string() }} ) as clm_poa_ind + , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) as dgns_prcdr_icd_ind +from {{ source('medicare_cclf','parta_diagnosis_code') }} \ No newline at end of file diff --git a/models/staging/stg_parta_procedure_code.sql b/models/staging/stg_parta_procedure_code.sql new file mode 100644 index 00000000..487fafea --- /dev/null +++ b/models/staging/stg_parta_procedure_code.sql @@ -0,0 +1,14 @@ +select + cast(cur_clm_uniq_id as {{ dbt.type_string() }} ) as cur_clm_uniq_id + , cast(bene_mbi_id as {{ dbt.type_string() }} ) as bene_mbi_id + , cast(bene_hic_num as {{ dbt.type_string() }} ) as bene_hic_num + , cast(clm_type_cd as {{ dbt.type_string() }} ) as clm_type_cd + , cast(clm_val_sqnc_num as {{ dbt.type_string() }} ) as clm_val_sqnc_num + , cast(clm_prcdr_cd as {{ dbt.type_string() }} ) as clm_prcdr_cd + , cast(clm_prcdr_prfrm_dt as {{ dbt.type_string() }} ) as clm_prcdr_prfrm_dt + , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }} ) as bene_eqtbl_bic_hicn_num + , cast(prvdr_oscar_num as {{ dbt.type_string() }} ) as prvdr_oscar_num + , cast(clm_from_dt as {{ dbt.type_string() }} ) as clm_from_dt + , cast(clm_thru_dt as {{ dbt.type_string() }} ) as clm_thru_dt + , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) as dgns_prcdr_icd_ind +from {{ source('medicare_cclf','parta_procedure_code') }} \ No newline at end of file diff --git a/models/staging/stg_partb_dme.sql b/models/staging/stg_partb_dme.sql new file mode 100644 index 00000000..12c62814 --- /dev/null +++ b/models/staging/stg_partb_dme.sql @@ -0,0 +1,29 @@ +select + cur_clm_uniq_id + , clm_line_num + , bene_mbi_id + , bene_hic_num + , clm_type_cd + , clm_from_dt + , clm_thru_dt + , clm_fed_type_srvc_cd + , clm_pos_cd + , clm_line_from_dt + , clm_line_thru_dt + , clm_line_hcpcs_cd + , clm_line_cvrd_pd_amt + , clm_prmry_pyr_cd + , payto_prvdr_npi_num + , ordrg_prvdr_npi_num + , clm_carr_pmt_dnl_cd + , clm_prcsg_ind_cd + , clm_adjsmt_type_cd + , clm_efctv_dt + , clm_idr_ld_dt + , clm_cntl_num + , bene_eqtbl_bic_hicn_num + , clm_line_alowd_chrg_amt + , clm_disp_cd + , file_name + , ingest_datetime +from {{ source('medicare_cclf','partb_dme') }} \ No newline at end of file diff --git a/models/staging/stg_partb_physicians.sql b/models/staging/stg_partb_physicians.sql new file mode 100644 index 00000000..313a7978 --- /dev/null +++ b/models/staging/stg_partb_physicians.sql @@ -0,0 +1,53 @@ +select + cur_clm_uniq_id + , clm_line_num + , bene_mbi_id + , bene_hic_num + , clm_type_cd + , clm_from_dt + , clm_thru_dt + , rndrg_prvdr_type_cd + , rndrg_prvdr_fips_st_cd + , clm_prvdr_spclty_cd + , clm_fed_type_srvc_cd + , clm_pos_cd + , clm_line_from_dt + , clm_line_thru_dt + , clm_line_hcpcs_cd + , clm_line_cvrd_pd_amt + , clm_line_prmry_pyr_cd + , clm_line_dgns_cd + , clm_rndrg_prvdr_tax_num + , rndrg_prvdr_npi_num + , clm_carr_pmt_dnl_cd + , clm_prcsg_ind_cd + , clm_adjsmt_type_cd + , clm_efctv_dt + , clm_idr_ld_dt + , clm_cntl_num + , bene_eqtbl_bic_hicn_num + , clm_line_alowd_chrg_amt + , clm_line_srvc_unit_qty + , hcpcs_1_mdfr_cd + , hcpcs_2_mdfr_cd + , hcpcs_3_mdfr_cd + , hcpcs_4_mdfr_cd + , hcpcs_5_mdfr_cd + , clm_disp_cd + , clm_dgns_1_cd + , clm_dgns_2_cd + , clm_dgns_3_cd + , clm_dgns_4_cd + , clm_dgns_5_cd + , clm_dgns_6_cd + , clm_dgns_7_cd + , clm_dgns_8_cd + , dgns_prcdr_icd_ind + , clm_dgns_9_cd + , clm_dgns_10_cd + , clm_dgns_11_cd + , clm_dgns_12_cd + , hcpcs_betos_cd + , file_name + , ingest_datetime +from {{ source('medicare_cclf','partb_physicians') }} \ No newline at end of file diff --git a/packages.yml b/packages.yml index 7a38e15a..1a42c0a1 100644 --- a/packages.yml +++ b/packages.yml @@ -2,4 +2,4 @@ packages: - package: dbt-labs/dbt_utils version: [">=0.9.2","<1.0.0"] - package: tuva-health/the_tuva_project - version: [">=0.7.0","<0.8.0"] \ No newline at end of file + version: [">=0.10.0","<0.11.0"] \ No newline at end of file