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 index 032d81e4..de755086 100644 --- 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 @@ -33,7 +33,7 @@ jobs: - 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"}' + 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 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 index b41cfab7..624ce85b 100644 --- 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 @@ -33,7 +33,7 @@ jobs: - 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"}' + 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() }} 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 index e3f02483..2079362c 100644 --- 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 @@ -35,7 +35,7 @@ jobs: - 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"}' + 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() }} diff --git a/.github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml b/.github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml index 452d3b94..9ae04ec0 100644 --- a/.github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml +++ b/.github/workflows/dbt_v1.4.6_bigquery_build_full_refresh.yml @@ -30,7 +30,7 @@ jobs: - name: dbt-build uses: mwhitaker/dbt-action@v1.4.6 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"}' + 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 diff --git a/.github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml b/.github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml index ffb6f603..3d2f9727 100644 --- a/.github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml +++ b/.github/workflows/dbt_v1.4.6_redshift_build_full_refresh.yml @@ -31,7 +31,7 @@ jobs: - name: dbt-build uses: mwhitaker/dbt-action@v1.4.6 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"}' + 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() }} diff --git a/.github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml b/.github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml index 99501cda..453c08f7 100644 --- a/.github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml +++ b/.github/workflows/dbt_v1.4.6_snowflake_build_full_refresh.yml @@ -35,7 +35,7 @@ jobs: - name: dbt-build uses: mwhitaker/dbt-action@v1.4.6 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"}' + 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 diff --git a/.github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml b/.github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml index a7ef810c..71f4566d 100644 --- a/.github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml +++ b/.github/workflows/outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml @@ -47,7 +47,7 @@ jobs: - name: dbt-build uses: mwhitaker/dbt-action@v1.4.6 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"}' + 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() }} @@ -76,7 +76,7 @@ jobs: - name: dbt-build uses: mwhitaker/dbt-action@v1.4.6 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"}' + 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() }} @@ -106,7 +106,7 @@ jobs: - name: dbt-build uses: mwhitaker/dbt-action@v1.4.6 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"}' + 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() }} diff --git a/dbt_project.yml b/dbt_project.yml index a7a7c8bd..d5b5b87e 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,14 +1,16 @@ name: 'medicare_cclf_connector' -version: '0.1.1' +version: '0.1.2' config-version: 2 profile: default vars: -## Set the database and schema where raw CCLF data is stored + ## Set the database and schema where raw CCLF data is stored input_database: default - input_schema: default + input_schema: default + + claims_enabled: true model-paths: ["models"] analysis-paths: ["analyses"] diff --git a/macros/cast_string_or_varchar.sql b/macros/cast_string_or_varchar.sql deleted file mode 100644 index 1ac85130..00000000 --- a/macros/cast_string_or_varchar.sql +++ /dev/null @@ -1,39 +0,0 @@ -{#- - Casts a column as string or varchar. --#} - -{%- macro cast_string_or_varchar(column_name) -%} - - {{ return(adapter.dispatch('cast_string_or_varchar')(column_name)) }} - -{%- endmacro -%} - -{%- macro bigquery__cast_string_or_varchar(column_name) -%} - - cast( {{ column_name }} as string ) - -{%- endmacro -%} - -{%- macro default__cast_string_or_varchar(column_name) %} - - cast( {{ column_name }} as string ) - -{%- endmacro -%} - -{%- macro postgres__cast_string_or_varchar(column_name) -%} - - cast( {{ column_name }} as varchar ) - -{%- endmacro -%} - -{%- macro redshift__cast_string_or_varchar(column_name) -%} - - cast( {{ column_name }} as varchar ) - -{%- endmacro -%} - -{%- macro snowflake__cast_string_or_varchar(column_name) %} - - cast( {{ column_name }} as string ) - -{%- endmacro -%} \ No newline at end of file diff --git a/models/_models.yml b/models/_models.yml index 9ee9f454..31d8e60b 100644 --- a/models/_models.yml +++ b/models/_models.yml @@ -1,79 +1,77 @@ version: 2 models: - -### staging - - name: base_parta_diagnosis_code - description: Base model used as ref for pivot transformation +### final + - name: eligibility + description: > + Member enrollment and demographic detail, converts member months to + enrollment spans. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} + materialized: table - - - name: base_parta_procedure_code - description: Base model used as ref for pivot transformation + - name: medical_claim + description: Claim line level medical data. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- 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 -%} + materialized: table ### intermediate - name: diagnosis_pivot - description: Pivot of diagnosis from long (1 row/diagnosis) to wide (multiple diagnosis per row) + description: > + Pivot of diagnosis from long (1 row/diagnosis) to wide (multiple diagnosis + per row). config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} - name: dme_claims - description: Mapping of durable medical equipment claims to Tuva claims data model + description: > + Mapping of durable medical equipment claims to Tuva claims data model. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} - name: institutional_claims description: > - Mapping of institution claims to Tuva claims data model + Mapping of institution claims to Tuva claims data model. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} - name: physician_claims description: > - Mapping of professional claims to Tuva claims data model + Mapping of professional claims to Tuva claims data model. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} - name: procedure_pivot - description: Pivot of procedures from long (1 row/procedure) to wide (multiple procedure per row) - config: - schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_tuva_claims{% else %}tuva_claims{%- endif -%} - - -### final - - name: eligibility description: > - Member enrollment and demographic detail, converts member months to enrollment spans. + Pivot of procedures from long (1 row/procedure) to wide (multiple + procedure per row). config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} - - name: medical_claim - description: Claim line level medical data +### staging + - name: base_parta_diagnosis_code + description: Base model used as ref for pivot transformation. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} - - name: pharmacy_claim - description: Claim line level medical data + - name: base_parta_procedure_code + description: Base model used as ref for pivot transformation. config: schema: | - {%- if var('medicare_cclf_connector_schema',None) != None -%}{{ var('medicare_cclf_connector_schema') }}{%- elif 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')}}_tuva_claims{% else %}_tuva_claims{%- endif -%} diff --git a/models/final/eligibility.sql b/models/final/eligibility.sql index 034d5549..4d806dbb 100644 --- a/models/final/eligibility.sql +++ b/models/final/eligibility.sql @@ -8,18 +8,19 @@ with demographics as ( select bene_mbi_id - , {{ cast_string_or_varchar('bene_sex_cd') }} as bene_sex_cd - , {{ cast_string_or_varchar('bene_race_cd') }} as bene_race_cd + , cast(bene_sex_cd as {{ dbt.type_string() }} ) as bene_sex_cd + , cast(bene_race_cd as {{ dbt.type_string() }} ) as bene_race_cd , bene_dob , bene_death_dt , {{ try_to_cast_date('bene_member_month', 'YYYY-MM-DD') }} as bene_member_month , bene_dual_stus_cd , bene_mdcr_stus_cd + , bene_orgnl_entlmt_rsn_cd , bene_1st_name , bene_last_name , bene_line_1_adr , geo_zip_plc_name - , {{ cast_string_or_varchar('bene_fips_state_cd') }} as bene_fips_state_cd + , cast(bene_fips_state_cd as {{ dbt.type_string() }} ) as bene_fips_state_cd , bene_zip_cd from {{ source('medicare_cclf','beneficiary_demographics') }} @@ -118,8 +119,8 @@ enrollment_span as ( joined as ( select - {{ cast_string_or_varchar('enrollment_span.bene_mbi_id') }} as patient_id - , {{ cast_string_or_varchar('enrollment_span.bene_mbi_id') }} as member_id + 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 , case demographics.bene_sex_cd when '0' then 'unknown' when '1' then 'male' @@ -144,15 +145,16 @@ joined as ( , enrollment_span.enrollment_end_date_last as enrollment_end_date , 'medicare' as payer , 'medicare' as payer_type - , {{ cast_string_or_varchar('demographics.bene_dual_stus_cd') }} as dual_status_code - , {{ cast_string_or_varchar('demographics.bene_mdcr_stus_cd') }} as medicare_status_code - , {{ cast_string_or_varchar('demographics.bene_1st_name') }} as first_name - , {{ cast_string_or_varchar('demographics.bene_last_name') }} as last_name - , {{ cast_string_or_varchar('demographics.bene_line_1_adr') }} as address - , {{ cast_string_or_varchar('demographics.geo_zip_plc_name') }} as city - , {{ cast_string_or_varchar('fips_state.ansi_fips_state_name') }} as state - , {{ cast_string_or_varchar('demographics.bene_zip_cd') }} as zip_code - , {{ cast_string_or_varchar('NULL') }} as phone + , cast(bene_orgnl_entlmt_rsn_cd as {{ dbt.type_string() }} ) as original_reason_entitlement_code + , cast(demographics.bene_dual_stus_cd as {{ dbt.type_string() }} ) as dual_status_code + , 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(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 from enrollment_span left join demographics diff --git a/models/intermediate/dme_claims.sql b/models/intermediate/dme_claims.sql index 6d6775e0..29c3f714 100644 --- a/models/intermediate/dme_claims.sql +++ b/models/intermediate/dme_claims.sql @@ -1,115 +1,115 @@ select - {{ cast_string_or_varchar('cur_clm_uniq_id') }} as claim_id + cast(cur_clm_uniq_id as {{ dbt.type_string() }} ) as claim_id , cast(clm_line_num as integer) as claim_line_number , 'professional' as claim_type - , {{ cast_string_or_varchar('bene_mbi_id') }} as patient_id - , {{ cast_string_or_varchar('bene_mbi_id') }} as member_id + , cast(bene_mbi_id as {{ dbt.type_string() }} ) as patient_id + , cast(bene_mbi_id as {{ dbt.type_string() }} ) as member_id , {{ try_to_cast_date('clm_from_dt', 'YYYY-MM-DD') }} as claim_start_date , {{ try_to_cast_date('clm_thru_dt', 'YYYY-MM-DD') }} as claim_end_date , {{ try_to_cast_date('clm_line_from_dt', 'YYYY-MM-DD') }} as claim_line_start_date , {{ try_to_cast_date('clm_line_thru_dt', 'YYYY-MM-DD') }} as claim_line_end_date , cast(NULL as date) as admission_date , cast(NULL as date) as discharge_date - , {{ cast_string_or_varchar('NULL') }} as admit_source_code - , {{ cast_string_or_varchar('NULL') }} as admit_type_code - , {{ cast_string_or_varchar('NULL') }} as discharge_disposition_code - , {{ cast_string_or_varchar('clm_pos_cd') }} as place_of_service_code - , {{ cast_string_or_varchar('NULL') }} as bill_type_code - , {{ cast_string_or_varchar('NULL') }} as ms_drg_code - , {{ cast_string_or_varchar('NULL') }} as apr_drg_code - , {{ cast_string_or_varchar('NULL') }} as revenue_center_code + , cast(NULL as {{ dbt.type_string() }} ) as admit_source_code + , cast(NULL as {{ dbt.type_string() }} ) as admit_type_code + , cast(NULL as {{ dbt.type_string() }} ) as discharge_disposition_code + , cast(clm_pos_cd as {{ dbt.type_string() }} ) as place_of_service_code + , cast(NULL as {{ dbt.type_string() }} ) as bill_type_code + , cast(NULL as {{ dbt.type_string() }} ) as ms_drg_code + , cast(NULL as {{ dbt.type_string() }} ) as apr_drg_code + , cast(NULL as {{ dbt.type_string() }} ) as revenue_center_code , cast(NULL as integer) as service_unit_quantity - , {{ cast_string_or_varchar('clm_line_hcpcs_cd') }} as hcpcs_code - , {{ cast_string_or_varchar('NULL') }} as hcpcs_modifier_1 - , {{ cast_string_or_varchar('NULL') }} as hcpcs_modifier_2 - , {{ cast_string_or_varchar('NULL') }} as hcpcs_modifier_3 - , {{ cast_string_or_varchar('NULL') }} as hcpcs_modifier_4 - , {{ cast_string_or_varchar('NULL') }} as hcpcs_modifier_5 - , {{ cast_string_or_varchar('ordrg_prvdr_npi_num') }} as rendering_npi - , {{ cast_string_or_varchar('payto_prvdr_npi_num') }} as billing_npi - , {{ cast_string_or_varchar('NULL') }} as facility_npi + , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }} ) as hcpcs_code + , cast(NULL as {{ dbt.type_string() }} ) as hcpcs_modifier_1 + , cast(NULL as {{ dbt.type_string() }} ) as hcpcs_modifier_2 + , cast(NULL as {{ dbt.type_string() }} ) as hcpcs_modifier_3 + , 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(payto_prvdr_npi_num as {{ dbt.type_string() }} ) as billing_npi + , cast(NULL as {{ dbt.type_string() }} ) as facility_npi , cast(NULL as date) as paid_date , {{ cast_numeric('clm_line_cvrd_pd_amt') }} as paid_amount , {{ cast_numeric('NULL') }} as total_cost_amount , {{ cast_numeric('clm_line_alowd_chrg_amt') }} as allowed_amount , {{ cast_numeric('clm_line_alowd_chrg_amt') }} as charge_amount - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_type - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_1 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_2 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_3 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_4 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_5 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_6 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_7 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_8 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_9 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_10 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_11 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_12 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_13 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_14 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_15 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_16 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_17 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_18 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_19 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_20 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_21 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_22 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_23 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_24 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_25 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_1 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_2 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_3 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_4 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_5 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_6 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_7 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_8 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_9 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_10 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_11 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_12 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_13 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_14 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_15 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_16 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_17 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_18 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_19 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_20 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_21 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_22 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_23 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_24 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_25 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_type - , {{ cast_string_or_varchar('NULL') }} as procedure_code_1 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_2 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_3 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_4 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_5 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_6 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_7 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_8 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_9 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_10 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_11 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_12 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_13 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_14 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_15 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_16 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_17 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_18 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_19 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_20 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_21 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_22 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_23 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_24 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_25 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_type + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_1 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_2 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_3 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_4 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_5 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_6 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_7 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_8 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_9 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_10 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_11 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_12 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_13 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_14 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_15 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_16 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_17 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_18 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_19 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_20 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_21 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_22 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_23 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_24 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_25 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_1 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_2 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_3 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_4 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_5 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_6 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_7 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_8 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_9 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_10 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_11 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_12 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_13 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_14 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_15 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_16 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_17 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_18 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_19 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_20 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_21 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_22 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_23 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_24 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_25 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_type + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_1 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_2 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_3 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_4 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_5 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_6 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_7 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_8 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_9 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_10 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_11 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_12 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_13 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_14 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_15 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_16 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_17 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_18 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_19 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_20 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_21 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_22 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_23 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_24 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_25 , cast(NULL as date) as procedure_date_1 , cast(NULL as date) as procedure_date_2 , cast(NULL as date) as procedure_date_3 diff --git a/models/intermediate/institutional_claims.sql b/models/intermediate/institutional_claims.sql index 98ea2841..2826eb93 100644 --- a/models/intermediate/institutional_claims.sql +++ b/models/intermediate/institutional_claims.sql @@ -33,127 +33,127 @@ left join add_header_paid_amount b ) select - {{ cast_string_or_varchar('a.claim_id') }} as claim_id + cast(a.claim_id as {{ dbt.type_string() }} ) as claim_id , cast(a.claim_line_number as integer) as claim_line_number , 'institutional' as claim_type - , {{ cast_string_or_varchar('h.bene_mbi_id') }} as patient_id - , {{ cast_string_or_varchar('h.bene_mbi_id') }} as member_id + , cast(h.bene_mbi_id as {{ dbt.type_string() }} ) as patient_id + , cast(h.bene_mbi_id as {{ dbt.type_string() }} ) as member_id , {{ try_to_cast_date('h.clm_from_dt', 'YYYY-MM-DD') }} as claim_start_date , {{ try_to_cast_date('h.clm_thru_dt', 'YYYY-MM-DD') }} as claim_end_date , cast(NULL as date) as claim_line_start_date , cast(NULL as date) as claim_line_end_date , cast(NULL as date) as admission_date , cast(NULL as date) as discharge_date - , {{ cast_string_or_varchar('h.clm_admsn_src_cd') }} as admit_source_code - , {{ cast_string_or_varchar('h.clm_admsn_type_cd') }} as admit_type_code - , lpad({{ cast_string_or_varchar('h.bene_ptnt_stus_cd') }},2, '0') as discharge_disposition_code - , {{ cast_string_or_varchar('NULL') }} as place_of_service_code - , {{ cast_string_or_varchar('h.clm_bill_fac_type_cd') }} - || {{ cast_string_or_varchar('h.clm_bill_clsfctn_cd') }} - || {{ cast_string_or_varchar('h.clm_bill_freq_cd') }} + , cast(h.clm_admsn_src_cd as {{ dbt.type_string() }} ) as admit_source_code + , cast(h.clm_admsn_type_cd as {{ dbt.type_string() }} ) as admit_type_code + , lpad(cast(h.bene_ptnt_stus_cd as {{ dbt.type_string() }} ),2, '0') as discharge_disposition_code + , cast(NULL as {{ dbt.type_string() }} ) as place_of_service_code + , cast(h.clm_bill_fac_type_cd as {{ dbt.type_string() }} ) + || cast(h.clm_bill_clsfctn_cd as {{ dbt.type_string() }} ) + || cast(h.clm_bill_freq_cd as {{ dbt.type_string() }} ) as bill_type_code - , {{ cast_string_or_varchar('h.dgns_drg_cd') }} as ms_drg_code - , {{ cast_string_or_varchar('null') }} as apr_drg_code - , lpad({{ cast_string_or_varchar('d.clm_line_prod_rev_ctr_cd') }},4,'0') as revenue_center_code + , cast(h.dgns_drg_cd as {{ dbt.type_string() }} ) as ms_drg_code + , cast(null as {{ dbt.type_string() }} ) as apr_drg_code + , lpad(cast(d.clm_line_prod_rev_ctr_cd as {{ dbt.type_string() }} ),4,'0') as revenue_center_code , cast(d.clm_line_srvc_unit_qty as integer) as service_unit_quantity - , {{ cast_string_or_varchar('d.clm_line_hcpcs_cd') }} as hcpcs_code - , {{ cast_string_or_varchar('d.hcpcs_1_mdfr_cd') }} as hcpcs_modifier_1 - , {{ cast_string_or_varchar('d.hcpcs_2_mdfr_cd') }} as hcpcs_modifier_2 - , {{ cast_string_or_varchar('d.hcpcs_3_mdfr_cd') }} as hcpcs_modifier_3 - , {{ cast_string_or_varchar('d.hcpcs_4_mdfr_cd') }} as hcpcs_modifier_4 - , {{ cast_string_or_varchar('d.hcpcs_5_mdfr_cd') }} as hcpcs_modifier_5 - , {{ cast_string_or_varchar('h.atndg_prvdr_npi_num') }} as rendering_npi - , {{ cast_string_or_varchar('NULL') }} as billing_npi - , {{ cast_string_or_varchar('h.fac_prvdr_npi_num') }} as facility_npi + , cast(d.clm_line_hcpcs_cd as {{ dbt.type_string() }} ) as hcpcs_code + , cast(d.hcpcs_1_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_1 + , cast(d.hcpcs_2_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_2 + , cast(d.hcpcs_3_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_3 + , 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 billing_npi + , cast(h.fac_prvdr_npi_num as {{ dbt.type_string() }} ) as facility_npi , cast(NULL as date) as paid_date , {{ cast_numeric('a.paid_amount') }} as paid_amount , {{ cast_numeric('NULL') }} as total_cost_amount , {{ cast_numeric('NULL') }} as allowed_amount , {{ cast_numeric('h.clm_mdcr_instnl_tot_chrg_amt') }} as charge_amount , case - when {{ cast_string_or_varchar('dx.dgns_prcdr_icd_ind') }} = '0' then 'icd-10-cm' - when {{ cast_string_or_varchar('dx.dgns_prcdr_icd_ind') }} = '9' then 'icd-9-cm' - else {{ cast_string_or_varchar('dx.dgns_prcdr_icd_ind') }} + when cast(dx.dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) = '0' then 'icd-10-cm' + when cast(dx.dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) = '9' then 'icd-9-cm' + else cast(dx.dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) end as diagnosis_code_type - , {{ cast_string_or_varchar('dx.diagnosis_code_1') }} as diagnosis_code_1 - , {{ cast_string_or_varchar('dx.diagnosis_code_2') }} as diagnosis_code_2 - , {{ cast_string_or_varchar('dx.diagnosis_code_3') }} as diagnosis_code_3 - , {{ cast_string_or_varchar('dx.diagnosis_code_4') }} as diagnosis_code_4 - , {{ cast_string_or_varchar('dx.diagnosis_code_5') }} as diagnosis_code_5 - , {{ cast_string_or_varchar('dx.diagnosis_code_6') }} as diagnosis_code_6 - , {{ cast_string_or_varchar('dx.diagnosis_code_7') }} as diagnosis_code_7 - , {{ cast_string_or_varchar('dx.diagnosis_code_8') }} as diagnosis_code_8 - , {{ cast_string_or_varchar('dx.diagnosis_code_9') }} as diagnosis_code_9 - , {{ cast_string_or_varchar('dx.diagnosis_code_10') }} as diagnosis_code_10 - , {{ cast_string_or_varchar('dx.diagnosis_code_11') }} as diagnosis_code_11 - , {{ cast_string_or_varchar('dx.diagnosis_code_12') }} as diagnosis_code_12 - , {{ cast_string_or_varchar('dx.diagnosis_code_13') }} as diagnosis_code_13 - , {{ cast_string_or_varchar('dx.diagnosis_code_14') }} as diagnosis_code_14 - , {{ cast_string_or_varchar('dx.diagnosis_code_15') }} as diagnosis_code_15 - , {{ cast_string_or_varchar('dx.diagnosis_code_16') }} as diagnosis_code_16 - , {{ cast_string_or_varchar('dx.diagnosis_code_17') }} as diagnosis_code_17 - , {{ cast_string_or_varchar('dx.diagnosis_code_18') }} as diagnosis_code_18 - , {{ cast_string_or_varchar('dx.diagnosis_code_19') }} as diagnosis_code_19 - , {{ cast_string_or_varchar('dx.diagnosis_code_20') }} as diagnosis_code_20 - , {{ cast_string_or_varchar('dx.diagnosis_code_21') }} as diagnosis_code_21 - , {{ cast_string_or_varchar('dx.diagnosis_code_22') }} as diagnosis_code_22 - , {{ cast_string_or_varchar('dx.diagnosis_code_23') }} as diagnosis_code_23 - , {{ cast_string_or_varchar('dx.diagnosis_code_24') }} as diagnosis_code_24 - , {{ cast_string_or_varchar('dx.diagnosis_code_25') }} as diagnosis_code_25 - , {{ cast_string_or_varchar('dx.diagnosis_poa_1') }} as diagnosis_poa_1 - , {{ cast_string_or_varchar('dx.diagnosis_poa_2') }} as diagnosis_poa_2 - , {{ cast_string_or_varchar('dx.diagnosis_poa_3') }} as diagnosis_poa_3 - , {{ cast_string_or_varchar('dx.diagnosis_poa_4') }} as diagnosis_poa_4 - , {{ cast_string_or_varchar('dx.diagnosis_poa_5') }} as diagnosis_poa_5 - , {{ cast_string_or_varchar('dx.diagnosis_poa_6') }} as diagnosis_poa_6 - , {{ cast_string_or_varchar('dx.diagnosis_poa_7') }} as diagnosis_poa_7 - , {{ cast_string_or_varchar('dx.diagnosis_poa_8') }} as diagnosis_poa_8 - , {{ cast_string_or_varchar('dx.diagnosis_poa_9') }} as diagnosis_poa_9 - , {{ cast_string_or_varchar('dx.diagnosis_poa_10') }} as diagnosis_poa_10 - , {{ cast_string_or_varchar('dx.diagnosis_poa_11') }} as diagnosis_poa_11 - , {{ cast_string_or_varchar('dx.diagnosis_poa_12') }} as diagnosis_poa_12 - , {{ cast_string_or_varchar('dx.diagnosis_poa_13') }} as diagnosis_poa_13 - , {{ cast_string_or_varchar('dx.diagnosis_poa_14') }} as diagnosis_poa_14 - , {{ cast_string_or_varchar('dx.diagnosis_poa_15') }} as diagnosis_poa_15 - , {{ cast_string_or_varchar('dx.diagnosis_poa_16') }} as diagnosis_poa_16 - , {{ cast_string_or_varchar('dx.diagnosis_poa_17') }} as diagnosis_poa_17 - , {{ cast_string_or_varchar('dx.diagnosis_poa_18') }} as diagnosis_poa_18 - , {{ cast_string_or_varchar('dx.diagnosis_poa_19') }} as diagnosis_poa_19 - , {{ cast_string_or_varchar('dx.diagnosis_poa_20') }} as diagnosis_poa_20 - , {{ cast_string_or_varchar('dx.diagnosis_poa_21') }} as diagnosis_poa_21 - , {{ cast_string_or_varchar('dx.diagnosis_poa_22') }} as diagnosis_poa_22 - , {{ cast_string_or_varchar('dx.diagnosis_poa_23') }} as diagnosis_poa_23 - , {{ cast_string_or_varchar('dx.diagnosis_poa_24') }} as diagnosis_poa_24 - , {{ cast_string_or_varchar('dx.diagnosis_poa_25') }} as diagnosis_poa_25 + , cast(dx.diagnosis_code_1 as {{ dbt.type_string() }} ) as diagnosis_code_1 + , cast(dx.diagnosis_code_2 as {{ dbt.type_string() }} ) as diagnosis_code_2 + , cast(dx.diagnosis_code_3 as {{ dbt.type_string() }} ) as diagnosis_code_3 + , cast(dx.diagnosis_code_4 as {{ dbt.type_string() }} ) as diagnosis_code_4 + , cast(dx.diagnosis_code_5 as {{ dbt.type_string() }} ) as diagnosis_code_5 + , cast(dx.diagnosis_code_6 as {{ dbt.type_string() }} ) as diagnosis_code_6 + , cast(dx.diagnosis_code_7 as {{ dbt.type_string() }} ) as diagnosis_code_7 + , cast(dx.diagnosis_code_8 as {{ dbt.type_string() }} ) as diagnosis_code_8 + , cast(dx.diagnosis_code_9 as {{ dbt.type_string() }} ) as diagnosis_code_9 + , cast(dx.diagnosis_code_10 as {{ dbt.type_string() }} ) as diagnosis_code_10 + , cast(dx.diagnosis_code_11 as {{ dbt.type_string() }} ) as diagnosis_code_11 + , cast(dx.diagnosis_code_12 as {{ dbt.type_string() }} ) as diagnosis_code_12 + , cast(dx.diagnosis_code_13 as {{ dbt.type_string() }} ) as diagnosis_code_13 + , cast(dx.diagnosis_code_14 as {{ dbt.type_string() }} ) as diagnosis_code_14 + , cast(dx.diagnosis_code_15 as {{ dbt.type_string() }} ) as diagnosis_code_15 + , cast(dx.diagnosis_code_16 as {{ dbt.type_string() }} ) as diagnosis_code_16 + , cast(dx.diagnosis_code_17 as {{ dbt.type_string() }} ) as diagnosis_code_17 + , cast(dx.diagnosis_code_18 as {{ dbt.type_string() }} ) as diagnosis_code_18 + , cast(dx.diagnosis_code_19 as {{ dbt.type_string() }} ) as diagnosis_code_19 + , cast(dx.diagnosis_code_20 as {{ dbt.type_string() }} ) as diagnosis_code_20 + , cast(dx.diagnosis_code_21 as {{ dbt.type_string() }} ) as diagnosis_code_21 + , cast(dx.diagnosis_code_22 as {{ dbt.type_string() }} ) as diagnosis_code_22 + , cast(dx.diagnosis_code_23 as {{ dbt.type_string() }} ) as diagnosis_code_23 + , cast(dx.diagnosis_code_24 as {{ dbt.type_string() }} ) as diagnosis_code_24 + , cast(dx.diagnosis_code_25 as {{ dbt.type_string() }} ) as diagnosis_code_25 + , cast(dx.diagnosis_poa_1 as {{ dbt.type_string() }} ) as diagnosis_poa_1 + , cast(dx.diagnosis_poa_2 as {{ dbt.type_string() }} ) as diagnosis_poa_2 + , cast(dx.diagnosis_poa_3 as {{ dbt.type_string() }} ) as diagnosis_poa_3 + , cast(dx.diagnosis_poa_4 as {{ dbt.type_string() }} ) as diagnosis_poa_4 + , cast(dx.diagnosis_poa_5 as {{ dbt.type_string() }} ) as diagnosis_poa_5 + , cast(dx.diagnosis_poa_6 as {{ dbt.type_string() }} ) as diagnosis_poa_6 + , cast(dx.diagnosis_poa_7 as {{ dbt.type_string() }} ) as diagnosis_poa_7 + , cast(dx.diagnosis_poa_8 as {{ dbt.type_string() }} ) as diagnosis_poa_8 + , cast(dx.diagnosis_poa_9 as {{ dbt.type_string() }} ) as diagnosis_poa_9 + , cast(dx.diagnosis_poa_10 as {{ dbt.type_string() }} ) as diagnosis_poa_10 + , cast(dx.diagnosis_poa_11 as {{ dbt.type_string() }} ) as diagnosis_poa_11 + , cast(dx.diagnosis_poa_12 as {{ dbt.type_string() }} ) as diagnosis_poa_12 + , cast(dx.diagnosis_poa_13 as {{ dbt.type_string() }} ) as diagnosis_poa_13 + , cast(dx.diagnosis_poa_14 as {{ dbt.type_string() }} ) as diagnosis_poa_14 + , cast(dx.diagnosis_poa_15 as {{ dbt.type_string() }} ) as diagnosis_poa_15 + , cast(dx.diagnosis_poa_16 as {{ dbt.type_string() }} ) as diagnosis_poa_16 + , cast(dx.diagnosis_poa_17 as {{ dbt.type_string() }} ) as diagnosis_poa_17 + , cast(dx.diagnosis_poa_18 as {{ dbt.type_string() }} ) as diagnosis_poa_18 + , cast(dx.diagnosis_poa_19 as {{ dbt.type_string() }} ) as diagnosis_poa_19 + , cast(dx.diagnosis_poa_20 as {{ dbt.type_string() }} ) as diagnosis_poa_20 + , cast(dx.diagnosis_poa_21 as {{ dbt.type_string() }} ) as diagnosis_poa_21 + , cast(dx.diagnosis_poa_22 as {{ dbt.type_string() }} ) as diagnosis_poa_22 + , cast(dx.diagnosis_poa_23 as {{ dbt.type_string() }} ) as diagnosis_poa_23 + , cast(dx.diagnosis_poa_24 as {{ dbt.type_string() }} ) as diagnosis_poa_24 + , cast(dx.diagnosis_poa_25 as {{ dbt.type_string() }} ) as diagnosis_poa_25 , case - when {{ cast_string_or_varchar('px.dgns_prcdr_icd_ind') }} = '0' then 'icd-10-pcs' - when {{ cast_string_or_varchar('px.dgns_prcdr_icd_ind') }} = '9' then 'icd-9-pcs' - else {{ cast_string_or_varchar('px.dgns_prcdr_icd_ind') }} end procedure_code_type - , {{ cast_string_or_varchar('px.procedure_code_1') }} as procedure_code_1 - , {{ cast_string_or_varchar('px.procedure_code_2') }} as procedure_code_2 - , {{ cast_string_or_varchar('px.procedure_code_3') }} as procedure_code_3 - , {{ cast_string_or_varchar('px.procedure_code_4') }} as procedure_code_4 - , {{ cast_string_or_varchar('px.procedure_code_5') }} as procedure_code_5 - , {{ cast_string_or_varchar('px.procedure_code_6') }} as procedure_code_6 - , {{ cast_string_or_varchar('px.procedure_code_7') }} as procedure_code_7 - , {{ cast_string_or_varchar('px.procedure_code_8') }} as procedure_code_8 - , {{ cast_string_or_varchar('px.procedure_code_9') }} as procedure_code_9 - , {{ cast_string_or_varchar('px.procedure_code_10') }} as procedure_code_10 - , {{ cast_string_or_varchar('px.procedure_code_11') }} as procedure_code_11 - , {{ cast_string_or_varchar('px.procedure_code_12') }} as procedure_code_12 - , {{ cast_string_or_varchar('px.procedure_code_13') }} as procedure_code_13 - , {{ cast_string_or_varchar('px.procedure_code_14') }} as procedure_code_14 - , {{ cast_string_or_varchar('px.procedure_code_15') }} as procedure_code_15 - , {{ cast_string_or_varchar('px.procedure_code_16') }} as procedure_code_16 - , {{ cast_string_or_varchar('px.procedure_code_17') }} as procedure_code_17 - , {{ cast_string_or_varchar('px.procedure_code_18') }} as procedure_code_18 - , {{ cast_string_or_varchar('px.procedure_code_19') }} as procedure_code_19 - , {{ cast_string_or_varchar('px.procedure_code_20') }} as procedure_code_20 - , {{ cast_string_or_varchar('px.procedure_code_21') }} as procedure_code_21 - , {{ cast_string_or_varchar('px.procedure_code_22') }} as procedure_code_22 - , {{ cast_string_or_varchar('px.procedure_code_23') }} as procedure_code_23 - , {{ cast_string_or_varchar('px.procedure_code_24') }} as procedure_code_24 - , {{ cast_string_or_varchar('px.procedure_code_25') }} as procedure_code_25 + when cast(px.dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) = '0' then 'icd-10-pcs' + when cast(px.dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) = '9' then 'icd-9-pcs' + else cast(px.dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) end procedure_code_type + , cast(px.procedure_code_1 as {{ dbt.type_string() }} ) as procedure_code_1 + , cast(px.procedure_code_2 as {{ dbt.type_string() }} ) as procedure_code_2 + , cast(px.procedure_code_3 as {{ dbt.type_string() }} ) as procedure_code_3 + , cast(px.procedure_code_4 as {{ dbt.type_string() }} ) as procedure_code_4 + , cast(px.procedure_code_5 as {{ dbt.type_string() }} ) as procedure_code_5 + , cast(px.procedure_code_6 as {{ dbt.type_string() }} ) as procedure_code_6 + , cast(px.procedure_code_7 as {{ dbt.type_string() }} ) as procedure_code_7 + , cast(px.procedure_code_8 as {{ dbt.type_string() }} ) as procedure_code_8 + , cast(px.procedure_code_9 as {{ dbt.type_string() }} ) as procedure_code_9 + , cast(px.procedure_code_10 as {{ dbt.type_string() }} ) as procedure_code_10 + , cast(px.procedure_code_11 as {{ dbt.type_string() }} ) as procedure_code_11 + , cast(px.procedure_code_12 as {{ dbt.type_string() }} ) as procedure_code_12 + , cast(px.procedure_code_13 as {{ dbt.type_string() }} ) as procedure_code_13 + , cast(px.procedure_code_14 as {{ dbt.type_string() }} ) as procedure_code_14 + , cast(px.procedure_code_15 as {{ dbt.type_string() }} ) as procedure_code_15 + , cast(px.procedure_code_16 as {{ dbt.type_string() }} ) as procedure_code_16 + , cast(px.procedure_code_17 as {{ dbt.type_string() }} ) as procedure_code_17 + , cast(px.procedure_code_18 as {{ dbt.type_string() }} ) as procedure_code_18 + , cast(px.procedure_code_19 as {{ dbt.type_string() }} ) as procedure_code_19 + , cast(px.procedure_code_20 as {{ dbt.type_string() }} ) as procedure_code_20 + , cast(px.procedure_code_21 as {{ dbt.type_string() }} ) as procedure_code_21 + , cast(px.procedure_code_22 as {{ dbt.type_string() }} ) as procedure_code_22 + , cast(px.procedure_code_23 as {{ dbt.type_string() }} ) as procedure_code_23 + , cast(px.procedure_code_24 as {{ dbt.type_string() }} ) as procedure_code_24 + , cast(px.procedure_code_25 as {{ dbt.type_string() }} ) as procedure_code_25 , {{ try_to_cast_date('px.procedure_date_1', 'YYYY-MM-DD') }} as procedure_date_1 , {{ try_to_cast_date('px.procedure_date_2', 'YYYY-MM-DD') }} as procedure_date_2 , {{ try_to_cast_date('px.procedure_date_3', 'YYYY-MM-DD') }} as procedure_date_3 @@ -187,6 +187,6 @@ 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_string_or_varchar('a.claim_id') }} = {{ cast_string_or_varchar('px.cur_clm_uniq_id') }} + 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_string_or_varchar('a.claim_id') }} = {{ cast_string_or_varchar('dx.cur_clm_uniq_id') }} \ No newline at end of file + 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 c344218f..6a3a4ad7 100644 --- a/models/intermediate/physician_claims.sql +++ b/models/intermediate/physician_claims.sql @@ -1,118 +1,118 @@ select - {{ cast_string_or_varchar('cur_clm_uniq_id') }} as claim_id + cast(cur_clm_uniq_id as {{ dbt.type_string() }} ) as claim_id , cast(clm_line_num as integer) as claim_line_number , 'professional' as claim_type - , {{ cast_string_or_varchar('bene_mbi_id') }} as patient_id - , {{ cast_string_or_varchar('bene_mbi_id') }} as member_id + , cast(bene_mbi_id as {{ dbt.type_string() }} ) as patient_id + , cast(bene_mbi_id as {{ dbt.type_string() }} ) as member_id , {{ try_to_cast_date('clm_from_dt', 'YYYY-MM-DD') }} as claim_start_date , {{ try_to_cast_date('clm_thru_dt', 'YYYY-MM-DD') }} as claim_end_date , {{ try_to_cast_date('clm_line_from_dt', 'YYYY-MM-DD') }} as claim_line_start_date , {{ try_to_cast_date('clm_line_thru_dt', 'YYYY-MM-DD') }} as claim_line_end_date , cast(NULL as date) as admission_date , cast(NULL as date) as discharge_date - , {{ cast_string_or_varchar('NULL') }} as admit_source_code - , {{ cast_string_or_varchar('NULL') }} as admit_type_code - , {{ cast_string_or_varchar('NULL') }} as discharge_disposition_code - , {{ cast_string_or_varchar('clm_pos_cd') }} as place_of_service_code - , {{ cast_string_or_varchar('NULL') }} as bill_type_code - , {{ cast_string_or_varchar('NULL') }} as ms_drg_code - , {{ cast_string_or_varchar('NULL') }} as apr_drg_code - , {{ cast_string_or_varchar('NULL') }} as revenue_center_code - , {{ cast_numeric('clm_line_srvc_unit_qty') }} as service_unit_quantity - , {{ cast_string_or_varchar('clm_line_hcpcs_cd') }} as hcpcs_code - , {{ cast_string_or_varchar('hcpcs_1_mdfr_cd') }} as hcpcs_modifier_1 - , {{ cast_string_or_varchar('hcpcs_2_mdfr_cd') }} as hcpcs_modifier_2 - , {{ cast_string_or_varchar('hcpcs_3_mdfr_cd') }} as hcpcs_modifier_3 - , {{ cast_string_or_varchar('hcpcs_4_mdfr_cd') }} as hcpcs_modifier_4 - , {{ cast_string_or_varchar('hcpcs_5_mdfr_cd') }} as hcpcs_modifier_5 - , {{ cast_string_or_varchar('rndrg_prvdr_npi_num') }} as rendering_npi - , {{ cast_string_or_varchar('NULL') }} as billing_npi - , {{ cast_string_or_varchar('NULL') }} as facility_npi + , cast(NULL as {{ dbt.type_string() }} ) as admit_source_code + , cast(NULL as {{ dbt.type_string() }} ) as admit_type_code + , cast(NULL as {{ dbt.type_string() }} ) as discharge_disposition_code + , cast(clm_pos_cd as {{ dbt.type_string() }} ) as place_of_service_code + , cast(NULL as {{ dbt.type_string() }} ) as bill_type_code + , cast(NULL as {{ dbt.type_string() }} ) as ms_drg_code + , cast(NULL as {{ dbt.type_string() }} ) as apr_drg_code + , cast(NULL as {{ dbt.type_string() }} ) as revenue_center_code + , cast(clm_line_srvc_unit_qty as integer) as service_unit_quantity + , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }} ) as hcpcs_code + , cast(hcpcs_1_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_1 + , cast(hcpcs_2_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_2 + , cast(hcpcs_3_mdfr_cd as {{ dbt.type_string() }} ) as hcpcs_modifier_3 + , 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(NULL as {{ dbt.type_string() }} ) as billing_npi + , cast(NULL as {{ dbt.type_string() }} ) as facility_npi , cast(NULL as date) as paid_date , {{ cast_numeric('clm_line_cvrd_pd_amt') }} as paid_amount , {{ cast_numeric('NULL') }} as total_cost_amount , {{ cast_numeric('clm_line_alowd_chrg_amt') }} as allowed_amount , {{ cast_numeric('clm_line_alowd_chrg_amt') }} as charge_amount , case - when {{ cast_string_or_varchar('dgns_prcdr_icd_ind') }} = '0' then 'icd-10-pcs' - when {{ cast_string_or_varchar('dgns_prcdr_icd_ind') }} = '9' then 'icd-9-pcs' - else {{ cast_string_or_varchar('dgns_prcdr_icd_ind') }} end as diagnosis_code_type - , {{ cast_string_or_varchar('clm_dgns_1_cd') }} as diagnosis_code_1 - , {{ cast_string_or_varchar('clm_dgns_2_cd') }} as diagnosis_code_2 - , {{ cast_string_or_varchar('clm_dgns_3_cd') }} as diagnosis_code_3 - , {{ cast_string_or_varchar('clm_dgns_4_cd') }} as diagnosis_code_4 - , {{ cast_string_or_varchar('clm_dgns_5_cd') }} as diagnosis_code_5 - , {{ cast_string_or_varchar('clm_dgns_6_cd') }} as diagnosis_code_6 - , {{ cast_string_or_varchar('clm_dgns_7_cd') }} as diagnosis_code_7 - , {{ cast_string_or_varchar('clm_dgns_8_cd') }} as diagnosis_code_8 - , {{ cast_string_or_varchar('clm_dgns_9_cd') }} as diagnosis_code_9 - , {{ cast_string_or_varchar('clm_dgns_10_cd') }} as diagnosis_code_10 - , {{ cast_string_or_varchar('clm_dgns_11_cd') }} as diagnosis_code_11 - , {{ cast_string_or_varchar('clm_dgns_12_cd') }} as diagnosis_code_12 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_13 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_14 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_15 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_16 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_17 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_18 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_19 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_20 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_21 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_22 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_23 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_24 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_code_25 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_1 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_2 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_3 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_4 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_5 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_6 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_7 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_8 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_9 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_10 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_11 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_12 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_13 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_14 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_15 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_16 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_17 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_18 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_19 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_20 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_21 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_22 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_23 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_24 - , {{ cast_string_or_varchar('NULL') }} as diagnosis_poa_25 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_type - , {{ cast_string_or_varchar('NULL') }} as procedure_code_1 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_2 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_3 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_4 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_5 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_6 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_7 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_8 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_9 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_10 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_11 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_12 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_13 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_14 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_15 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_16 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_17 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_18 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_19 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_20 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_21 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_22 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_23 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_24 - , {{ cast_string_or_varchar('NULL') }} as procedure_code_25 + when cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) = '0' then 'icd-10-pcs' + when cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) = '9' then 'icd-9-pcs' + else cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }} ) end as diagnosis_code_type + , cast(clm_dgns_1_cd as {{ dbt.type_string() }} ) as diagnosis_code_1 + , cast(clm_dgns_2_cd as {{ dbt.type_string() }} ) as diagnosis_code_2 + , cast(clm_dgns_3_cd as {{ dbt.type_string() }} ) as diagnosis_code_3 + , cast(clm_dgns_4_cd as {{ dbt.type_string() }} ) as diagnosis_code_4 + , cast(clm_dgns_5_cd as {{ dbt.type_string() }} ) as diagnosis_code_5 + , cast(clm_dgns_6_cd as {{ dbt.type_string() }} ) as diagnosis_code_6 + , cast(clm_dgns_7_cd as {{ dbt.type_string() }} ) as diagnosis_code_7 + , cast(clm_dgns_8_cd as {{ dbt.type_string() }} ) as diagnosis_code_8 + , cast(clm_dgns_9_cd as {{ dbt.type_string() }} ) as diagnosis_code_9 + , cast(clm_dgns_10_cd as {{ dbt.type_string() }} ) as diagnosis_code_10 + , cast(clm_dgns_11_cd as {{ dbt.type_string() }} ) as diagnosis_code_11 + , cast(clm_dgns_12_cd as {{ dbt.type_string() }} ) as diagnosis_code_12 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_13 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_14 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_15 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_16 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_17 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_18 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_19 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_20 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_21 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_22 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_23 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_24 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_code_25 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_1 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_2 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_3 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_4 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_5 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_6 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_7 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_8 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_9 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_10 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_11 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_12 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_13 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_14 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_15 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_16 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_17 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_18 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_19 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_20 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_21 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_22 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_23 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_24 + , cast(NULL as {{ dbt.type_string() }} ) as diagnosis_poa_25 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_type + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_1 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_2 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_3 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_4 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_5 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_6 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_7 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_8 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_9 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_10 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_11 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_12 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_13 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_14 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_15 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_16 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_17 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_18 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_19 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_20 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_21 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_22 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_23 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_24 + , cast(NULL as {{ dbt.type_string() }} ) as procedure_code_25 , cast(NULL as date) as procedure_date_1 , cast(NULL as date) as procedure_date_2 , cast(NULL as date) as procedure_date_3 diff --git a/models/staging/base_parta_diagnosis_code.sql b/models/staging/base_parta_diagnosis_code.sql index 273645f8..4fab0d00 100644 --- a/models/staging/base_parta_diagnosis_code.sql +++ b/models/staging/base_parta_diagnosis_code.sql @@ -1,16 +1,16 @@ select - {{ cast_string_or_varchar('cur_clm_uniq_id') }} as cur_clm_uniq_id - , {{ cast_string_or_varchar('bene_mbi_id') }} as bene_mbi_id - , {{ cast_string_or_varchar('bene_hic_num') }} as bene_hic_num - , {{ cast_string_or_varchar('clm_type_cd') }} as clm_type_cd - , {{ cast_string_or_varchar('clm_prod_type_cd') }} as clm_prod_type_cd - , {{ cast_string_or_varchar('clm_val_sqnc_num') }} as clm_val_sqnc_num - , {{ cast_string_or_varchar('clm_dgns_cd') }} as clm_dgns_cd - , {{ cast_string_or_varchar('bene_eqtbl_bic_hicn_num') }} as bene_eqtbl_bic_hicn_num - , {{ cast_string_or_varchar('prvdr_oscar_num') }} as prvdr_oscar_num - , {{ cast_string_or_varchar('clm_from_dt') }} as clm_from_dt - , {{ cast_string_or_varchar('clm_thru_dt') }} as clm_thru_dt - , {{ cast_string_or_varchar('clm_poa_ind') }} as clm_poa_ind - , {{ cast_string_or_varchar('dgns_prcdr_icd_ind') }} as dgns_prcdr_icd_ind + 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 index 28a07b45..e48904ee 100644 --- a/models/staging/base_parta_procedure_code.sql +++ b/models/staging/base_parta_procedure_code.sql @@ -1,15 +1,15 @@ select - {{ cast_string_or_varchar('cur_clm_uniq_id') }} as cur_clm_uniq_id - , {{ cast_string_or_varchar('bene_mbi_id') }} as bene_mbi_id - , {{ cast_string_or_varchar('bene_hic_num') }} as bene_hic_num - , {{ cast_string_or_varchar('clm_type_cd') }} as clm_type_cd - , {{ cast_string_or_varchar('clm_val_sqnc_num') }} as clm_val_sqnc_num - , {{ cast_string_or_varchar('clm_prcdr_cd') }} as clm_prcdr_cd - , {{ cast_string_or_varchar('clm_prcdr_prfrm_dt') }} as clm_prcdr_prfrm_dt - , {{ cast_string_or_varchar('bene_eqtbl_bic_hicn_num') }} as bene_eqtbl_bic_hicn_num - , {{ cast_string_or_varchar('prvdr_oscar_num') }} as prvdr_oscar_num - , {{ cast_string_or_varchar('clm_from_dt') }} as clm_from_dt - , {{ cast_string_or_varchar('clm_thru_dt') }} as clm_thru_dt - , {{ cast_string_or_varchar('dgns_prcdr_icd_ind') }} as dgns_prcdr_icd_ind + 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/packages.yml b/packages.yml index 453b4099..8faed53f 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.3.0","<1.0.0"] + version: [">=0.5.0","<1.0.0"] \ No newline at end of file