From da384994c8991f9e11ee8a4cd088b72142b25b62 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 09:47:31 -0600 Subject: [PATCH 01/18] Add staging models --- models/staging/base_parta_diagnosis_code.sql | 16 ------ models/staging/base_parta_procedure_code.sql | 15 ------ .../staging/stg_beneficiary_demographics.sql | 36 +++++++++++++ models/staging/stg_parta_claims_header.sql | 41 ++++++++++++++ ...stg_parta_claims_revenue_center_detail.sql | 26 +++++++++ models/staging/stg_parta_diagnosis_code.sql | 17 ++++++ models/staging/stg_parta_procedure_code.sql | 16 ++++++ models/staging/stg_partb_dme.sql | 29 ++++++++++ models/staging/stg_partb_physicians.sql | 53 +++++++++++++++++++ 9 files changed, 218 insertions(+), 31 deletions(-) delete mode 100644 models/staging/base_parta_diagnosis_code.sql delete mode 100644 models/staging/base_parta_procedure_code.sql create mode 100644 models/staging/stg_beneficiary_demographics.sql create mode 100644 models/staging/stg_parta_claims_header.sql create mode 100644 models/staging/stg_parta_claims_revenue_center_detail.sql create mode 100644 models/staging/stg_parta_diagnosis_code.sql create mode 100644 models/staging/stg_parta_procedure_code.sql create mode 100644 models/staging/stg_partb_dme.sql create mode 100644 models/staging/stg_partb_physicians.sql 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..e6cbb610 --- /dev/null +++ b/models/staging/stg_beneficiary_demographics.sql @@ -0,0 +1,36 @@ +select + cast(bene_mbi_id as {{ dbt.type_string() }}) as bene_mbi_id + , cast(bene_member_month as {{ dbt.type_string() }}) as bene_member_month + , cast(bene_hic_num as {{ dbt.type_string() }}) as bene_hic_num + , cast(bene_fips_state_cd as {{ dbt.type_string() }}) as bene_fips_state_cd + , cast(bene_fips_cnty_cd as {{ dbt.type_string() }}) as bene_fips_cnty_cd + , cast(bene_zip_cd as {{ dbt.type_string() }}) as bene_zip_cd + , cast(bene_dob as {{ dbt.type_string() }}) as bene_dob + , cast(bene_sex_cd as {{ dbt.type_string() }}) as bene_sex_cd + , cast(bene_race_cd as {{ dbt.type_string() }}) as bene_race_cd + , cast(bene_age as {{ dbt.type_string() }}) as bene_age + , cast(bene_mdcr_stus_cd as {{ dbt.type_string() }}) as bene_mdcr_stus_cd + , cast(bene_dual_stus_cd as {{ dbt.type_string() }}) as bene_dual_stus_cd + , cast(bene_death_dt as {{ dbt.type_string() }}) as bene_death_dt + , cast(bene_rng_bgn_dt as {{ dbt.type_string() }}) as bene_rng_bgn_dt + , cast(bene_rng_end_dt as {{ dbt.type_string() }}) as bene_rng_end_dt + , cast(bene_1st_name as {{ dbt.type_string() }}) as bene_1st_name + , cast(bene_midl_name as {{ dbt.type_string() }}) as bene_midl_name + , cast(bene_last_name as {{ dbt.type_string() }}) as bene_last_name + , cast(bene_orgnl_entlmt_rsn_cd as {{ dbt.type_string() }}) as bene_orgnl_entlmt_rsn_cd + , cast(bene_entlmt_buyin_ind as {{ dbt.type_string() }}) as bene_entlmt_buyin_ind + , cast(bene_part_a_enrlmt_bgn_dt as {{ dbt.type_string() }}) as bene_part_a_enrlmt_bgn_dt + , cast(bene_part_b_enrlmt_bgn_dt as {{ dbt.type_string() }}) as bene_part_b_enrlmt_bgn_dt + , cast(bene_line_1_adr as {{ dbt.type_string() }}) as bene_line_1_adr + , cast(bene_line_2_adr as {{ dbt.type_string() }}) as bene_line_2_adr + , cast(bene_line_3_adr as {{ dbt.type_string() }}) as bene_line_3_adr + , cast(bene_line_4_adr as {{ dbt.type_string() }}) as bene_line_4_adr + , cast(bene_line_5_adr as {{ dbt.type_string() }}) as bene_line_5_adr + , cast(bene_line_6_adr as {{ dbt.type_string() }}) as bene_line_6_adr + , cast(geo_zip_plc_name as {{ dbt.type_string() }}) as geo_zip_plc_name + , cast(geo_usps_state_cd as {{ dbt.type_string() }}) as geo_usps_state_cd + , cast(geo_zip5_cd as {{ dbt.type_string() }}) as geo_zip5_cd + , cast(geo_zip4_cd as {{ dbt.type_string() }}) as geo_zip4_cd + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as 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..0e738a1c --- /dev/null +++ b/models/staging/stg_parta_claims_header.sql @@ -0,0 +1,41 @@ +select + cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id + , cast(prvdr_oscar_num as {{ dbt.type_string() }}) as prvdr_oscar_num + , 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_from_dt as {{ dbt.type_string() }}) as clm_from_dt + , cast(clm_thru_dt as {{ dbt.type_string() }}) as clm_thru_dt + , cast(clm_bill_fac_type_cd as {{ dbt.type_string() }}) as clm_bill_fac_type_cd + , cast(clm_bill_clsfctn_cd as {{ dbt.type_string() }}) as clm_bill_clsfctn_cd + , cast(prncpl_dgns_cd as {{ dbt.type_string() }}) as prncpl_dgns_cd + , cast(admtg_dgns_cd as {{ dbt.type_string() }}) as admtg_dgns_cd + , cast(clm_mdcr_npmt_rsn_cd as {{ dbt.type_string() }}) as clm_mdcr_npmt_rsn_cd + , cast(clm_pmt_amt as {{ dbt.type_string() }}) as clm_pmt_amt + , cast(clm_nch_prmry_pyr_cd as {{ dbt.type_string() }}) as clm_nch_prmry_pyr_cd + , cast(prvdr_fac_fips_st_cd as {{ dbt.type_string() }}) as prvdr_fac_fips_st_cd + , cast(bene_ptnt_stus_cd as {{ dbt.type_string() }}) as bene_ptnt_stus_cd + , cast(dgns_drg_cd as {{ dbt.type_string() }}) as dgns_drg_cd + , cast(clm_op_srvc_type_cd as {{ dbt.type_string() }}) as clm_op_srvc_type_cd + , cast(fac_prvdr_npi_num as {{ dbt.type_string() }}) as fac_prvdr_npi_num + , cast(oprtg_prvdr_npi_num as {{ dbt.type_string() }}) as oprtg_prvdr_npi_num + , cast(atndg_prvdr_npi_num as {{ dbt.type_string() }}) as atndg_prvdr_npi_num + , cast(othr_prvdr_npi_num as {{ dbt.type_string() }}) as othr_prvdr_npi_num + , cast(clm_adjsmt_type_cd as {{ dbt.type_string() }}) as clm_adjsmt_type_cd + , cast(clm_efctv_dt as {{ dbt.type_string() }}) as clm_efctv_dt + , cast(clm_idr_ld_dt as {{ dbt.type_string() }}) as clm_idr_ld_dt + , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }}) as bene_eqtbl_bic_hicn_num + , cast(clm_admsn_type_cd as {{ dbt.type_string() }}) as clm_admsn_type_cd + , cast(clm_admsn_src_cd as {{ dbt.type_string() }}) as clm_admsn_src_cd + , cast(clm_bill_freq_cd as {{ dbt.type_string() }}) as clm_bill_freq_cd + , cast(clm_query_cd as {{ dbt.type_string() }}) as clm_query_cd + , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }}) as dgns_prcdr_icd_ind + , cast(clm_mdcr_instnl_tot_chrg_amt as {{ dbt.type_string() }}) as clm_mdcr_instnl_tot_chrg_amt + , cast(clm_mdcr_ip_pps_cptl_ime_amt as {{ dbt.type_string() }}) as clm_mdcr_ip_pps_cptl_ime_amt + , cast(clm_oprtnl_ime_amt as {{ dbt.type_string() }}) as clm_oprtnl_ime_amt + , cast(clm_mdcr_ip_pps_dsprprtnt_amt as {{ dbt.type_string() }}) as clm_mdcr_ip_pps_dsprprtnt_amt + , cast(clm_hipps_uncompd_care_amt as {{ dbt.type_string() }}) as clm_hipps_uncompd_care_amt + , cast(clm_oprtnl_dsprtnt_amt as {{ dbt.type_string() }}) as clm_oprtnl_dsprtnt_amt + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as 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..d00c924f --- /dev/null +++ b/models/staging/stg_parta_claims_revenue_center_detail.sql @@ -0,0 +1,26 @@ +select + cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id + , cast(clm_line_num as {{ dbt.type_string() }}) as clm_line_num + , 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_line_from_dt as {{ dbt.type_string() }}) as clm_line_from_dt + , cast(clm_line_thru_dt as {{ dbt.type_string() }}) as clm_line_thru_dt + , cast(clm_line_prod_rev_ctr_cd as {{ dbt.type_string() }}) as clm_line_prod_rev_ctr_cd + , cast(clm_line_instnl_rev_ctr_dt as {{ dbt.type_string() }}) as clm_line_instnl_rev_ctr_dt + , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }}) as clm_line_hcpcs_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_line_srvc_unit_qty as {{ dbt.type_string() }}) as clm_line_srvc_unit_qty + , cast(clm_line_cvrd_pd_amt as {{ dbt.type_string() }}) as clm_line_cvrd_pd_amt + , cast(hcpcs_1_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_1_mdfr_cd + , cast(hcpcs_2_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_2_mdfr_cd + , cast(hcpcs_3_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_3_mdfr_cd + , cast(hcpcs_4_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_4_mdfr_cd + , cast(hcpcs_5_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_5_mdfr_cd + , cast(clm_rev_apc_hipps_cd as {{ dbt.type_string() }}) as clm_rev_apc_hipps_cd + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as 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..b95e48be --- /dev/null +++ b/models/staging/stg_parta_diagnosis_code.sql @@ -0,0 +1,17 @@ +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 + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime +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..30a2e7a4 --- /dev/null +++ b/models/staging/stg_parta_procedure_code.sql @@ -0,0 +1,16 @@ +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 + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime +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..1717a606 --- /dev/null +++ b/models/staging/stg_partb_dme.sql @@ -0,0 +1,29 @@ +select + cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id + , cast(clm_line_num as {{ dbt.type_string() }}) as clm_line_num + , 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_from_dt as {{ dbt.type_string() }}) as clm_from_dt + , cast(clm_thru_dt as {{ dbt.type_string() }}) as clm_thru_dt + , cast(clm_fed_type_srvc_cd as {{ dbt.type_string() }}) as clm_fed_type_srvc_cd + , cast(clm_pos_cd as {{ dbt.type_string() }}) as clm_pos_cd + , cast(clm_line_from_dt as {{ dbt.type_string() }}) as clm_line_from_dt + , cast(clm_line_thru_dt as {{ dbt.type_string() }}) as clm_line_thru_dt + , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }}) as clm_line_hcpcs_cd + , cast(clm_line_cvrd_pd_amt as {{ dbt.type_string() }}) as clm_line_cvrd_pd_amt + , cast(clm_prmry_pyr_cd as {{ dbt.type_string() }}) as clm_prmry_pyr_cd + , cast(payto_prvdr_npi_num as {{ dbt.type_string() }}) as payto_prvdr_npi_num + , cast(ordrg_prvdr_npi_num as {{ dbt.type_string() }}) as ordrg_prvdr_npi_num + , cast(clm_carr_pmt_dnl_cd as {{ dbt.type_string() }}) as clm_carr_pmt_dnl_cd + , cast(clm_prcsg_ind_cd as {{ dbt.type_string() }}) as clm_prcsg_ind_cd + , cast(clm_adjsmt_type_cd as {{ dbt.type_string() }}) as clm_adjsmt_type_cd + , cast(clm_efctv_dt as {{ dbt.type_string() }}) as clm_efctv_dt + , cast(clm_idr_ld_dt as {{ dbt.type_string() }}) as clm_idr_ld_dt + , cast(clm_cntl_num as {{ dbt.type_string() }}) as clm_cntl_num + , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }}) as bene_eqtbl_bic_hicn_num + , cast(clm_line_alowd_chrg_amt as {{ dbt.type_string() }}) as clm_line_alowd_chrg_amt + , cast(clm_disp_cd as {{ dbt.type_string() }}) as clm_disp_cd + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as 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..51dcd520 --- /dev/null +++ b/models/staging/stg_partb_physicians.sql @@ -0,0 +1,53 @@ +select + cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id + , cast(clm_line_num as {{ dbt.type_string() }}) as clm_line_num + , 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_from_dt as {{ dbt.type_string() }}) as clm_from_dt + , cast(clm_thru_dt as {{ dbt.type_string() }}) as clm_thru_dt + , cast(rndrg_prvdr_type_cd as {{ dbt.type_string() }}) as rndrg_prvdr_type_cd + , cast(rndrg_prvdr_fips_st_cd as {{ dbt.type_string() }}) as rndrg_prvdr_fips_st_cd + , cast(clm_prvdr_spclty_cd as {{ dbt.type_string() }}) as clm_prvdr_spclty_cd + , cast(clm_fed_type_srvc_cd as {{ dbt.type_string() }}) as clm_fed_type_srvc_cd + , cast(clm_pos_cd as {{ dbt.type_string() }}) as clm_pos_cd + , cast(clm_line_from_dt as {{ dbt.type_string() }}) as clm_line_from_dt + , cast(clm_line_thru_dt as {{ dbt.type_string() }}) as clm_line_thru_dt + , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }}) as clm_line_hcpcs_cd + , cast(clm_line_cvrd_pd_amt as {{ dbt.type_string() }}) as clm_line_cvrd_pd_amt + , cast(clm_line_prmry_pyr_cd as {{ dbt.type_string() }}) as clm_line_prmry_pyr_cd + , cast(clm_line_dgns_cd as {{ dbt.type_string() }}) as clm_line_dgns_cd + , cast(clm_rndrg_prvdr_tax_num as {{ dbt.type_string() }}) as clm_rndrg_prvdr_tax_num + , cast(rndrg_prvdr_npi_num as {{ dbt.type_string() }}) as rndrg_prvdr_npi_num + , cast(clm_carr_pmt_dnl_cd as {{ dbt.type_string() }}) as clm_carr_pmt_dnl_cd + , cast(clm_prcsg_ind_cd as {{ dbt.type_string() }}) as clm_prcsg_ind_cd + , cast(clm_adjsmt_type_cd as {{ dbt.type_string() }}) as clm_adjsmt_type_cd + , cast(clm_efctv_dt as {{ dbt.type_string() }}) as clm_efctv_dt + , cast(clm_idr_ld_dt as {{ dbt.type_string() }}) as clm_idr_ld_dt + , cast(clm_cntl_num as {{ dbt.type_string() }}) as clm_cntl_num + , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }}) as bene_eqtbl_bic_hicn_num + , cast(clm_line_alowd_chrg_amt as {{ dbt.type_string() }}) as clm_line_alowd_chrg_amt + , cast(clm_line_srvc_unit_qty as {{ dbt.type_string() }}) as clm_line_srvc_unit_qty + , cast(hcpcs_1_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_1_mdfr_cd + , cast(hcpcs_2_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_2_mdfr_cd + , cast(hcpcs_3_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_3_mdfr_cd + , cast(hcpcs_4_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_4_mdfr_cd + , cast(hcpcs_5_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_5_mdfr_cd + , cast(clm_disp_cd as {{ dbt.type_string() }}) as clm_disp_cd + , cast(clm_dgns_1_cd as {{ dbt.type_string() }}) as clm_dgns_1_cd + , cast(clm_dgns_2_cd as {{ dbt.type_string() }}) as clm_dgns_2_cd + , cast(clm_dgns_3_cd as {{ dbt.type_string() }}) as clm_dgns_3_cd + , cast(clm_dgns_4_cd as {{ dbt.type_string() }}) as clm_dgns_4_cd + , cast(clm_dgns_5_cd as {{ dbt.type_string() }}) as clm_dgns_5_cd + , cast(clm_dgns_6_cd as {{ dbt.type_string() }}) as clm_dgns_6_cd + , cast(clm_dgns_7_cd as {{ dbt.type_string() }}) as clm_dgns_7_cd + , cast(clm_dgns_8_cd as {{ dbt.type_string() }}) as clm_dgns_8_cd + , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }}) as dgns_prcdr_icd_ind + , cast(clm_dgns_9_cd as {{ dbt.type_string() }}) as clm_dgns_9_cd + , cast(clm_dgns_10_cd as {{ dbt.type_string() }}) as clm_dgns_10_cd + , cast(clm_dgns_11_cd as {{ dbt.type_string() }}) as clm_dgns_11_cd + , cast(clm_dgns_12_cd as {{ dbt.type_string() }}) as clm_dgns_12_cd + , cast(hcpcs_betos_cd as {{ dbt.type_string() }}) as hcpcs_betos_cd + , cast(file_name as {{ dbt.type_string() }}) as file_name + , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime +from {{ source('medicare_cclf','partb_physicians') }} \ No newline at end of file From 146fcc161aa26050b6fb53e504e6c7be1f9faf65 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 09:50:08 -0600 Subject: [PATCH 02/18] Update gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 8000891f70c504949df9152b6fc2d77630231fb4 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 10:04:10 -0600 Subject: [PATCH 03/18] Fix staging references --- models/intermediate/diagnosis_pivot.sql | 4 ++-- models/intermediate/procedure_pivot.sql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/models/intermediate/diagnosis_pivot.sql b/models/intermediate/diagnosis_pivot.sql index 4fd83af1..1694c91a 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 diff --git a/models/intermediate/procedure_pivot.sql b/models/intermediate/procedure_pivot.sql index f6b74749..97a2dfcf 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 From 2b95b60e0df152f9c52fa3a56caba510db529659 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 10:04:38 -0600 Subject: [PATCH 04/18] Add fields to claims --- models/final/medical_claim.sql | 164 ++++++++++++++++++- models/final/pharmacy_claim.sql | 44 ++--- models/intermediate/dme_claims.sql | 7 +- models/intermediate/institutional_claims.sql | 77 +++++---- models/intermediate/physician_claims.sql | 7 +- 5 files changed, 239 insertions(+), 60 deletions(-) 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..171faf67 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(1 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_string() }}) as ingest_datetime limit 0 \ No newline at end of file diff --git a/models/intermediate/dme_claims.sql b/models/intermediate/dme_claims.sql index 1869bb12..f4494309 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_string() }} ) 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..f8b25c21 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') }} a + left join {{ ref('stg_parta_claims_revenue_center_detail') }} 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 a + inner join {{ ref('stg_parta_claims_header') }} 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 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 @@ -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 + , cast(a.file_name as {{ dbt.type_string() }} ) as file_name + , cast(a.ingest_datetime as {{ dbt.type_string() }} ) as ingest_datetime from claim_line_a a -left join {{ source('medicare_cclf','parta_claims_header')}} h +left join {{ ref('stg_parta_claims_header') }} h on a.claim_id = h.cur_clm_uniq_id -left join {{ source('medicare_cclf','parta_claims_revenue_center_detail')}} d +left join {{ ref('stg_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 +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() }} ) +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() }} ) \ No newline at end of file diff --git a/models/intermediate/physician_claims.sql b/models/intermediate/physician_claims.sql index 9002a845..37c3c259 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_string() }} ) as ingest_datetime +from {{ ref('stg_partb_physicians') }} \ No newline at end of file From 83a71906cc6d7bdf0dd7586c47e0b6441551cf53 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 10:23:59 -0600 Subject: [PATCH 05/18] Add timestamp data type --- models/intermediate/dme_claims.sql | 2 +- models/intermediate/institutional_claims.sql | 2 +- models/intermediate/physician_claims.sql | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models/intermediate/dme_claims.sql b/models/intermediate/dme_claims.sql index f4494309..bfec3265 100644 --- a/models/intermediate/dme_claims.sql +++ b/models/intermediate/dme_claims.sql @@ -148,5 +148,5 @@ select , cast(1 as int) as in_network_flag , 'medicare cclf' as data_source , cast(file_name as {{ dbt.type_string() }} ) as file_name - , cast(ingest_datetime as {{ dbt.type_string() }} ) as ingest_datetime + , 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 f8b25c21..48f9b1c2 100644 --- a/models/intermediate/institutional_claims.sql +++ b/models/intermediate/institutional_claims.sql @@ -198,7 +198,7 @@ select , cast(1 as int) as in_network_flag , 'medicare cclf' as data_source , cast(a.file_name as {{ dbt.type_string() }} ) as file_name - , cast(a.ingest_datetime as {{ dbt.type_string() }} ) as ingest_datetime + , cast(a.ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime from claim_line_a a left join {{ ref('stg_parta_claims_header') }} h on a.claim_id = h.cur_clm_uniq_id diff --git a/models/intermediate/physician_claims.sql b/models/intermediate/physician_claims.sql index 37c3c259..8c884005 100644 --- a/models/intermediate/physician_claims.sql +++ b/models/intermediate/physician_claims.sql @@ -151,5 +151,5 @@ select , cast(1 as int) as in_network_flag , 'medicare cclf' as data_source , cast(file_name as {{ dbt.type_string() }} ) as file_name - , cast(ingest_datetime as {{ dbt.type_string() }} ) as ingest_datetime + , cast(ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime from {{ ref('stg_partb_physicians') }} \ No newline at end of file From c5177ca5a579fc06d43dd95bdc7cc6d54c831ffa Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 10:24:19 -0600 Subject: [PATCH 06/18] Update package version --- packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 387c7270885a249eca87d78615af49207bb7dfbe Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 10:32:27 -0600 Subject: [PATCH 07/18] Update yml --- models/_models.yml | 50 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/models/_models.yml b/models/_models.yml index 31d8e60b..b3a38b94 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: stg_beneficiary_demographics + description: Staging model for beneficiary demographics. + config: + schema: | + {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} + + - 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')}}_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: base_parta_diagnosis_code description: Base model used as ref for pivot transformation. 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. 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_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 -%} From 2302dc823ea5f5f01811b16a295f57c82dc337e2 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 16:48:32 -0600 Subject: [PATCH 08/18] Remove duplicative type casting --- .../staging/stg_beneficiary_demographics.sql | 68 ++++++------ models/staging/stg_parta_claims_header.sql | 78 +++++++------- ...stg_parta_claims_revenue_center_detail.sql | 48 ++++----- models/staging/stg_parta_diagnosis_code.sql | 30 +++--- models/staging/stg_parta_procedure_code.sql | 28 ++--- models/staging/stg_partb_dme.sql | 54 +++++----- models/staging/stg_partb_physicians.sql | 102 +++++++++--------- 7 files changed, 204 insertions(+), 204 deletions(-) diff --git a/models/staging/stg_beneficiary_demographics.sql b/models/staging/stg_beneficiary_demographics.sql index e6cbb610..f1d825fa 100644 --- a/models/staging/stg_beneficiary_demographics.sql +++ b/models/staging/stg_beneficiary_demographics.sql @@ -1,36 +1,36 @@ select - cast(bene_mbi_id as {{ dbt.type_string() }}) as bene_mbi_id - , cast(bene_member_month as {{ dbt.type_string() }}) as bene_member_month - , cast(bene_hic_num as {{ dbt.type_string() }}) as bene_hic_num - , cast(bene_fips_state_cd as {{ dbt.type_string() }}) as bene_fips_state_cd - , cast(bene_fips_cnty_cd as {{ dbt.type_string() }}) as bene_fips_cnty_cd - , cast(bene_zip_cd as {{ dbt.type_string() }}) as bene_zip_cd - , cast(bene_dob as {{ dbt.type_string() }}) as bene_dob - , cast(bene_sex_cd as {{ dbt.type_string() }}) as bene_sex_cd - , cast(bene_race_cd as {{ dbt.type_string() }}) as bene_race_cd - , cast(bene_age as {{ dbt.type_string() }}) as bene_age - , cast(bene_mdcr_stus_cd as {{ dbt.type_string() }}) as bene_mdcr_stus_cd - , cast(bene_dual_stus_cd as {{ dbt.type_string() }}) as bene_dual_stus_cd - , cast(bene_death_dt as {{ dbt.type_string() }}) as bene_death_dt - , cast(bene_rng_bgn_dt as {{ dbt.type_string() }}) as bene_rng_bgn_dt - , cast(bene_rng_end_dt as {{ dbt.type_string() }}) as bene_rng_end_dt - , cast(bene_1st_name as {{ dbt.type_string() }}) as bene_1st_name - , cast(bene_midl_name as {{ dbt.type_string() }}) as bene_midl_name - , cast(bene_last_name as {{ dbt.type_string() }}) as bene_last_name - , cast(bene_orgnl_entlmt_rsn_cd as {{ dbt.type_string() }}) as bene_orgnl_entlmt_rsn_cd - , cast(bene_entlmt_buyin_ind as {{ dbt.type_string() }}) as bene_entlmt_buyin_ind - , cast(bene_part_a_enrlmt_bgn_dt as {{ dbt.type_string() }}) as bene_part_a_enrlmt_bgn_dt - , cast(bene_part_b_enrlmt_bgn_dt as {{ dbt.type_string() }}) as bene_part_b_enrlmt_bgn_dt - , cast(bene_line_1_adr as {{ dbt.type_string() }}) as bene_line_1_adr - , cast(bene_line_2_adr as {{ dbt.type_string() }}) as bene_line_2_adr - , cast(bene_line_3_adr as {{ dbt.type_string() }}) as bene_line_3_adr - , cast(bene_line_4_adr as {{ dbt.type_string() }}) as bene_line_4_adr - , cast(bene_line_5_adr as {{ dbt.type_string() }}) as bene_line_5_adr - , cast(bene_line_6_adr as {{ dbt.type_string() }}) as bene_line_6_adr - , cast(geo_zip_plc_name as {{ dbt.type_string() }}) as geo_zip_plc_name - , cast(geo_usps_state_cd as {{ dbt.type_string() }}) as geo_usps_state_cd - , cast(geo_zip5_cd as {{ dbt.type_string() }}) as geo_zip5_cd - , cast(geo_zip4_cd as {{ dbt.type_string() }}) as geo_zip4_cd - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + 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 index 0e738a1c..1081ac49 100644 --- a/models/staging/stg_parta_claims_header.sql +++ b/models/staging/stg_parta_claims_header.sql @@ -1,41 +1,41 @@ select - cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id - , cast(prvdr_oscar_num as {{ dbt.type_string() }}) as prvdr_oscar_num - , 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_from_dt as {{ dbt.type_string() }}) as clm_from_dt - , cast(clm_thru_dt as {{ dbt.type_string() }}) as clm_thru_dt - , cast(clm_bill_fac_type_cd as {{ dbt.type_string() }}) as clm_bill_fac_type_cd - , cast(clm_bill_clsfctn_cd as {{ dbt.type_string() }}) as clm_bill_clsfctn_cd - , cast(prncpl_dgns_cd as {{ dbt.type_string() }}) as prncpl_dgns_cd - , cast(admtg_dgns_cd as {{ dbt.type_string() }}) as admtg_dgns_cd - , cast(clm_mdcr_npmt_rsn_cd as {{ dbt.type_string() }}) as clm_mdcr_npmt_rsn_cd - , cast(clm_pmt_amt as {{ dbt.type_string() }}) as clm_pmt_amt - , cast(clm_nch_prmry_pyr_cd as {{ dbt.type_string() }}) as clm_nch_prmry_pyr_cd - , cast(prvdr_fac_fips_st_cd as {{ dbt.type_string() }}) as prvdr_fac_fips_st_cd - , cast(bene_ptnt_stus_cd as {{ dbt.type_string() }}) as bene_ptnt_stus_cd - , cast(dgns_drg_cd as {{ dbt.type_string() }}) as dgns_drg_cd - , cast(clm_op_srvc_type_cd as {{ dbt.type_string() }}) as clm_op_srvc_type_cd - , cast(fac_prvdr_npi_num as {{ dbt.type_string() }}) as fac_prvdr_npi_num - , cast(oprtg_prvdr_npi_num as {{ dbt.type_string() }}) as oprtg_prvdr_npi_num - , cast(atndg_prvdr_npi_num as {{ dbt.type_string() }}) as atndg_prvdr_npi_num - , cast(othr_prvdr_npi_num as {{ dbt.type_string() }}) as othr_prvdr_npi_num - , cast(clm_adjsmt_type_cd as {{ dbt.type_string() }}) as clm_adjsmt_type_cd - , cast(clm_efctv_dt as {{ dbt.type_string() }}) as clm_efctv_dt - , cast(clm_idr_ld_dt as {{ dbt.type_string() }}) as clm_idr_ld_dt - , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }}) as bene_eqtbl_bic_hicn_num - , cast(clm_admsn_type_cd as {{ dbt.type_string() }}) as clm_admsn_type_cd - , cast(clm_admsn_src_cd as {{ dbt.type_string() }}) as clm_admsn_src_cd - , cast(clm_bill_freq_cd as {{ dbt.type_string() }}) as clm_bill_freq_cd - , cast(clm_query_cd as {{ dbt.type_string() }}) as clm_query_cd - , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }}) as dgns_prcdr_icd_ind - , cast(clm_mdcr_instnl_tot_chrg_amt as {{ dbt.type_string() }}) as clm_mdcr_instnl_tot_chrg_amt - , cast(clm_mdcr_ip_pps_cptl_ime_amt as {{ dbt.type_string() }}) as clm_mdcr_ip_pps_cptl_ime_amt - , cast(clm_oprtnl_ime_amt as {{ dbt.type_string() }}) as clm_oprtnl_ime_amt - , cast(clm_mdcr_ip_pps_dsprprtnt_amt as {{ dbt.type_string() }}) as clm_mdcr_ip_pps_dsprprtnt_amt - , cast(clm_hipps_uncompd_care_amt as {{ dbt.type_string() }}) as clm_hipps_uncompd_care_amt - , cast(clm_oprtnl_dsprtnt_amt as {{ dbt.type_string() }}) as clm_oprtnl_dsprtnt_amt - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + 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 index d00c924f..5ffd9afe 100644 --- a/models/staging/stg_parta_claims_revenue_center_detail.sql +++ b/models/staging/stg_parta_claims_revenue_center_detail.sql @@ -1,26 +1,26 @@ select - cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id - , cast(clm_line_num as {{ dbt.type_string() }}) as clm_line_num - , 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_line_from_dt as {{ dbt.type_string() }}) as clm_line_from_dt - , cast(clm_line_thru_dt as {{ dbt.type_string() }}) as clm_line_thru_dt - , cast(clm_line_prod_rev_ctr_cd as {{ dbt.type_string() }}) as clm_line_prod_rev_ctr_cd - , cast(clm_line_instnl_rev_ctr_dt as {{ dbt.type_string() }}) as clm_line_instnl_rev_ctr_dt - , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }}) as clm_line_hcpcs_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_line_srvc_unit_qty as {{ dbt.type_string() }}) as clm_line_srvc_unit_qty - , cast(clm_line_cvrd_pd_amt as {{ dbt.type_string() }}) as clm_line_cvrd_pd_amt - , cast(hcpcs_1_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_1_mdfr_cd - , cast(hcpcs_2_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_2_mdfr_cd - , cast(hcpcs_3_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_3_mdfr_cd - , cast(hcpcs_4_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_4_mdfr_cd - , cast(hcpcs_5_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_5_mdfr_cd - , cast(clm_rev_apc_hipps_cd as {{ dbt.type_string() }}) as clm_rev_apc_hipps_cd - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + 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 index b95e48be..85640a7b 100644 --- a/models/staging/stg_parta_diagnosis_code.sql +++ b/models/staging/stg_parta_diagnosis_code.sql @@ -1,17 +1,17 @@ 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 - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + cur_clm_uniq_id + , bene_mbi_id + , bene_hic_num + , clm_type_cd + , clm_prod_type_cd + , clm_val_sqnc_num + , clm_dgns_cd + , bene_eqtbl_bic_hicn_num + , prvdr_oscar_num + , clm_from_dt + , clm_thru_dt + , clm_poa_ind + , dgns_prcdr_icd_ind + , file_name + , ingest_datetime 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 index 30a2e7a4..3924b4eb 100644 --- a/models/staging/stg_parta_procedure_code.sql +++ b/models/staging/stg_parta_procedure_code.sql @@ -1,16 +1,16 @@ 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 - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + cur_clm_uniq_id + , bene_mbi_id + , bene_hic_num + , clm_type_cd + , clm_val_sqnc_num + , clm_prcdr_cd + , clm_prcdr_prfrm_dt + , bene_eqtbl_bic_hicn_num + , prvdr_oscar_num + , clm_from_dt + , clm_thru_dt + , dgns_prcdr_icd_ind + , file_name + , ingest_datetime 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 index 1717a606..12c62814 100644 --- a/models/staging/stg_partb_dme.sql +++ b/models/staging/stg_partb_dme.sql @@ -1,29 +1,29 @@ select - cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id - , cast(clm_line_num as {{ dbt.type_string() }}) as clm_line_num - , 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_from_dt as {{ dbt.type_string() }}) as clm_from_dt - , cast(clm_thru_dt as {{ dbt.type_string() }}) as clm_thru_dt - , cast(clm_fed_type_srvc_cd as {{ dbt.type_string() }}) as clm_fed_type_srvc_cd - , cast(clm_pos_cd as {{ dbt.type_string() }}) as clm_pos_cd - , cast(clm_line_from_dt as {{ dbt.type_string() }}) as clm_line_from_dt - , cast(clm_line_thru_dt as {{ dbt.type_string() }}) as clm_line_thru_dt - , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }}) as clm_line_hcpcs_cd - , cast(clm_line_cvrd_pd_amt as {{ dbt.type_string() }}) as clm_line_cvrd_pd_amt - , cast(clm_prmry_pyr_cd as {{ dbt.type_string() }}) as clm_prmry_pyr_cd - , cast(payto_prvdr_npi_num as {{ dbt.type_string() }}) as payto_prvdr_npi_num - , cast(ordrg_prvdr_npi_num as {{ dbt.type_string() }}) as ordrg_prvdr_npi_num - , cast(clm_carr_pmt_dnl_cd as {{ dbt.type_string() }}) as clm_carr_pmt_dnl_cd - , cast(clm_prcsg_ind_cd as {{ dbt.type_string() }}) as clm_prcsg_ind_cd - , cast(clm_adjsmt_type_cd as {{ dbt.type_string() }}) as clm_adjsmt_type_cd - , cast(clm_efctv_dt as {{ dbt.type_string() }}) as clm_efctv_dt - , cast(clm_idr_ld_dt as {{ dbt.type_string() }}) as clm_idr_ld_dt - , cast(clm_cntl_num as {{ dbt.type_string() }}) as clm_cntl_num - , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }}) as bene_eqtbl_bic_hicn_num - , cast(clm_line_alowd_chrg_amt as {{ dbt.type_string() }}) as clm_line_alowd_chrg_amt - , cast(clm_disp_cd as {{ dbt.type_string() }}) as clm_disp_cd - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + 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 index 51dcd520..313a7978 100644 --- a/models/staging/stg_partb_physicians.sql +++ b/models/staging/stg_partb_physicians.sql @@ -1,53 +1,53 @@ select - cast(cur_clm_uniq_id as {{ dbt.type_string() }}) as cur_clm_uniq_id - , cast(clm_line_num as {{ dbt.type_string() }}) as clm_line_num - , 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_from_dt as {{ dbt.type_string() }}) as clm_from_dt - , cast(clm_thru_dt as {{ dbt.type_string() }}) as clm_thru_dt - , cast(rndrg_prvdr_type_cd as {{ dbt.type_string() }}) as rndrg_prvdr_type_cd - , cast(rndrg_prvdr_fips_st_cd as {{ dbt.type_string() }}) as rndrg_prvdr_fips_st_cd - , cast(clm_prvdr_spclty_cd as {{ dbt.type_string() }}) as clm_prvdr_spclty_cd - , cast(clm_fed_type_srvc_cd as {{ dbt.type_string() }}) as clm_fed_type_srvc_cd - , cast(clm_pos_cd as {{ dbt.type_string() }}) as clm_pos_cd - , cast(clm_line_from_dt as {{ dbt.type_string() }}) as clm_line_from_dt - , cast(clm_line_thru_dt as {{ dbt.type_string() }}) as clm_line_thru_dt - , cast(clm_line_hcpcs_cd as {{ dbt.type_string() }}) as clm_line_hcpcs_cd - , cast(clm_line_cvrd_pd_amt as {{ dbt.type_string() }}) as clm_line_cvrd_pd_amt - , cast(clm_line_prmry_pyr_cd as {{ dbt.type_string() }}) as clm_line_prmry_pyr_cd - , cast(clm_line_dgns_cd as {{ dbt.type_string() }}) as clm_line_dgns_cd - , cast(clm_rndrg_prvdr_tax_num as {{ dbt.type_string() }}) as clm_rndrg_prvdr_tax_num - , cast(rndrg_prvdr_npi_num as {{ dbt.type_string() }}) as rndrg_prvdr_npi_num - , cast(clm_carr_pmt_dnl_cd as {{ dbt.type_string() }}) as clm_carr_pmt_dnl_cd - , cast(clm_prcsg_ind_cd as {{ dbt.type_string() }}) as clm_prcsg_ind_cd - , cast(clm_adjsmt_type_cd as {{ dbt.type_string() }}) as clm_adjsmt_type_cd - , cast(clm_efctv_dt as {{ dbt.type_string() }}) as clm_efctv_dt - , cast(clm_idr_ld_dt as {{ dbt.type_string() }}) as clm_idr_ld_dt - , cast(clm_cntl_num as {{ dbt.type_string() }}) as clm_cntl_num - , cast(bene_eqtbl_bic_hicn_num as {{ dbt.type_string() }}) as bene_eqtbl_bic_hicn_num - , cast(clm_line_alowd_chrg_amt as {{ dbt.type_string() }}) as clm_line_alowd_chrg_amt - , cast(clm_line_srvc_unit_qty as {{ dbt.type_string() }}) as clm_line_srvc_unit_qty - , cast(hcpcs_1_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_1_mdfr_cd - , cast(hcpcs_2_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_2_mdfr_cd - , cast(hcpcs_3_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_3_mdfr_cd - , cast(hcpcs_4_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_4_mdfr_cd - , cast(hcpcs_5_mdfr_cd as {{ dbt.type_string() }}) as hcpcs_5_mdfr_cd - , cast(clm_disp_cd as {{ dbt.type_string() }}) as clm_disp_cd - , cast(clm_dgns_1_cd as {{ dbt.type_string() }}) as clm_dgns_1_cd - , cast(clm_dgns_2_cd as {{ dbt.type_string() }}) as clm_dgns_2_cd - , cast(clm_dgns_3_cd as {{ dbt.type_string() }}) as clm_dgns_3_cd - , cast(clm_dgns_4_cd as {{ dbt.type_string() }}) as clm_dgns_4_cd - , cast(clm_dgns_5_cd as {{ dbt.type_string() }}) as clm_dgns_5_cd - , cast(clm_dgns_6_cd as {{ dbt.type_string() }}) as clm_dgns_6_cd - , cast(clm_dgns_7_cd as {{ dbt.type_string() }}) as clm_dgns_7_cd - , cast(clm_dgns_8_cd as {{ dbt.type_string() }}) as clm_dgns_8_cd - , cast(dgns_prcdr_icd_ind as {{ dbt.type_string() }}) as dgns_prcdr_icd_ind - , cast(clm_dgns_9_cd as {{ dbt.type_string() }}) as clm_dgns_9_cd - , cast(clm_dgns_10_cd as {{ dbt.type_string() }}) as clm_dgns_10_cd - , cast(clm_dgns_11_cd as {{ dbt.type_string() }}) as clm_dgns_11_cd - , cast(clm_dgns_12_cd as {{ dbt.type_string() }}) as clm_dgns_12_cd - , cast(hcpcs_betos_cd as {{ dbt.type_string() }}) as hcpcs_betos_cd - , cast(file_name as {{ dbt.type_string() }}) as file_name - , cast(ingest_datetime as {{ dbt.type_timestamp() }}) as ingest_datetime + 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 From f41645dafcfb126ca8387bf82ea9141186e3ea91 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 16:49:27 -0600 Subject: [PATCH 09/18] Update schema for final tables --- models/_models.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/_models.yml b/models/_models.yml index b3a38b94..463f229c 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')}}input_layer{% else %}input_layer{%- 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')}}input_layer{% else %}input_layer{%- 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')}}input_layer{% else %}input_layer{%- endif -%} + {%- if var('tuva_schema_prefix',None) != None -%}{{var('tuva_schema_prefix')}}_input_layer{% else %}input_layer{%- endif -%} materialized: table ### intermediate From 25e43a77526303ee6a040376239ce47a7c878a9e Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Wed, 21 Aug 2024 16:58:09 -0600 Subject: [PATCH 10/18] Add null placeholder to pharmacy claim --- models/final/pharmacy_claim.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/final/pharmacy_claim.sql b/models/final/pharmacy_claim.sql index 171faf67..f044e04b 100644 --- a/models/final/pharmacy_claim.sql +++ b/models/final/pharmacy_claim.sql @@ -19,7 +19,7 @@ select , cast(null as numeric) as coinsurance_amount , cast(null as numeric) as copayment_amount , cast(null as numeric) as deductible_amount - , cast(1 as int) as in_network_flag + , 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_string() }}) as ingest_datetime From cfac8b64681241d2285d0d027a6b640822f65b70 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 12:35:00 -0600 Subject: [PATCH 11/18] Fix data type in pharmacy claim --- models/final/pharmacy_claim.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/final/pharmacy_claim.sql b/models/final/pharmacy_claim.sql index f044e04b..64ee6828 100644 --- a/models/final/pharmacy_claim.sql +++ b/models/final/pharmacy_claim.sql @@ -22,5 +22,5 @@ select , 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_string() }}) as ingest_datetime + , cast(null as {{ dbt.type_timestamp() }}) as ingest_datetime limit 0 \ No newline at end of file From c2d77de8bce49934d1ba5ddce4462965a600f503 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 12:35:17 -0600 Subject: [PATCH 12/18] Add new fields to eligibility --- models/final/eligibility.sql | 72 +++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/models/final/eligibility.sql b/models/final/eligibility.sql index 90981357..46778217 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') }} -), +) -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,12 +154,16 @@ 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 on enrollment_span.bene_mbi_id = demographics.bene_mbi_id @@ -166,4 +173,33 @@ joined as ( ) -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 From 8234e4f52e9a8f86a490c3b6c61f3748e7883c2a Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 14:22:09 -0600 Subject: [PATCH 13/18] Standardize syntax --- models/intermediate/diagnosis_pivot.sql | 4 +- models/intermediate/institutional_claims.sql | 44 ++++++++++---------- models/intermediate/procedure_pivot.sql | 6 +-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/models/intermediate/diagnosis_pivot.sql b/models/intermediate/diagnosis_pivot.sql index 1694c91a..4df3ff3a 100644 --- a/models/intermediate/diagnosis_pivot.sql +++ b/models/intermediate/diagnosis_pivot.sql @@ -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/institutional_claims.sql b/models/intermediate/institutional_claims.sql index 48f9b1c2..f2bd19e2 100644 --- a/models/intermediate/institutional_claims.sql +++ b/models/intermediate/institutional_claims.sql @@ -4,9 +4,9 @@ with claim_line as ( 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') }} a - left join {{ ref('stg_parta_claims_revenue_center_detail') }} b - on a.cur_clm_uniq_id = b.cur_clm_uniq_id + 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 ) @@ -17,9 +17,9 @@ with claim_line as ( , a.claim_line_number , a.claim_row_number , b.clm_pmt_amt as paid_amount - from claim_line a - inner join {{ ref('stg_parta_claims_header') }} b - on a.claim_id = b.cur_clm_uniq_id + 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 ) @@ -31,10 +31,10 @@ with claim_line as ( , 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 + 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 ) @@ -197,15 +197,15 @@ select , {{ 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 - , cast(a.file_name as {{ dbt.type_string() }} ) as file_name - , cast(a.ingest_datetime as {{ dbt.type_timestamp() }} ) as ingest_datetime -from claim_line_a a -left join {{ ref('stg_parta_claims_header') }} h - on a.claim_id = h.cur_clm_uniq_id -left join {{ ref('stg_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() }} ) \ No newline at end of file + , 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/procedure_pivot.sql b/models/intermediate/procedure_pivot.sql index 97a2dfcf..c56b5c28 100644 --- a/models/intermediate/procedure_pivot.sql +++ b/models/intermediate/procedure_pivot.sql @@ -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 From 1ab183f01cf7d4f2b9628d332a38116b15ec5550 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 14:22:23 -0600 Subject: [PATCH 14/18] Fix terminology reference --- models/final/eligibility.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/final/eligibility.sql b/models/final/eligibility.sql index 46778217..1011700e 100644 --- a/models/final/eligibility.sql +++ b/models/final/eligibility.sql @@ -30,7 +30,7 @@ with demographics as ( , fips_state as ( - select * from {{ ref('terminology__ansi_fips_state') }} + select * from {{ ref('reference_data__ansi_fips_state') }} ) @@ -165,10 +165,10 @@ with demographics as ( , 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 ) From 84a562dfeed76a13e95f3060043ebf1b9477c48e Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 14:22:42 -0600 Subject: [PATCH 15/18] Fix model names in yml --- models/_models.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/_models.yml b/models/_models.yml index 463f229c..aaf6e7de 100644 --- a/models/_models.yml +++ b/models/_models.yml @@ -82,14 +82,14 @@ models: schema: | {%- if var('tuva_schema_prefix',None) != None -%}_{{var('tuva_schema_prefix')}}_stg_input_layer{% else %}_stg_input_layer{%- endif -%} - - name: base_parta_diagnosis_code - description: Base model used as ref for pivot transformation. + - 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: base_parta_procedure_code - description: Base model used as ref for pivot transformation. + - 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 -%} From 9ee5371376eb38bb4e3f9bb476eb8f2f19fa590d Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 14:31:02 -0600 Subject: [PATCH 16/18] Remove old tests for unsupported dbt version --- ...dbt_v1.3.0_bigquery_build_full_refresh.yml | 42 ------------------ ...dbt_v1.3.0_redshift_build_full_refresh.yml | 41 ------------------ ...bt_v1.3.0_snowflake_build_full_refresh.yml | 43 ------------------- 3 files changed, 126 deletions(-) delete mode 100644 .github/workflows/biweekly_dbt_v1.3.0_bigquery_build_full_refresh.yml delete mode 100644 .github/workflows/biweekly_dbt_v1.3.0_redshift_build_full_refresh.yml delete mode 100644 .github/workflows/biweekly_dbt_v1.3.0_snowflake_build_full_refresh.yml 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 From 4e8ba92e880f9379781f18916978f1fca037f0df Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 14:44:10 -0600 Subject: [PATCH 17/18] Update dbt version in github workflows --- ...bt_v1.6.3_bigquery_build_full_refresh.yml} | 8 ++++---- ...bt_v1.6.3_redshift_build_full_refresh.yml} | 8 ++++---- ...t_v1.6.3_snowflake_build_full_refresh.yml} | 8 ++++---- ...tor_dbt_v1.6.3_all_build_full_refresh.yml} | 20 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) rename .github/workflows/{dbt_v1.4.6_bigquery_build_full_refresh.yml => dbt_v1.6.3_bigquery_build_full_refresh.yml} (84%) rename .github/workflows/{dbt_v1.4.6_redshift_build_full_refresh.yml => dbt_v1.6.3_redshift_build_full_refresh.yml} (85%) rename .github/workflows/{dbt_v1.4.6_snowflake_build_full_refresh.yml => dbt_v1.6.3_snowflake_build_full_refresh.yml} (88%) rename .github/workflows/{outside_contributor_dbt_v1.4.6_all_build_full_refresh.yml => outside_contributor_dbt_v1.6.3_all_build_full_refresh.yml} (90%) 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"}' From 25bda392031a3d03afa76e4ccd8ea43a7ac1a996 Mon Sep 17 00:00:00 2001 From: sarah-tuva Date: Thu, 22 Aug 2024 17:31:22 -0600 Subject: [PATCH 18/18] Add data type casting to models before pivot --- models/staging/stg_parta_diagnosis_code.sql | 28 ++++++++++----------- models/staging/stg_parta_procedure_code.sql | 26 +++++++++---------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/models/staging/stg_parta_diagnosis_code.sql b/models/staging/stg_parta_diagnosis_code.sql index 85640a7b..b79d7160 100644 --- a/models/staging/stg_parta_diagnosis_code.sql +++ b/models/staging/stg_parta_diagnosis_code.sql @@ -1,17 +1,15 @@ select - cur_clm_uniq_id - , bene_mbi_id - , bene_hic_num - , clm_type_cd - , clm_prod_type_cd - , clm_val_sqnc_num - , clm_dgns_cd - , bene_eqtbl_bic_hicn_num - , prvdr_oscar_num - , clm_from_dt - , clm_thru_dt - , clm_poa_ind - , dgns_prcdr_icd_ind - , file_name - , ingest_datetime + 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 index 3924b4eb..487fafea 100644 --- a/models/staging/stg_parta_procedure_code.sql +++ b/models/staging/stg_parta_procedure_code.sql @@ -1,16 +1,14 @@ select - cur_clm_uniq_id - , bene_mbi_id - , bene_hic_num - , clm_type_cd - , clm_val_sqnc_num - , clm_prcdr_cd - , clm_prcdr_prfrm_dt - , bene_eqtbl_bic_hicn_num - , prvdr_oscar_num - , clm_from_dt - , clm_thru_dt - , dgns_prcdr_icd_ind - , file_name - , ingest_datetime + 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